Reputation: 27211
Please, help me to understand the build process for luajit.
If I want to compile a c library I use this code:
gcc -shared -fpic -O -I/path-to-luajit-headers/luajit-2.1 mylib.c -o mylib.so
Is it needed to use more specific parameters like this:
gcc -shared -fpic -O -I/path-to-luajit-headers/luajit-2.1 -L/path-to-luajit/lib mylib.c -o mylib.so -lluajit-2.1
In the second case the .so file is twice larger than the first one. What is the difference? Is it important to use -lluajit-2.1
, etc. May be there are more parameters to define luajit mode instead of pure lua building mode?
Upvotes: 0
Views: 1124
Reputation: 4271
The interpreter needs access to the Lua API, and C extension modules need access to the Lua API, and both need to link to the same library, because otherwise bad things will happen (e.g. there will be two sets of static variables).
There are two common approaches to achieve theses requirements.
-Wl,-E
linker flag when building the interpreter.Since you seem to run a Unixoid OS, your first approach is probably the correct one (because your interpreter is likely re-exporting the Lua API already), and the second approach will link in the Lua API twice.
Upvotes: 1