lua-users home
lua-l archive

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


Hi,

Even if I am pretty new to lua I have some major problems.
I am writing a lua application at the University of Saarland (Germany)
on Mac OS X. I need to load a c-library out of lua. To avoid problems
with Mac OS X, I installed lua-5.1-work5 without problems (thanks to the
mailing list).
It is still no problem trying to compile the library itself following
the instructions given in the lua-wiki.
(http://lua-users.org/wiki/BuildingModules)

	MACOSX_DEPLOYMENT_TARGET="10.3"
	export MACOSX_DEPLOYMENT_TARGET
	gcc -O2 -fno-common -c -o clib.o clib.c
	gcc -bundle -undefined dynamic_lookup -o clib.so clib.o

But when I try to load the library with the following code:

	clib = loadlib ("./clib.so", "luaopen_clib")
	clib()

I return the following error:

	lua: main.lua:15: attempt to call global `clib' (a nil value)
	stack traceback:
        	main.lua:15: in main chunk
	        (luac): in main chunk
	        [C]: ?

Sorry but I have no Idea what I am doing wrong or what could be the
problem (the file does exist).

By the way: The complete code is working under Linux (Debian).
There I use other compile flags to build my shared library:

	gcc -shared -o clib.so clib.o



Thank a lot for your help.



Have a nice day

Kim Herzig