Cross compiling Hello World for Raspberry Pi fails

880 views
Skip to first unread message

Tomi P. Maila

unread,
Aug 23, 2018, 1:09:41 PM8/23/18
to actor-framework
Hey,

I am new to C++ Actor Framework and to the forum. Thanks for accepting me to the group. I am trying to use CAF for an embedded project. My dev environment is Ubuntu 18.04 and I am targeting Raspberry Pi. I compiled the Actor Framework itself on Raspberry Pi without problems. However I want to do the actual development on my Ubuntu laptop and hence trying to cross compile a CAF app for Raspberry Pi. I have installed on Ubuntu the cross compiler with the following command.

sudo apt-get install g++-arm-linux-gnueabihf

I have copied the content of the Raspberry Pi root into a folder that I use as a sysroot for the compiling. All steps of compiling succeed but the link step fails for an undefined reference to a glibc function.

cd /home/tomi/projects/embedded-controller/cmake-build-arm/src/hellocaf && /usr/bin/cmake -E cmake_link_script CMakeFiles/hellocaf.dir/link.txt --verbose=1
/usr/bin/arm-linux-gnueabihf-g++ --sysroot=/home/tomi/x-compile/sysroot     CMakeFiles/hellocaf.dir/src/main.cpp.o  -o hellocaf -Wl,-rpath,/usr/local/lib /home/tomi/x-compile/sysroot/usr/local/lib/libcaf_core.so 
/home/tomi/x-compile/sysroot/lib/arm-linux-gnueabihf/libpthread.so.0: undefined reference to `__libc_dl_error_tsd@GLIBC_PRIVATE'
collect2: error: ld returned 1 exit status


On the Ubuntu host I have a GCC cross compile tools version 7.3.0 and on Raspberry Pi the GCC toolchain is of version 6.3.0. Further glibc version on the host is (Ubuntu GLIBC 2.27-3ubuntu1) 2.27 and on target (Debian GLIBC 2.24-11+deb9u3) 2.24. I am initially thinking that the linker error is because of the version difference between glibc version. I tried to reconfigure the CMake implicit link and include folders to override the default ones 

SET(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${CMAKE_SYSROOT}/usr/lib/gcc/arm-linux-gnueabihf/6;${CMAKE_SYSROOT}/usr/lib/arm-linux-gnueabihf;${CMAKE_SYSROOT}/usr/lib;${CMAKE_SYSROOT}/lib/arm-linux-gnueabihf")
SET(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: "${CMAKE_SYSROOT}/usr/include")


but these don't seem to have an effect and they don't seem to override the implicit folders that remain to have the values below:

-- CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES: /usr/lib/gcc-cross/arm-linux-gnueabihf/7;/usr/arm-linux-gnueabihf/lib;/home/tomi/x-compile/sysroot/lib/arm-linux-gnueabihf;/home/tomi/x-compile/sysroot/lib;/home/tomi/x-compile/sysroot/usr/lib/arm-linux-gnueabihf;/home/tomi/x-compile/sysroot/usr/lib
-- CMAKE_CXX_IMPLICIT_LINK_LIBRARIES: stdc++;m;gcc_s;gcc;c;gcc_s;gcc
-- CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: /usr/include


That is the CMake still uses the link library folders relative to the gcc cross compiler instead of the ones on my target system sysroot alone.

Has anyone successfully set up a cross compilation environment for CAF? Any ideas what to try next? Do I need to compile a custom cross compile toolchain that matches with the GCC and glibc versions on the target? Or is this an issue that has nothing to do with the version disparity?

Tomi


Tomi P. Maila

unread,
Aug 23, 2018, 1:51:39 PM8/23/18
to actor-framework
Solved. I feel so dum. Just adding -lpthread to the target link libraries.

target_link_libraries(${PROJECT_NAME} ${CAF_LIBRARIES} pthread)

Tomi

Dominik Charousset

unread,
Aug 24, 2018, 4:35:30 AM8/24/18
to actor-f...@googlegroups.com
Solved. I feel so dum. Just adding -lpthread to the target link libraries.

target_link_libraries(${PROJECT_NAME} ${CAF_LIBRARIES} pthread)


Happens to all of us. :)

Welcome aboard and I hope you find CAF useful for your project.

    Dominik
Reply all
Reply to author
Forward
0 new messages