lua-users home
lua-l archive

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

	I think it is ok, but I don't know the option '-Os'.

I put the -Os option here as a bad old habit, it asks the linker to omit all symbol information from the output file. I use it when cross-compiling for embedded applications to minimize the size of the binaries, but there is no need of it there so I replaced it by a more usual -O2.

	Open _cgi.c and search for 'add your libraries here'.  You
should add a line:

   {"lfs", luaopen_lfs},

	before the {NULL, NULL}.  This will add the library to the
launcher.  In cgi.lua (or t_cgi.lua) you'll have to comment the line

require"lfs" => --require"lfs"
I also added a #include "lfs.h" in _cgi.c to prevent a "undefined reference to luaopen_lfs". But I still have linking errors... Here is a trace of my _cgi build (I removed the -fPIC option and added my lfslib.a in the linking):

jmh@ubuntuBox:~/Lua/work/cgilua $ make -f Makefile_cgilua
sed -e "s|LUA_DIR|/usr/local/share/lua/5.0|" -e "s|LUA_LIBDIR|/usr/local/lib/lua/5.0|" -e "s|LIB_EXT||g" t_cgi.lua > cgi.lua
/usr/local/bin/luac -o cgi.lua
/usr/local/bin/bin2c | sed -e "s|lua_dobuffer|status=lua_dobuffer|" > cgi.lch gcc -O2 -Wall -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -I/usr/local/include/ -DINCLUDE_LUA -c -o _cgi.o _cgi.c gcc -O2 -Wall -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -I/usr/local/include/ -DINCLUDE_LUA -o _cgi _cgi.o lfslib.a -llua -llualib -lm -ldl
_cgi.o(.text+0x128): In function `runlua':
: undefined reference to `lua_dobuffer'
_cgi.o(.text+0x15b): In function `main':
: undefined reference to `lua_open'
collect2: ld a retourné 1 code d'état d'exécution
make: *** [_cgi] Erreur 1

The undefined ref to "lua_dobuffer" seems strange to me because it is intended to be referenced in liblualib.a (through the -llualib option) as the "nm" command tells me :

jmh@ubuntuBox:~/Lua/work/cgilua $ nm liblualib.a | grep lua_dobuffer
00001640 T lua_dobuffer

The same could be told for the undef ref to "lua_open"...

jmh@ubuntuBox:~/Lua/work/cgilua $ nm liblua.a | grep lua_open
00000520 T lua_open

Does it means that my -llualib & -llua don't refer to the right liblualib & liblua libraries? Or that my libraries are broken?

Thanks again,