2017-03-29 11 views
0

在我的ubuntu 14.xx中,我嘗試編譯lsnes模擬器以使用aleju/mario-ai的mario-ai腳本,並且我試着谷歌許多解決方案來解決下面的問題:鏈接錯誤與「undefined lua_xxxxx」構建lsnes時

下面是從控制檯輸出:

補充[3]:__all__.files' is up to date. make[3]: Leaving directory /家庭/ pengsuyu /軟件/ lsnes /源碼/ src目錄/平臺/ MacOSX的」 化妝[2]:離開目錄/home/pengsuyu/software/lsnes/sourcecode/src/platform' g++ -o lsnes cat all_common .files all_platform .files -pthread -lboost_iostreams -lboost_filesystem -lboost_system -lz -lgcrypt -lgpg-error -L/usr/lib/x86_64-linux-gnu -lcurl -rdynamic -ldl貓核心/ 所有 .ldflags LUA/所有 .ldflags字體/ 所有 .ldflags庫/ 所有 .ldflags接口/ 所有 .ldflags視頻/ 所有 .ldflags仿真/ 所有。 LDFLAGS cmdhelp/所有 .ldflags平臺/ 所有 .ldflags core/multitrack.o: In function盧阿::狀態:: get_string(INT,的std :: string常量&)「: /家庭/ pengsuyu /軟件/ lsnes /源碼/ SRC /核心/../../include/library/lua-base.hpp:317 :未定義的參考lua_tolstring' core/multitrack.o: In function lua :: state :: get_bool(int,std :: string const &)': /home/pengsuyu/software/lsnes/sourcecode/src/core/../../include/library/ lua-base.hpp:334:未定義的參考lua_toboolean' core/multitrack.o: In function lua :: state :: type(int)': 。 。 /home/pengsuyu/software/lsnes/sourcecode/src/library/lua.cpp:536:undefined參考lua_close' library/lua.o: In function lua :: state :: pushcfunction(int()(lua_State))': /home/pengsuyu /software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:504:未定義引用lua_pushcclosure' library/lua.o: In function lua :: state :: getfield(int,char const *)': /home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:506:undefined reference to lua_getfield' library/lua.o: In function lua :: state :: insert(int)': /home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:509:undefined參考lua_insert' collect2: error: ld returned 1 exit status make[1]: *** [lsnes] Error 1 make[1]: Leaving directory/home/pengsuyu/software/lsnes/sourcecode/src' make:*** [src/all_files]錯誤2

==================================

在開始,我想連接器找不到我的lua庫。所以我試圖用test.lua編譯我的main.cpp。

main.cpp中:

#include <stdio.h> 
#include <iostream> 

//extern "C" 
//{ 
#include <lua.h> 
#include <lualib.h> 
#include <lauxlib.h> 
//} // liblua5.1-c++.a 
lua_State * L; 
int main() 
{ 
    L = lua_open(); 
    luaL_openlibs(L); 
    luaL_dofile(L, "d:\\test.lua"); 
    return 0; 
} 

test.lua:

print("Hello World"); 

我寫了一個Makefile文件生成的可執行文件 「主」:

main:main.o 
    gcc -o [email protected] $< -llua5.1 -lstdc++ 
main.o: 
    gcc -c main.cpp 
clean: 
    -rm *.o 

它工作時,我添加編譯選項「-llua5。1" 和‘-lstdC++’,否則它拋出了同樣的錯誤,因爲我編譯lsnes

我不熟悉gcc和Makefile文件。請幫我解決這個問題。

回答

0

我已經解決了我的問題

解決這個問題的方法就是改變一個行命名爲「options.build」的文件中。

1. find the line "LUA=lua" in options.build 

2. change this line to "LUA=lua5.1" 

,因爲所需要的庫是5.1,所以如果你想成功地建立它,你必須使用「lua5.1」庫但是默認配置是「lua」不是「lua5.1」