In my ubuntu 14.xx, I try to compile lsnes emulator to use the mario-ai script from aleju/mario-ai, and I've tried to google many solutions to solve the problem below:
Here is the output from the console:
make[3]:
__all__.files' is up to date. make[3]: Leaving directory
/home/pengsuyu/software/lsnes/sourcecode/src/platform/macosx' make[2]: Leaving directory/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
cat core/all.ldflags lua/all.ldflags fonts/all.ldflags library/all.ldflags interface/all.ldflags video/all.ldflags emulation/all.ldflags cmdhelp/all.ldflags platform/all.ldflagscore/multitrack.o: In function
lua::state::get_string(int, std::string const&)': /home/pengsuyu/software/lsnes/sourcecode/src/core/../../include/library/lua-base.hpp:317: undefined reference tolua_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: undefined reference tolua_toboolean' core/multitrack.o: In function
lua::state::type(int)': . . /home/pengsuyu/software/lsnes/sourcecode/src/library/lua.cpp:536: undefined reference tolua_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: undefined reference tolua_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 tolua_getfield' library/lua.o: In function
lua::state::insert(int)': /home/pengsuyu/software/lsnes/sourcecode/src/library/../../include/library/lua-base.hpp:509: undefined reference tolua_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] Error 2
==================================
At the beginning, I think, the linker cannot find my lua library. So I tried to compile my main.cpp with test.lua.
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");
I write a MakeFile to generate the executable file "main":
main:main.o
gcc -o $@ $< -llua5.1 -lstdc++
main.o:
gcc -c main.cpp
clean:
-rm *.o
It works when I add the compile option "-llua5.1" and "-lstdc++" otherwise it throws the same error as I compiled lsnes
I am not familiar with gcc and Makefile. Please help me to solve this problem.