I'm trying to add Lua to the project, but when I compile it I get an error:
LuaScript.cpp :(. Text + 0xf4): undefined reference to luaL_loadfilex
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8) project(Linaria) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/) set(CMAKE_C_COMPILER_INIT g++) find_package(SFML 2 REQUIRED system window graphics network audio) find_package(Lua REQUIRED) include_directories( ${SFML_INCLUDE_DIR} ${LUA_INCLUDE_DIR} include/ ) file(GLOB SRC "src/*.cpp" ) add_executable(Linaria ${SRC}) target_link_libraries(Linaria ${SFML_LIBRARIES} ${LUA_LIBRARIES} ) set_target_properties(Linaria PROPERTIES OUTPUT_NAME "Linaria" CLEAN_DIRECT_OUTPUT 1 ) add_definitions(-std=c++11 -w)
And here is the code:
void LuaScript::open(std::string file){ if(!this->luaState){ this->luaState = luaL_newstate(); if(luaL_loadfile(this->luaState, file.c_str())){ // File not found } luaL_openlibs(this->luaState); } } }
Nowhere did I find anything that would solve the error.
What to do?
undefined reference
often says that the corresponding library is not connected (by linker). Maybe the version is not the same, or bit. - αλεχολυτlua
, but alsolualib
. - aleksandr barakin-llua5.2 -llualib5.2
, but nothing has changed. - user26699@пользователь
). - aleksandr barakin