I have code that #include
s the files lua.h
, lapi.h
, lualib.h
, and lauxlib.h
from Lua's source. Now I have to actually compile this code.
My first thought is to include all of the .c
files in the Lua's source code or just figure out which of those .c
files I actually need, but is there a better or even right way to compile code that uses Lua 5.1's C API?
I should add that I am a complete beginning to compilation, and I know next to nothing. I do know what GCC is and how to run it from the command line, but that's about it.
To be more specific, I know that my compilation command using GCC will look something like this:
gcc code.c
Now, do I need to add every file in the Lua source as an argument like this?
gcc code.c lapi.c lauxlib.c lbaselib.c lcode.c …
or is there a better way to do this?
gcc code.c
is wrong. In practice, even for a single translation unitcode.c
which does not use external library (e.g. a hello-world program), you should compile it withgcc -Wall -Wextra -g code.c -o progbin
– Basile Starynkevitch-o
, so as far as I understand, they aren't necessary. I am open to you telling why they are, however. As for-o
, isn't it possible to compile and link in one step? I thought you only use-o
if you want to compile code files to object files so you can link them manually. – NetherGranite