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

Linking CXX executable osrm-extract failed #1925

Closed
Dentro opened this issue Jan 24, 2016 · 18 comments
Closed

Linking CXX executable osrm-extract failed #1925

Dentro opened this issue Jan 24, 2016 · 18 comments

Comments

@Dentro
Copy link

Dentro commented Jan 24, 2016

Linking CXX executable osrm-extract

more undefined references to `lua_objlen' follow
collect2: error: ld returned 1 exit status
CMakeFiles/osrm-extract.dir/build.make:120: recipe for target 'osrm-extract' failed
make[2]: *** [osrm-extract] Error 1
CMakeFiles/Makefile2:503: recipe for target 'CMakeFiles/osrm-extract.dir/all' failed
make[1]: *** [CMakeFiles/osrm-extract.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2

Ubuntu 15.10

-- Building on a 64 bit system
-- Configuring OSRM in release mode
-- LTO working
-- Using gcc specific binutils for LTO.
-- Setting linker optimizations
-- Boost version: 1.60.0
-- Found the following Boost libraries:
-- date_time
-- filesystem
-- iostreams
-- program_options
-- regex
-- system
-- thread
-- unit_test_framework
-- Found Intel TBB
-- Looking for Luabind...
-- Found Luabind: /usr/lib/libluabind.so
-- Looking for LuaJIT 5.2
-- Found LuaJIT: LUAJIT_LIBRARY-NOTFOUND
-- Performing Test LUABIND_WORKS
-- Performing Test LUABIND_WORKS - Success
-- Luabind/Lua5.2 combination working with /usr/lib/x86_64-linux-gnu/liblua5.2.so
-- Looking for STXXL...
-- Found STXXL: /usr/lib/libstxxl.so
-- OpenMP support found. Linking just in case for stxxl
-- Configuring done
-- Generating done
How to fix it ?

@daniel-j-h
Copy link
Member

It seems like CMake tries Lua 5.2 first and that fails since we're not linking the appropriate library in. Trying to reproduce during the next days.

In the meantime, could you post the Lua version your libluabind is linked against?

ldd /usr/lib/libluabind.so | grep lua

if it's something like .. => ../liblua5.1.so.0 then you have to install the Lua 5.1 dev packages as per

sudo apt-get install lua5.1 liblua5.1-0-dev

remove your build directory and run CMake again. Then it should automatically detect and use Lua 5.1.

@Dentro
Copy link
Author

Dentro commented Jan 24, 2016

I have liblua5.2.so.0 => /usr/lib/x86_64-linux-gnu/liblua5.2.so.0

@daniel-j-h
Copy link
Member

I have liblua5.2.so.0 => /usr/lib/x86_64-linux-gnu/liblua5.2.so.0

Please check for libluabind and not liblua.

@Dentro
Copy link
Author

Dentro commented Jan 24, 2016

after entering (ldd /usr/lib/libluabind.so | grep lua) I only
liblua5.2.so.0 => /usr/lib/x86_64-linux-gnu/liblua5.2.so.0

@daniel-j-h
Copy link
Member

Ah right, you already piped it through grep! My mistake. So, your libluabind is linked against Lua 5.2, which means osrm-backend also has to link against Lua 5.2.

Looking at the symbols

nm --defined-only --demangle --print-file-name /usr/lib/x86_64-linux-gnu/liblua5.2.a |ag objlen
/usr/lib/x86_64-linux-gnu/liblua5.2.a:lvm.o:0000000000000c40 T luaV_objlen

nm --defined-only --demangle --print-file-name /usr/lib/x86_64-linux-gnu/liblua5.1.a |ag objlen
/usr/lib/x86_64-linux-gnu/liblua5.1.a:lapi.o:0000000000000900 T lua_objlen

it seems like lua_objlen is no longer in Lua 5.2, but instead it's called luaV_objlen now.

Luabind has a few lua_objlen calls but those are ifdefed on < 5.2 (ref).

Would you be so kind and add the following three lines to the CMakeLists.txt file

message(STATUS ">>> " ${LUA_LIBRARIES})
message(STATUS ">>> " ${LUA_INCLUDE_DIR})
message(STATUS ">>> " ${USED_LUA_LIBRARIES})

remove your build directory and re-run CMake?

@Dentro
Copy link
Author

Dentro commented Jan 24, 2016

cmake .. -DCMAKE_BUILD_TYPE=Release -DLUAJIT_INCLUDE_DIR=/usr/local/share/luajit-2.0.3 -DLUAJIT_LIBRARIES=/usr/lib/ -DLUABIND_LIBRARY=/usr/lib/libluabind.so.0.9.1
-- The C compiler identification is GNU 5.3.1
-- The CXX compiler identification is GNU 5.3.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
-- Building on a 64 bit system
-- Configuring OSRM in release mode
-- Performing Test LTO_AVAILABLE
-- Performing Test LTO_AVAILABLE - Success
-- Performing Test LTO_WORKS
-- Performing Test LTO_WORKS - Success
-- LTO working
-- Using gcc specific binutils for LTO.
-- Performing Test HAS_COLOR_FLAG
-- Performing Test HAS_COLOR_FLAG - Success
-- Setting linker optimizations
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Looking for include file pthread.h
-- Looking for include file 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 EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.1.0")
-- Found BZip2: /usr/lib/x86_64-linux-gnu/libbz2.so (found version "1.0.6")
-- Looking for BZ2_bzCompressInit in /usr/lib/x86_64-linux-gnu/libbz2.so
-- Looking for BZ2_bzCompressInit in /usr/lib/x86_64-linux-gnu/libbz2.so - found
-- Found Osmium: /home/adamus/Desktop/aplikacje/osrm-backend/third_party/libosmium/include
-- Boost version: 1.60.0
-- Found the following Boost libraries:
-- date_time
-- filesystem
-- iostreams
-- program_options
-- regex
-- system
-- thread
-- unit_test_framework
-- Found Intel TBB
-- Looking for Luabind...
-- Found Luabind: /usr/lib/libluabind.so.0.9.1
-- Found Luabind: /usr/lib/libluabind.so.0.9.1
-- Found Lua52: /usr/lib/x86_64-linux-gnu/liblua5.2.so;/usr/lib/x86_64-linux-gnu/libm.so
-- Looking for LuaJIT 5.2
-- Found LUAJIT: /usr/lib/
-- Found LuaJIT: LUAJIT_LIBRARY-NOTFOUND
-- Performing Test LUABIND_WORKS
-- Performing Test LUABIND_WORKS - Success
-- Luabind/Lua5.2 combination working with /usr/lib/x86_64-linux-gnu/liblua5.2.so
-- Looking for STXXL...
-- Found STXXL: /usr/lib/libstxxl.so
-- Found STXXL: /usr/lib/libstxxl.so
-- OpenMP support found. Linking just in case for stxxl
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.9.1")
-- >>> /usr/lib/x86_64-linux-gnu/liblua5.2.so/usr/lib/x86_64-linux-gnu/libm.so
-- >>> /usr/include/lua5.2
-- >>> /usr/lib/x86_64-linux-gnu/liblua5.2.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/adamus/Desktop/aplikacje/osrm-backend/build

@Dentro
Copy link
Author

Dentro commented Jan 24, 2016

How to install (LUAJIT_LIBRARY)?

@TheMarex
Copy link
Member

@Dentro you don't need it, it will work withou LuaJIT (it is a replacement for the normal lua runtime).

@Dentro
Copy link
Author

Dentro commented Jan 25, 2016

Lua, LauJIT reinstall and Build cmake?
The problem isn't solved...

@daniel-j-h
Copy link
Member

Yeah my initial suspicion that somehow your CMake setup uses both Lua 5.1 and Lua 5.2 seem to be not the case. CMake clearly prints the include path and library for Lua 5.2.

Unfortunately I don't have Ubuntu 15.10 here to investigate myself right now, but I will try to reproduce this on a live CD during the next days.

Could you post the following file's content

build/CMakeFiles/osrm-extract.dir/link.txt

showing which libraries CMake links in for osrm-extract.

@Dentro
Copy link
Author

Dentro commented Jan 25, 2016

I reinstall libluabind-dev , lua, luajit
sudo cmake .. -DCMAKE_BUILD_TYPE=Release -DLUAJIT_INCLUDE_DIR=/usr/local/share/luajit-2.0.4 -DLUAJIT_LIBRARIES=/usr/lib/ -DLUABIND_LIBRARY=/usr/lib/libluabind.so
-- The C compiler identification is GNU 5.3.1
-- The CXX compiler identification is GNU 5.3.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
-- Building on a 64 bit system
-- Configuring OSRM in release mode
-- Performing Test LTO_AVAILABLE
-- Performing Test LTO_AVAILABLE - Success
-- Performing Test LTO_WORKS
-- Performing Test LTO_WORKS - Success
-- LTO working
-- Using gcc specific binutils for LTO.
-- Performing Test HAS_COLOR_FLAG
-- Performing Test HAS_COLOR_FLAG - Success
-- Setting linker optimizations
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Looking for include file pthread.h
-- Looking for include file 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 EXPAT: /usr/lib/x86_64-linux-gnu/libexpat.so (found version "2.1.0")
-- Found BZip2: /usr/lib/x86_64-linux-gnu/libbz2.so (found version "1.0.6")
-- Looking for BZ2_bzCompressInit in /usr/lib/x86_64-linux-gnu/libbz2.so
-- Looking for BZ2_bzCompressInit in /usr/lib/x86_64-linux-gnu/libbz2.so - found
-- Found Osmium: /home/adamus/Desktop/aplikacje/osrm-backend/third_party/libosmium/include
-- Boost version: 1.60.0
-- Found the following Boost libraries:
-- date_time
-- filesystem
-- iostreams
-- program_options
-- regex
-- system
-- thread
-- unit_test_framework
-- Found Intel TBB
-- Looking for Luabind...
-- Found Luabind: /usr/lib/libluabind.so
-- Found Luabind: /usr/lib/libluabind.so
-- Found Lua52: /usr/lib/x86_64-linux-gnu/liblua5.2.so;/usr/lib/x86_64-linux-gnu/libm.so
-- Looking for LuaJIT 5.2
-- Found LUAJIT: /usr/lib/
-- Found LuaJIT: LUAJIT_LIBRARY-NOTFOUND
-- Performing Test LUABIND_WORKS
-- Performing Test LUABIND_WORKS - Success
-- Luabind/Lua5.2 combination working with /usr/lib/x86_64-linux-gnu/liblua5.2.so
-- Looking for STXXL...
-- Found STXXL: /usr/lib/libstxxl.so
-- Found STXXL: /usr/lib/libstxxl.so
-- OpenMP support found. Linking just in case for stxxl
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.9.1")
-- >>> /usr/lib/x86_64-linux-gnu/liblua5.2.so/usr/lib/x86_64-linux-gnu/libm.so
-- >>> /usr/local/include
-- >>> /usr/lib/x86_64-linux-gnu/liblua5.2.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/adamus/Desktop/aplikacje/osrm-backend/build

build/CMakeFiles/osrm-extract.dir/link.txt:
/usr/bin/c++ -flto=8 -Wall -Wextra -pedantic -Wuninitialized -Wunreachable-code -Wstrict-overflow=1 -D_FORTIFY_SOURCE=2 -fdiagnostics-color=auto -fPIC -ffunction-sections -fdata-sections -std=c++11 -fopenmp -O3 -DNDEBUG -Wl,--gc-sections -Wl,-O1 -Wl,--hash-style=gnu -Wl,--sort-common CMakeFiles/osrm-extract.dir/src/tools/extract.cpp.o -o osrm-extract -rdynamic libosrm_extract.a /usr/local/lib/libboost_date_time.so /usr/local/lib/libboost_filesystem.so /usr/local/lib/libboost_iostreams.so /usr/local/lib/libboost_program_options.so /usr/local/lib/libboost_regex.so /usr/local/lib/libboost_system.so /usr/local/lib/libboost_thread.so /usr/local/lib/libboost_unit_test_framework.so -lpthread -lbz2 -lpthread -lexpat -lluabind -llua5.2 -lz -lstxxl -ltbb -ltbbmalloc -lbz2 -lpthread -lexpat -lluabind -llua5.2 -lz -lstxxl -ltbb -ltbbmalloc /usr/local/lib/libboost_date_time.so /usr/local/lib/libboost_filesystem.so /usr/local/lib/libboost_iostreams.so /usr/local/lib/libboost_program_options.so /usr/local/lib/libboost_regex.so /usr/local/lib/libboost_system.so /usr/local/lib/libboost_thread.so /usr/local/lib/libboost_unit_test_framework.so -lpthread -Wl,-rpath,/usr/local/lib:

@Dentro
Copy link
Author

Dentro commented Jan 25, 2016

What more can I do?

@danpat
Copy link
Member

danpat commented Jan 25, 2016

@daniel-j-h this looks like it might be a bug in the Ubuntu luabind packaging -> the installed luabind seems to have been compiled against Lua5.1 symbols.

@Dentro If my hunch is correct, you have two options:

  1. Remove Lua5.2 packages and install Lua5.1 instead.
  2. Remove the system packaged luabind and build your own copy from source and install in /usr/local/lib.

I would suggest trying option 1 first.

@daniel-j-h
Copy link
Member

@danpat could indeed be the case. But then again we had people already building on Ubuntu 15.10 without those issues.

If you go for option two, that is building luabind from source, make sure to grab the fork here with patches so that it compiles with the latest Boost release: https://github.com/mapbox/luabind

You don't even have to uninstall the system's luabind, just clone that repo and so

mkdir build
pushd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo make install

This installs libluabind into /usr/local/{include,lib}, which then should be picked up by osrm's CMakelists.

Do a final ldd /usr/local/libluabind.so then, and check against which Lua version it is linked.

@Dentro
Copy link
Author

Dentro commented Jan 26, 2016

I Remove Lua5.2 packages , install Lua5.1 and https://github.com/mapbox/luabind
Not found /usr/local/libluabind.so

@daniel-j-h
Copy link
Member

Then you forgot to issue the sudo make install target when compiling libluabind. Or you changed the install prefix. Do it like the following, to get libluabind installed at /usr/local/libluabind.so:

git clone https://github.com/mapbox/luabind.git
cd luabind
mkdir build
pushd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo make install

@Dentro
Copy link
Author

Dentro commented Jan 30, 2016

I reinstall the system, after installing this https://github.com/Project-OSRM/osrm-backend/wiki/Building-on-Ubuntu - the installation was successful

@Dentro Dentro closed this as completed Jan 30, 2016
@daniel-j-h
Copy link
Member

Just confirmed that our build instructions work on a fresh Ubuntu 15.10 AWS EC2 instance.

I think you accidentally broke your installation by building and linking against the wrong Lua version.

Great to hear it works now!

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

4 participants