I'm following @stetre's amazing guide (link to guide) on how to embed Lua in C/C++
Note: I'm a complete beginner, and it may be obvious to more experienced Lua developers, but I'm posting some of the additional steps I had to take just in case others experience the same problem.
I got
when I tried to compile the program with
The solution was to install
Then I got another error:
Same problem, I had to add the version explicitly:
It compiled and I was able to run the script.
- Lua version: 5.3
- Operating system: Ubuntu 20.04 LTS
Note: I'm a complete beginner, and it may be obvious to more experienced Lua developers, but I'm posting some of the additional steps I had to take just in case others experience the same problem.
I got
Code:
main.c:2:10: fatal error: lua.h: No such file or directory
2 | #include <lua.h>
| ^~~~~~~
compilation terminated.
Bash:
cc -o myapp main.c -llua -lm -ldl
The solution was to install
liblua5.3-dev
(apt-get install liblua5.3-dev
) and specify the Lua version when including the headers like this:
C:
#include <lua5.3/lua.h>
#include <lua5.3/lualib.h>
#include <lua5.3/lauxlib.h>
Then I got another error:
Code:
/usr/bin/ld: cannot find -llua
collect2: error: ld returned 1 exit status
Same problem, I had to add the version explicitly:
Bash:
cc -o myapp main.c -llua5.3 -lm -ldl
It compiled and I was able to run the script.