试图编译lua文件时发生gcc错误

试图编译lua文件时发生gcc错误,gcc,lua,Gcc,Lua,我正在尝试使用以下方法从lua文件创建可执行文件: 我使用bintocee实用程序(from:)将myfile.lua转换为code.c。然后我使用以下main.c(from:) 但是,我得到以下错误: /tmp/ccyIOC0O.o: In function `main': main.c:(.text+0x21): undefined reference to `luaL_newstate' main.c:(.text+0x2f): undefined reference to `luaL_o

我正在尝试使用以下方法从lua文件创建可执行文件:

我使用bintocee实用程序(from:)将myfile.lua转换为code.c。然后我使用以下main.c(from:)

但是,我得到以下错误:

/tmp/ccyIOC0O.o: In function `main':
main.c:(.text+0x21): undefined reference to `luaL_newstate'
main.c:(.text+0x2f): undefined reference to `luaL_openlibs'
main.c:(.text+0x41): undefined reference to `lua_createtable'
main.c:(.text+0x62): undefined reference to `lua_pushnumber'
main.c:(.text+0x82): undefined reference to `lua_pushstring'
main.c:(.text+0x92): undefined reference to `lua_rawset'
main.c:(.text+0xb7): undefined reference to `lua_setfield'
main.c:(.text+0xd5): undefined reference to `luaL_loadbuffer'
main.c:(.text+0xea): undefined reference to `lua_pcall'
main.c:(.text+0xf8): undefined reference to `lua_close'
collect2: error: ld returned 1 exit status

我正在使用Linux Debian Stable(更新版)。问题在哪里?如何解决?谢谢您的帮助。

既然您安装了
liblua-5.1-dev
,我假设您使用的是Debian或其衍生工具。在这里,您必须链接到
-llua5.1
,如下所示:

gcc -O2 -Wall -I/usr/include/lua5.1 main.c -llua5.1

lua
有一个小小的想法,但它显然需要一些库来链接。我尝试安装liblua5.1和liblua5.1-dev,但同样的错误仍然存在。你需要链接到。类似于gcc main.c-llua-o myfile.exe的东西(不知道实际名称)是的,它可以工作。如果您能简要说明此处使用的所有选项,将对所有人都有帮助。
/tmp/ccyIOC0O.o: In function `main':
main.c:(.text+0x21): undefined reference to `luaL_newstate'
main.c:(.text+0x2f): undefined reference to `luaL_openlibs'
main.c:(.text+0x41): undefined reference to `lua_createtable'
main.c:(.text+0x62): undefined reference to `lua_pushnumber'
main.c:(.text+0x82): undefined reference to `lua_pushstring'
main.c:(.text+0x92): undefined reference to `lua_rawset'
main.c:(.text+0xb7): undefined reference to `lua_setfield'
main.c:(.text+0xd5): undefined reference to `luaL_loadbuffer'
main.c:(.text+0xea): undefined reference to `lua_pcall'
main.c:(.text+0xf8): undefined reference to `lua_close'
collect2: error: ld returned 1 exit status
gcc -O2 -Wall -I/usr/include/lua5.1 main.c -llua5.1