Better to use the list since it will be
archived etc.
I must admit to never having read up on
the difference between -fPIC and -fpic. I still don’t get why gcc
has two options instead of one, but I guess that’s just a mystery for the
ages. But anyway, goodbye -fPIC and –llua…
The new configuration script in svn is
definitely far superior to the old build system, but using libtool and having a
configurable path to Lua would probably be a smart thing to implement.
Thanks,
-W.W.
From:
address@hidden [mailto:address@hidden On Behalf Of Arjen P. de Vries
Sent: Thursday, August 03, 2006
4:55 PM
To: Will Weisser
Subject: Makefile question
Hi Will,
(I do not know if you'd prefer to have this sent to the list.)
To get the language extension compiled and running on our x64 amd machines, I
had to add -fpic to the .c.o rule in lib/Makefile.
I also changed the Makefile in bindings/lua to not link to lua itself (so
removed -llua).
Finally, I use -fpic instead of -fPIC.
These two changes were inspired by the lua wiki on modules, where they suggest
never to link to the lua library as it may cause hard to trace problems
(especially when updating lua).
(see: http://lua-users.org/wiki/BuildingModules)
The libtool commands given there work also; with the svn Makefile they are not
needed, but in the archive I used:
PREFIX=/ufs/arjen/local
LIBTOOL="libtool --tag=CC --silent"
$LIBTOOL --mode=compile cc -I$PREFIX/include -c cinvoke_lua.c
$LIBTOOL --mode=link cc -rpath $PREFIX/lib/lua/5.1 -L$PREFIX/lib
-lcinvoke -o libcinvoke_lua.la cinvoke_lua.lo
cp .libs/libcinvoke_lua.so.0.0.0 cinvoke_lua.so
cp cinvoke_lua.so $PREFIX/lib/lua/5.1
Hopefully this is of use,
Arjen
On 03/08/06, Will
Weisser <address@hidden>
wrote:
Sorry about that, the server rebooted for a security update
and I had to manually restart the daemon.
Thanks for using the software.
-W.W.
Subject: Re:
[cinvoke-dev] Question: cinv.string_to_chararray lua binding
Hi, great, thanks for the quick responses!
Indeed, your guess is right, so many thanks,
Arjen
PS: the svn repository could not be reached today, which is why I used the
tar-ball.
Will try again!
On
03/08/06, Will Weisser <address@hidden>
wrote:
Yes, string_to_chararray is broken, the below patch
fixes it. There is
also another patch for ptr_to_string:
@@ -1359,7 +1359,7 @@
int _cinv_ptr_to_string(lua_State *l) {
char *ptr;
int len = -1;
- if (lua_gettop(l) != 1 || lua_gettop(l)
!= 2) {
+ if (lua_gettop(l) != 1 &&
lua_gettop(l) != 2) {
lua_pushstring(l,
"usage: cinv.ptr_to_string(cptr[,
len])");
lua_error(l);
}
Or you can grab the latest source out of subversion which has several
Lua fixes not in the 0.9 release.
The reason I mention ptr_to_string is that I think to do what you're
trying to do you'll probably need to use it, assuming the char ** is an
"out" parameter:
address@hidden test]$ cat test.c
void foo(char **c) {
*c = "hello";
}
address@hidden test]$ gcc -shared -o test.so test.c
address@hidden test]$ cat test.lua
require("cinvoke_lua")
lib = clibrary.new("./test.so")
foo = lib:get_function(Cvoid, "foo", cinv.array (Cptr))
ptr_arr = { "0" } -- initialize with null pointer
foo(ptr_arr)
print(cinv.ptr_to_string(ptr_arr[1]))
address@hidden test]$ lua test.lua
Hello
address@hidden test]$
-W.W .
-----Original Message-----
From: cinvoke-dev-bounces+wweisser=address@hidden
[mailto:address@hidden ] On
Behalf Of
Shmuel Zeigerman
Sent: Thursday, August 03, 2006 2:03 PM
To: address@hidden
Subject: Re: [cinvoke-dev] Question: cinv.string_to_chararray lua
binding
This patch should help:
cinvoke_lua.c, line 1295.
- lua_settable(l, 1);
+ lua_settable(l, -3);
Arjen P. de Vries wrote:
> I was trying to use cinvoke, and first experiment worked fine,
> but now I want to call a function with parameter char** and have not
> been successful so far.
>
> I ended up doing:
> require("cinvoke_lua")
> c = cinv.string_to_chararray ("Test", true)
> print("c[1] = " .. c[1])
>
> which gives the error message:
> lua: attempt to index a string value
> stack traceback:
> [C]: in
function 'string_to_chararray'
> t.lua:2: in
main chunk
> [C]: ?
>
> Am I doing something wrong?
_______________________________________________
cinvoke-dev mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/cinvoke-dev
_______________________________________________
cinvoke-dev mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/cinvoke-dev
--
====================================================================
CWI, room
C1.16 Centre for
Mathematics and Computer Science
Kruislaan
413
Email: address@hidden
1098 SJ
Amsterdam
tel: +31-(0)20-5924306
The Netherlands
fax: +31-(0)20-5924312
===================== http://www.cwi.nl/~arjen/
====================
--
====================================================================
CWI, room
C1.16 Centre for
Mathematics and Computer Science
Kruislaan
413
Email: address@hidden
1098 SJ
Amsterdam
tel: +31-(0)20-5924306
The Netherlands
fax: +31-(0)20-5924312
===================== http://www.cwi.nl/~arjen/
====================
|