Question

I've successfully compiled boost using the cross compiler (used the instructions from Installing Raspberry Pi Cross-Compiler) and it worked just fine.

I moved the lib and the include into the rootfs so that cmake finds it... and when I run cmake, I get

gervasio@ubuntu:~/cpp-netlib-0.10.1$ cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.55.0
-- Found the following Boost libraries:
--   unit_test_framework
--   system
--   regex
--   date_time
--   thread
--   filesystem
--   program_options
--   chrono
-- Found OpenSSL: /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so;/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so (found version "1..1")
-- Looking for include files CMAKE_HAVE_PTHREAD_H
-- Looking for include files CMAKE_HAVE_PTHREAD_H - 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 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gervasio/cpp-netlib-0.10.1

which is awesome... now, when I run make, it ends with

gervasio@ubuntu:~/cpp-netlib-0.10.1$ make

...

[ 15%] Building CXX object libs/network/test/CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o
cd /home/gervasio/cpp-netlib-0.10.1/libs/network/test && /home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++   -DBOOST_NETWORK_ENABLE_HTTPS -Wall -I/home/gervasio/raspberrypi/rootfs/usr/include -I/home/gervasio/cpp-netlib-0.10.1    -Wall -o CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o -c /home/gervasio/cpp-netlib-0.10.1/libs/network/test/message_test.cpp
Linking CXX executable ../../../tests/cpp-netlib-message_test
cd /home/gervasio/cpp-netlib-0.10.1/libs/network/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/cpp-netlib-message_test.dir/link.txt --verbose=1
/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++    -Wall    CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o  -o ../../../tests/cpp-netlib-message_test -rdynamic /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_unit_test_framework.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_system.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_regex.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_date_time.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_thread.a -lpthread /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_filesystem.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_program_options.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_chrono.a -lpthread ../src/libcppnetlib-uri.a /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so -lrt -Wl,-rpath,/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf 
/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libz.so.1, needed by /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so, not found (try using -rpath or -rpath-link)
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `deflateInit_'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `deflate'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `deflateEnd'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `inflate'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `inflateInit_'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `inflateEnd'
/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so: undefined reference to `zError'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/cpp-netlib-message_test] Error 1
make[2]: Leaving directory `/home/gervasio/cpp-netlib-0.10.1'
make[1]: *** [libs/network/test/CMakeFiles/cpp-netlib-message_test.dir/all] Error 2
make[1]: Leaving directory `/home/gervasio/cpp-netlib-0.10.1'
make: *** [all] Error 2

but... inside ~/raspberrypi/rootfs/lib/arm-linux-gnueabihf there's a libz.so.1

gervasio@ubuntu:~/raspberrypi/rootfs/lib/arm-linux-gnueabihf$ ls -lah libz.so*
lrwxrwxrwx 1 gervasio gervasio  13 Jun 24  2012 libz.so.1 -> libz.so.1.2.7
-rw-r--r-- 1 gervasio gervasio 86K Jun 24  2012 libz.so.1.2.7

I know it's failing just on the test, and that I can use the libraries... but I'd really like to have a good environment to cross compile whatever I need.

Thanks for your help :)

edit: just ran ldd libssl.so on the raspberry and got

/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so (0xb6ec6000)
libcrypto.so.1.0.0 => /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0 (0xb6d57000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6d4c000)
libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0xb6d2e000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6bff000)
/lib/ld-linux-armhf.so.3 (0xb6f24000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6bd7000)

edit 2: If I run cmake with -DCMAKE_SKIP_BUILD_RPATH=FALSE -DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE -DCMAKE_INSTALL_RPATH=/home/gervasio/raspberrypi/rootfs/lib/arm-linux-gnueabihf -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE I get this output

/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++    -Wall    CMakeFiles/cpp-netlib-message_test.dir/message_test.cpp.o  -o ../../../tests/cpp-netlib-message_test -rdynamic /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_unit_test_framework.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_system.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_regex.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_date_time.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_thread.a -lpthread /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_filesystem.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_program_options.a /home/gervasio/raspberrypi/rootfs/usr/lib/libboost_chrono.a -lpthread ../src/libcppnetlib-uri.a /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so -lrt -Wl,-rpath,/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf 
/home/gervasio/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libz.so.1, needed by /home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so, not found (try using -rpath or -rpath-link)

where it says -rpath,/home/gervasio/raspberrypi/rootfs/usr/lib/arm-linux-gnueabihf that doesn't seem ok, right?

Était-ce utile?

La solution

Thanks to @ruslo and that link he posted, I figured it out... this is the way to tell cmake to use rpath

cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/raspberrypi/pi.cmake -DCMAKE_SKIP_BUILD_RPATH=FALSE -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE -DCMAKE_INSTALL_RPATH=/home/gervasio/raspberrypi/rootfs/lib/arm-linux-gnueabihf -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE .

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top