C++ 无法链接预编译的Lua二进制文件

C++ 无法链接预编译的Lua二进制文件,c++,lua,g++,C++,Lua,G++,我正在尝试使用MinGW编译一个涉及Lua的示例程序 #include <stdlib.h> #include <lua.hpp> int main(void) { lua_State *L = luaL_newstate(); luaL_openlibs(L); lua_close(L); exit(EXIT_SUCCESS); } 批处理文件如下所示: g++ -c -v -Iinclude src/Main.cpp g++ -v

我正在尝试使用MinGW编译一个涉及Lua的示例程序

#include <stdlib.h>

#include <lua.hpp>

int main(void) {
    lua_State *L = luaL_newstate();
    luaL_openlibs(L);
    lua_close(L);
    exit(EXIT_SUCCESS);
}
批处理文件如下所示:

g++ -c -v -Iinclude src/Main.cpp
g++ -v -o bin/main Main.o -Llib -llua53
del Main.o
pause
据我所知,此设置应该可以工作,但链接器在每次调用Lua函数时都会抛出未定义的引用错误:

Main.o:Main.cpp:(.text+0xf): undefined reference to `luaL_newstate'
Main.o:Main.cpp:(.text+0x1f): undefined reference to `luaL_openlibs'
Main.o:Main.cpp:(.text+0x2b): undefined reference to `lua_close'

我做错了什么?

你试过LuaBinaries的32位DLL吗?有些MinGW发行版默认编译为32位(有些根本不支持64位编译)……我可以发誓我已经试过了。不过它起作用了,所以谢谢!你试过LuaBinaries的32位DLL吗?有些MinGW发行版默认编译为32位(有些根本不支持64位编译)……我可以发誓我已经试过了。不过它起作用了,所以谢谢!
Main.o:Main.cpp:(.text+0xf): undefined reference to `luaL_newstate'
Main.o:Main.cpp:(.text+0x1f): undefined reference to `luaL_openlibs'
Main.o:Main.cpp:(.text+0x2b): undefined reference to `lua_close'