lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Luiz,

thanks for your answer,

On Thu, Oct 27, 2016 at 12:24 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> Compiling with this statement:
> gcc -g -Wall -shared -fPIC example1.c luamodule.c -o example2.so
> -I/usr/include/lua5.2 -llua5.2 -lm -ldl

This is confusing. What is in example1.c?

if you see my luamodule.c, there is an included header, example.h. The example.c|h pair aremy "external" library, what I want to wrap.
 
Also, I don't think you need -llua5.2 -lm -ldl.

yep, you're right - I just copied those flags from my test embedded Lua source.
 
You may end up with a copy of the Lua runtime in example2.so.

right, thanks,
 

You may want to have a look at my libraries and their Makefiles:
        http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/


Well, many thanks for this - I'll review that!
 
Look at a simple one like lbase64 or lrandom.
You may need to add -fPIC to CFLAGS and MAKESO.

yes, I know, but now it doesn't matter, I just make a short and "ugly" makefile wihout any flags/other variables... 


Many thanks for your notations.

An other question: does anybody use SWIG with Lua? The final plan would be that, but SWIG doesn't have several helper files, eg. cstring.i, which helps to handle strings.
Eg.: in my C library, there are several function, which expects a special char * arguments, where function stores its result. In cases of most languages (Python, Perl, ...) SWIG transforms
these functions that the language specific functions returns a string, and not necessary to push a plus buffer. For eg., see my first email in this thread: the get_str() expects two char *, and the 1st argument will be duplicated in 2nd.
But in Lua, the get_str() expects only one argument, and gives back the result.

So, in SWIG, this doesn't work - I'm looking for the solution.


Thanks again,


a.