r/programminghelp • • Sep 30 '20

C Linking to liblua.a file with Linux and GCC

I'm following a tutorial about embedding Lua in c++ and I'm following along but in C and with the intention to compile for Linux. The guy in the tutorial is using Visual Studio 2017 and links to liblua.a by doing

#ifdef _WIN32
#pragma comment(lib, "Lua540/liblua54.a")
#endif

How do I do this but for GCC?

3 Upvotes

1 comment sorted by

3

u/[deleted] Sep 30 '20

IIRC GCC doesn't accept linking from source files like this. It's been a while but I think you'll have to do something like:

gcc -static myfile.c -lliblua54 -o myfile.exe

etc