Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation Errors #138

Closed
AndrewChicco opened this issue Dec 11, 2015 · 2 comments
Closed

Compilation Errors #138

AndrewChicco opened this issue Dec 11, 2015 · 2 comments

Comments

@AndrewChicco
Copy link

Hi,
I'm getting some major compilation errors attempting to compile a very simple program
(using Ubuntu 15.x with G++ 4.9.2).

These problems appeared when I added in all the selene specific code in the main function.

Can someone let me know if I'm doing something terribly wrong.

Please excuse my ignorance if I've done something very obviously wrong.

Thanks,
Andrew

include <selene.h>

include

include

using namespace std;
using namespace sel;

int main()
{
State state;
state.Load("./test.lua");
assert(state["foo"] == 4);
assert(state["bar"][3] == "hi");
assert(state["bar"]["key"] == "there");

// basic checking
cout << "Hello world!" << endl;
return 0;
}

-- test.lua
foo = 4
bar = {}
bar[3] = "hi"
bar["key"] = "there"

errors

-------------- Clean: Debug in LUATest (compiler: GNU GCC Compiler)---------------

Cleaned "LUATest - Debug"

-------------- Build: Debug in LUATest (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -std=c++11 -I/usr/include/lua5.2 -I/usr/include/selene -c /home/andrew/code/LUATest/LUATest/main.cpp -o obj/Debug/main.o
g++ -o bin/Debug/LUATest obj/Debug/main.o
obj/Debug/main.o: In function sel::MetatableRegistry::detail::_create_table_in_registry(lua_State*, std::string const&)': main.cpp:(.text+0x100): undefined reference tolua_pushlstring'
main.cpp:(.text+0x112): undefined reference to lua_createtable' main.cpp:(.text+0x125): undefined reference tolua_settable'
obj/Debug/main.o: In function sel::detail::_get(sel::detail::_id<int>, lua_State*, int)': main.cpp:(.text._ZN3sel6detail4_getENS0_3_idIiEEP9lua_Statei[_ZN3sel6detail4_getENS0_3_idIiEEP9lua_Statei]+0x12): undefined reference tolua_tointegerx'
obj/Debug/main.o: In function sel::detail::_get(sel::detail::_id<std::string>, lua_State*, int)': main.cpp:(.text._ZN3sel6detail4_getENS0_3_idISsEEP9lua_Statei[_ZN3sel6detail4_getENS0_3_idISsEEP9lua_Statei]+0x2c): undefined reference tolua_tolstring'
obj/Debug/main.o: In function sel::detail::_push(lua_State*, int)': main.cpp:(.text._ZN3sel6detail5_pushEP9lua_Statei[_ZN3sel6detail5_pushEP9lua_Statei]+0x10): undefined reference tolua_pushinteger'
obj/Debug/main.o: In function sel::detail::_push(lua_State*, std::string const&)': main.cpp:(.text._ZN3sel6detail5_pushEP9lua_StateRKSs[_ZN3sel6detail5_pushEP9lua_StateRKSs]+0x2e): undefined reference tolua_pushlstring'
obj/Debug/main.o: In function sel::test_stored_exception(lua_State*)': main.cpp:(.text._ZN3sel21test_stored_exceptionEP9lua_State[_ZN3sel21test_stored_exceptionEP9lua_State]+0xf): undefined reference tolua_isuserdata'
main.cpp:(.text._ZN3sel21test_stored_exceptionEP9lua_State[ZN3sel21test_stored_exceptionEP9lua_State]+0x3a): undefined reference to luaL_testudata' obj/Debug/main.o: In functionsel::ResetStackOnScopeExit::ResetStackOnScopeExit(lua_State)':
main.cpp:(.text._ZN3sel21ResetStackOnScopeExitC2EP9lua_State[_ZN3sel21ResetStackOnScopeExitC5EP9lua_State]+0x18): undefined reference to lua_gettop' obj/Debug/main.o: In functionsel::ResetStackOnScopeExit::~ResetStackOnScopeExit()':
main.cpp:(.text._ZN3sel21ResetStackOnScopeExitD2Ev[ZN3sel21ResetStackOnScopeExitD5Ev]+0x20): undefined reference to lua_settop' obj/Debug/main.o: In functionsel::detail::LuaRefDeleter::operator()(int) const':
main.cpp:(.text._ZNK3sel6detail13LuaRefDeleterclEPi[ZNK3sel6detail13LuaRefDeleterclEPi]+0x1b): undefined reference to luaL_unref' obj/Debug/main.o: In functionsel::LuaRef::Push(lua_State) const':
main.cpp:(.text._ZNK3sel6LuaRef4PushEP9lua_State[ZNK3sel6LuaRef4PushEP9lua_State]+0x24): undefined reference to lua_rawgeti' obj/Debug/main.o: In functionsel::Traceback(lua_State)':
main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0x16): undefined reference to lua_type' main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0x31): undefined reference tolua_tolstring'
main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0x52): undefined reference to lua_pushstring' main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0x65): undefined reference tolua_getglobal'
main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0x7a): undefined reference to lua_getfield' main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0x8a): undefined reference tolua_pushvalue'
main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0x9a): undefined reference to lua_pushinteger' main.cpp:(.text._ZN3sel9TracebackEP9lua_State[_ZN3sel9TracebackEP9lua_State]+0xb0): undefined reference tolua_callk'
obj/Debug/main.o: In function sel::SetErrorHandler(lua_State*)': main.cpp:(.text._ZN3sel15SetErrorHandlerEP9lua_State[_ZN3sel15SetErrorHandlerEP9lua_State]+0x14): undefined reference tolua_pushcclosure'
main.cpp:(.text._ZN3sel15SetErrorHandlerEP9lua_State[_ZN3sel15SetErrorHandlerEP9lua_State]+0x22): undefined reference to lua_gettop' obj/Debug/main.o: In functionsel::Selector::_get(sel::LuaRef) const':
main.cpp:(.text._ZNK3sel8Selector4_getENS_6LuaRefE[_ZNK3sel8Selector4_getENS_6LuaRefE]+0x26): undefined reference to lua_gettable' main.cpp:(.text._ZNK3sel8Selector4_getENS_6LuaRefE[_ZNK3sel8Selector4_getENS_6LuaRefE]+0x39): undefined reference tolua_absindex'
main.cpp:(.text._ZNK3sel8Selector4_getENS_6LuaRefE[_ZNK3sel8Selector4_getENS_6LuaRefE]+0x4d): undefined reference to lua_remove' obj/Debug/main.o: In functionsel::Selector::_check_create_table() const::{lambda()#1}::operator()() const':
main.cpp:(.text._ZZNK3sel8Selector19_check_create_tableEvENKUlvE_clEv[_ZZNK3sel8Selector19_check_create_tableEvENKUlvE_clEv]+0x16): undefined reference to lua_createtable' obj/Debug/main.o: In functionsel::Selector::_check_create_table() const':
main.cpp:(.text._ZNK3sel8Selector19_check_create_tableEv[_ZNK3sel8Selector19_check_create_tableEv]+0x55): undefined reference to lua_type' main.cpp:(.text._ZNK3sel8Selector19_check_create_tableEv[_ZNK3sel8Selector19_check_create_tableEv]+0x72): undefined reference tolua_settop'
obj/Debug/main.o: In function sel::Selector::_traverse() const': main.cpp:(.text._ZNK3sel8Selector9_traverseEv[_ZNK3sel8Selector9_traverseEv]+0x29): undefined reference tolua_rawgeti'
obj/Debug/main.o: In function sel::Selector::_evaluate_function_call(int) const': main.cpp:(.text._ZNK3sel8Selector23_evaluate_function_callEi[_ZNK3sel8Selector23_evaluate_function_callEi]+0x74): undefined reference tolua_pushvalue'
main.cpp:(.text._ZNK3sel8Selector23_evaluate_function_callEi[_ZNK3sel8Selector23_evaluate_function_callEi]+0x8b): undefined reference to lua_copy' main.cpp:(.text._ZNK3sel8Selector23_evaluate_function_callEi[_ZNK3sel8Selector23_evaluate_function_callEi]+0x9f): undefined reference tolua_replace'
main.cpp:(.text._ZNK3sel8Selector23_evaluate_function_callEi[_ZNK3sel8Selector23_evaluate_function_callEi]+0x14e): undefined reference to lua_pcallk' main.cpp:(.text._ZNK3sel8Selector23_evaluate_function_callEi[_ZNK3sel8Selector23_evaluate_function_callEi]+0x169): undefined reference tolua_remove'
obj/Debug/main.o: In function sel::State::State(bool)': main.cpp:(.text._ZN3sel5StateC2Eb[_ZN3sel5StateC5Eb]+0x5f): undefined reference toluaL_newstate'
main.cpp:(.text._ZN3sel5StateC2Eb[_ZN3sel5StateC5Eb]+0xa6): undefined reference to luaL_openlibs' obj/Debug/main.o: In functionsel::State::~State()':
main.cpp:(.text._ZN3sel5StateD2Ev[_ZN3sel5StateD5Ev]+0x32): undefined reference to lua_close' obj/Debug/main.o: In functionsel::State::Load(std::string const&)':
main.cpp:(.text._ZN3sel5State4LoadERKSs[_ZN3sel5State4LoadERKSs]+0x51): undefined reference to luaL_loadfilex' main.cpp:(.text._ZN3sel5State4LoadERKSs[_ZN3sel5State4LoadERKSs]+0x84): undefined reference tolua_tolstring'
main.cpp:(.text._ZN3sel5State4LoadERKSs[_ZN3sel5State4LoadERKSs]+0x163): undefined reference to lua_tolstring' main.cpp:(.text._ZN3sel5State4LoadERKSs[_ZN3sel5State4LoadERKSs]+0x243): undefined reference tolua_pcallk'
main.cpp:(.text._ZN3sel5State4LoadERKSs[_ZN3sel5State4LoadERKSs]+0x26b): undefined reference to lua_tolstring' obj/Debug/main.o: In functionsel::State::ForceGC()':
main.cpp:(.text._ZN3sel5State7ForceGCEv[_ZN3sel5State7ForceGCEv]+0x14): undefined reference to lua_gc' obj/Debug/main.o: In functionsel::LuaRef sel::make_Ref<std::string const&>(lua_State*, std::string const&)':
main.cpp:(.text.ZN3sel8make_RefIRKSsEENS_6LuaRefEP9lua_StateOT[ZN3sel8make_RefIRKSsEENS_6LuaRefEP9lua_StateOT]+0x2f): undefined reference to luaL_ref' obj/Debug/main.o: In functionvoid sel::Selector::_put<sel::Selector::_check_create_table() const::{lambda()#1}>(sel::Selector::_check_create_table() const::{lambda()#1}) const':
main.cpp:(.text.ZNK3sel8Selector4_putIZNKS0_19_check_create_tableEvEUlvE_EEvT[ZNK3sel8Selector4_putIZNKS0_19_check_create_tableEvEUlvE_EEvT]+0x39): undefined reference to lua_settable' main.cpp:(.text._ZNK3sel8Selector4_putIZNKS0_19_check_create_tableEvEUlvE_EEvT_[_ZNK3sel8Selector4_putIZNKS0_19_check_create_tableEvEUlvE_EEvT_]+0x4c): undefined reference tolua_settop'
obj/Debug/main.o: In function int sel::detail::_pop<int>(sel::detail::_id<int>, lua_State*)': main.cpp:(.text._ZN3sel6detail4_popIiEET_NS0_3_idIS2_EEP9lua_State[_ZN3sel6detail4_popIiEET_NS0_3_idIS2_EEP9lua_State]+0x23): undefined reference tolua_settop'
obj/Debug/main.o: In function std::string sel::detail::_pop<std::string>(sel::detail::_id<std::string>, lua_State*)': main.cpp:(.text._ZN3sel6detail4_popISsEET_NS0_3_idIS2_EEP9lua_State[_ZN3sel6detail4_popISsEET_NS0_3_idIS2_EEP9lua_State]+0x39): undefined reference tolua_settop'
obj/Debug/main.o: In function sel::LuaRef sel::make_Ref<int const&>(lua_State*, int const&)': main.cpp:(.text._ZN3sel8make_RefIRKiEENS_6LuaRefEP9lua_StateOT_[_ZN3sel8make_RefIRKiEENS_6LuaRefEP9lua_StateOT_]+0x31): undefined reference toluaL_ref'
Process terminated with status 1 (0 minute(s), 6 second(s))
50 error(s), 0 warning(s) (0 minute(s), 6 second(s))

@AnonymousProgrammerLandau
Copy link
Contributor

It seems your commandline g++ -o bin/Debug/LUATest obj/Debug/main.o misses parameters to link the Lua libraries.

@AndrewChicco
Copy link
Author

Hi AnonymousProgrammerLandau,
Much thanks for the hint. It seems to be all working now.
I was just missing the '-llua5.2' for the linking stage.

Andrew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants