Can build lua module, linker error

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

pietrko
Just popping in
Just popping in
Posts: 2
Joined: Sun Jul 03, 2016 10:46

Can build lua module, linker error

Postby pietrko » Sun Jul 03, 2016 10:57

Can't build lua module du to the linker error.

Make error

Code: Select all

CMakeFiles/toluappcegui-0.8.dir/tolua.c.o: In function `main':
/home/pietrko/projekty/worldforge/hammer/work/source/cegui-0.8.7/cegui/src/ScriptModules/Lua/support/tolua++bin/tolua.c:106: undefined reference to `lua_setglobal'
/home/pietrko/projekty/worldforge/hammer/work/source/cegui-0.8.7/cegui/src/ScriptModules/Lua/support/tolua++bin/tolua.c:107: undefined reference to `lua_setglobal'
/home/pietrko/projekty/worldforge/hammer/work/source/cegui-0.8.7/cegui/src/ScriptModules/Lua/support/tolua++bin/tolua.c:118: undefined reference to `lua_setglobal'
/home/pietrko/projekty/worldforge/hammer/work/source/cegui-0.8.7/cegui/src/ScriptModules/Lua/support/tolua++bin/tolua.c:121: undefined reference to `lua_setglobal'
CMakeFiles/toluappcegui-0.8.dir/tolua.c.o: In function `add_extra':
/home/pietrko/projekty/worldforge/hammer/work/source/cegui-0.8.7/cegui/src/ScriptModules/Lua/support/tolua++bin/tolua.c:69: undefined reference to `lua_getglobal'
/home/pietrko/projekty/worldforge/hammer/work/source/cegui-0.8.7/cegui/src/ScriptModules/Lua/support/tolua++bin/tolua.c:71: undefined reference to `lua_rawlen'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/toluappcegui-0.8] Błąd 1
make[1]: *** [cegui/src/ScriptModules/Lua/support/tolua++bin/CMakeFiles/toluappcegui-0.8.dir/all] Błąd 2
make[1]: *** Oczekiwanie na niezakończone zadania....
make: *** [all] Błąd 2


Make command used for building this file:

Code: Select all

 94%] Linking C executable ../../../../../../bin/toluappcegui-0.8
cd /home/pietrko/projekty/worldforge/hammer/work/build/cegui-0.8.7/native-64/cegui/src/ScriptModules/Lua/support/tolua++bin && /usr/bin/cmake -E cmake_link_script CMakeFiles/toluappcegui-0.8.dir/link.txt --verbose=1
/usr/bin/cc  -O2 -g -DNDEBUG  -std=c99  -fsigned-char -Wall -Wextra -Wno-unused-parameter -O3 -DNDEBUG   -L/home/pietrko/projekty/worldforge/hammer/work/local/lib  -fsigned-char -Wall -Wextra CMakeFiles/toluappcegui-0.8.dir/toluabind.c.o CMakeFiles/toluappcegui-0.8.dir/tolua.c.o  -o ../../../../../../bin/toluappcegui-0.8 -rdynamic -ltoluapp -llua5.1 -lm
cegui/src/ScriptModules/Lua/support/tolua++bin/CMakeFiles/toluappcegui-0.8.dir/build.make:123: polecenia dla obiektu 'bin/toluappcegui-0.8' nie powiodły się
make[2]: Opuszczenie katalogu '/home/pietrko/projekty/worldforge/hammer/work/build/cegui-0.8.7/native-64'
CMakeFiles/Makefile2:453: polecenia dla obiektu 'cegui/src/ScriptModules/Lua/support/tolua++bin/CMakeFiles/toluappcegui-0.8.dir/all' nie powiodły się
make[1]: Opuszczenie katalogu '/home/pietrko/projekty/worldforge/hammer/work/build/cegui-0.8.7/native-64'
Makefile:149: polecenia dla obiektu 'all' nie powiodły się



Configuration output

Code: Select all

loading initial cache file /home/pietrko/projekty/worldforge/hammer/support/CEGUI_defaults.cmake
-- The C compiler identification is GNU 6.1.1
-- The CXX compiler identification is GNU 6.1.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PCRE: /usr/lib64/libpcre.so 
-- Found FREETYPE: /usr/lib64/libfreetype.so 
-- Could NOT find MINIZIP (missing:  MINIZIP_LIB MINIZIP_H_PATH)
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1")
-- Checking for module 'fribidi'
--   Found fribidi, version 0.19.7
-- Found FRIBIDI: TRUE 
-- Looking for iconv
-- Looking for iconv - found
-- Found OpenGL: /usr/lib64/libGL.so 
-- Found GLEW: /usr/lib64/libGLEW.so 
-- Could NOT find GLM (missing:  GLM_H_PATH)
-- Could NOT find GLFW (missing:  GLFW_LIB GLFW_H_PATH)
-- Could NOT find GLFW3 (missing:  GLFW3_LIB GLFW3_H_PATH)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
-- Found SDL2: /usr/lib64/libSDL2.so;/usr/lib64/libSDL2main.a;-lpthread 
-- Could NOT find SDL2IMAGE (missing:  SDL2IMAGE_LIB SDL2IMAGE_H_PATH)
-- Could NOT find DIRECTXSDK (missing:  DIRECTXSDK_LIB_PATH DIRECTXSDK_H_PATH DIRECTXSDK_MAX_D3D)
-- Could NOT find D3DX11EFFECTS (missing:  D3DX11EFFECTS_LIB D3DX11EFFECTS_H_PATH)
-- Could NOT find IRRLICHT (missing:  IRRLICHT_LIB IRRLICHT_H_PATH)
-- Found OGRE: /usr/lib64/libOgreMain.so 
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   thread
--   system
--   chrono
--   date_time
--   atomic
-- Found OIS: /usr/lib64/libOIS.so 
-- Could NOT find DIRECTFB (missing:  DIRECTFB_LIB DIRECTFB_H_PATH)
-- Could NOT find OPENGLES (missing:  OPENGLES_LIB)
-- Found EPOXY: /usr/lib64/libepoxy.so 
-- Found EXPAT: /usr/lib64/libexpat.so 
-- Could NOT find XERCESC (missing:  XERCESC_LIB XERCESC_H_PATH)
-- Found LibXml2: /usr/lib64/libxml2.so (found version "2.9.4")
-- Found TINYXML: /usr/lib64/libtinyxml.so 
-- Performing Test TINYXML_API_TEST
-- Performing Test TINYXML_API_TEST - Success
-- Could NOT find RAPIDXML (missing:  RAPIDXML_H_PATH)
-- Could NOT find IL (missing:  IL_LIB IL_H_PATH)
-- Could NOT find ILU (missing:  ILU_LIB)
-- Found FREEIMAGE: /usr/lib64/libfreeimage.so 
-- Could NOT find SILLY (missing:  SILLY_LIB SILLY_H_PATH)
-- Could NOT find CORONA (missing:  CORONA_LIB CORONA_H_PATH)
-- Could NOT find PVRTOOLS (missing:  PVRTOOLS_LIB PVRTOOLS_H_PATH)
-- Found LUA51: /usr/lib64/liblua5.1.so 
-- Found TOLUAPP: /usr/lib64/libtoluapp.so 
-- Found PythonInterp: /usr/bin/python (found version "2.7.11")
-- Found PythonLibs: /usr/lib64/libpython2.7.so (found suitable exact version "2.7.11")
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   python
--   unit_test_framework
--   system
--   timer
--   chrono
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE)
-- Found GTK2_GTK: /usr/lib64/libgtk-x11-2.0.so 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pietrko/projekty/worldforge/hammer/work/build/cegui-0.8.7/native-64




Help no idea what's happening I have lua51 and tolua + regular lua (5.3) but linker seems to receive right options.


EDIT:
It turns our lua5.1 doesn't have lua_setglobal symbols indeed... Why is this happening?

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Can build lua module, linker error

Postby YaronCT » Sun Jul 03, 2016 18:10

@pietrko: Plz specify distribution (name, ver, arch). I guess Fedora 24 x64?

pietrko
Just popping in
Just popping in
Posts: 2
Joined: Sun Jul 03, 2016 10:46

Re: Can build lua module, linker error

Postby pietrko » Mon Jul 04, 2016 13:37

ArchLinux, 4.6.1, x86_64 (there aren't versions of archlinux its rolling release distro).
I'm using CEGUI 0.8.7.
I'm building it from sources as a part of worldforge project. We don't apply any patches only defaults CMAKE options.
It looks like wrong header is used somehow, despite CEGUI correctly detecting both lua5.1 libs and headers.

I've checked that CMAKE FindLua51.cmake does its job.
Linker uses for sure -llua5.1.
Function that are referenced are really in llua (version 5.2 or newer). I've checked manully libs on my distro (lua.so and lua5.1.so)

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Can build lua module, linker error

Postby YaronCT » Wed Jul 06, 2016 09:23

@pietrko: Ok, that was a confusing bug.. "lua_getglobal" isn't in "liblua51.so". However, it's defined in "lua.h" (in Lua 5.1) as:

#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))

So the linker should have perhaps complained about undefined reference to "lua_getfield" rather than "lua_getglobal". What happens is, that file ("lua.h" from Lua 5.1) isn't "#include"-d at all. Instead, "lua.h" from Lua 5.3 is used. Y? Coz "toloa++.h" has:

Code: Select all

#include "lua.h"
#include "lauxlib.h"


Which is a bug. It should have been:

Code: Select all

#include <lua.h>
#include <lauxlib.h>


The problem with the current implementation is that it first looks in the same directory of the current file, *before* directories specified with "-I" or "-isystem". In this case the file is in "/usr/include" so it always uses "/usr/include/lua.h", which is Lua 5.3. Therefore it's impossible to make it use a specific Lua version - In this case we're interested in Lua 5.1's version, located at "/usr/include/lua5.1". That's a wrong way to include a library. Untill ToLua++ is fixed, u can work around this by changing "cegui/src/ScriptModules/Lua/support/tolua++bin/tolua.c". Move the line:

Code: Select all

#include "tolua++.h"


To just after:

Code: Select all

#include "lauxlib.h"

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Can build lua module, linker error

Postby YaronCT » Wed Jul 06, 2016 10:29

And yes, I'm aware of us doing the same wrong thing using #include "..." for external libs.. We'll fix that.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 27 guests