参考文献:
[1] https://medium.com/@tahsincankose/cross-compiling-ros-project-for-arm-263642b405ac
宿主机平台:虚拟机ubuntu16.04LTS系统
目标运行平台:树莓派4B
目标平台系统:Raspbian Buster with desktop and recommended software
采用的方法:
`set(libraries "cv_bridge;/usr/local/lib/libopencv_core.so.3.4.3;/usr/local/lib/libopencv_imgproc.so.3.4.3;/usr/local/lib/libopencv_imgcodecs.so.3.4.3")`
可以看到,其连接的共享库都指向本地目录这都是PC环境下运行的共享库,我们需要替换其中的内容;
4. 修改kinect下所有文件中跟PC环境库和头文件相关的位置到从树莓派4b拷贝过来的目录对应位置:其中(以下指令均在kinect目录下执行)
find . -type f | xargs sed -i 's#/opt/ros/kinetic#${CMAKE_CROSS_COMPILE_PREFIX}#g'
find . -type f | xargs sed -i 's#/usr/lib#${CMAKE_CROSS_COMPILE_PREFIX}/usr/lib#g'
`
find . -type f | xargs sed -i 's#/usr/local/lib#${CMAKE_CROSS_COMPILE_PREFIX}/usr/local/lib#g'
find . -type f | xargs sed -i 's#/usr/local/include#${CMAKE_CROSS_COMPILE_PREFIX}/usr/local/include#g'
find . -type f | xargs sed -i 's#/usr/include#${CMAKE_CROSS_COMPILE_PREFIX}/usr/include#g'
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
SET(RASPBERRY_ROOT_PATH /home/liqiang/work/linux/raspberrypi/lib)
SET(RASPBERRY_KINETIC_PATH ${RASPBERRY_ROOT_PATH}/opt/ros/kinetic)
SET(CMAKE_FIND_ROOT_PATH ${RASPBERRY_ROOT_PATH} ${CATKIN_DEVEL_PREFIX})
SET(CMAKE_PREFIX_PATH ${RASPBERRY_KINETIC_PATH} ${RASPBERRY_ROOT_PATH}/usr)
# Have to set this one to BOTH, to allow CMake to find rospack
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH}" CACHE INTERNAL "" FORCE)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH}" CACHE INTERNAL "" FORCE)
#SET(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH}" CACHE INTERNAL "" FORCE)
#SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH}" CACHE INTERNAL "" FORCE)
SET(LD_LIBRARY_PATH ${RASPBERRY_KINETIC_PATH}/lib)
include_directories(/home/liqiang/work/linux/raspberrypi/lib/usr/include/arm-linux-gnueabihf)
set(CMAKE_CROSS_COMPILE_PREFIX /home/liqiang/work/linux/raspberrypi/lib)
LINK_DIRECTORIES(${CMAKE_CROSS_COMPILE_PREFIX}/lib/arm-linux-gnueabihf)
catkin_make -DCMAKE_TOOLCHAIN_FILE=/home/liqiang/work/mobileRobot/rostoolchain.cmake
备注:得到这样的结果已经奋战了好几天了,离成功不远了。
解决试探:
可以看到库有问题,但究竟谁的库有问题了(交叉编译器的自带的库还是从目标机器拷贝的库),标准c:库交叉编译器自带的为libc-2.13.so,而树莓派的库为libc-2.28.so,标准C++库:通过执行以下指令:
readelf -a libstdc++.so | grep 3.4
比较得知,交叉编译器的c++库只支持到GLIBCXX_3.4.19,而树莓派系统自带的库支持到GLIBCXX_3.4.25,故编译器的库版本较低。从编译错误看出,需要支持到GLIBCXX_3.4.21。
决定用树莓派的库替换交叉编译器的库,结果是连编译都无法完成了,不是连接错误。
看来需要更高版本的交叉编译器了,查看编译器的版本:
arm-linux-gnueabihf-gcc -v
树莓派:gcc version 8.3.0 (Raspbian 8.3.0-6+rpi1)
交叉编译器: gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03)
可以看出,交叉编译器的版本很低,进而需要寻找更高版本的交叉编译器,在错误编译结果之后给出寻找正确交叉编译器的过程:
错误编译结果:
[ 66%] Building CXX object robot_base/bin/CMakeFiles/robot_base.dir/src/Communication.cpp.o
[ 66%] Building CXX object robot_base/bin/CMakeFiles/robot_base.dir/src/main.cpp.o
[100%] Linking CXX executable robot_base
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libcrypt.so.1: undefined reference to `__open_nocancel@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `VTT for std::__cxx11::basic_stringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_replace_aux(unsigned int, unsigned int, unsigned int, wchar_t)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_mutate(unsigned int, unsigned int, char const*, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::find(char const*, unsigned int, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_assign(std::__cxx11::basic_string, std::allocator > const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::rfind(char, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::find(char, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `bool std::has_facet >(std::locale const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_append(char const*, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `VTT for std::__cxx11::basic_stringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `bool std::has_facet >(std::locale const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_append(wchar_t const*, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::basic_string(std::__cxx11::basic_string, std::allocator >&&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libuuid.so.1: undefined reference to `fcntl64@GLIBC_2.28'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::__cxx11::basic_ostringstream, std::allocator >::basic_ostringstream(std::_Ios_Openmode)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_stringbuf, std::allocator >::_M_sync(wchar_t*, unsigned int, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libcrypt.so.1: undefined reference to `__read_nocancel@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::reserve(unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::rfind(char const*, unsigned int, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::runtime_error::runtime_error(char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__close_nocancel@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libapr-1.so.0: undefined reference to `__fdelt_chk@GLIBC_2.15'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_filesystem.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_replace(unsigned int, unsigned int, wchar_t const*, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `vtable for std::__cxx11::basic_ostringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/librosconsole.so: undefined reference to `std::logic_error::logic_error(char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::runtime_error::runtime_error(std::__cxx11::basic_string, std::allocator > const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `typeinfo for std::ios_base::failure[abi:cxx11]@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `operator delete(void*, unsigned int)@CXXABI_1.3.9'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_create(unsigned int&, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `std::__cxx11::numpunct const& std::use_facet >(std::locale const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::resize(unsigned int, char)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__recv@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_erase(unsigned int, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::invalid_argument::invalid_argument(char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::operator=(std::__cxx11::basic_string, std::allocator >&&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libdl.so.2: undefined reference to `_dl_catch_error@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::out_of_range::out_of_range(std::__cxx11::basic_string, std::allocator > const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__shm_directory@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_filesystem.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::find_last_of(char const*, unsigned int, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__pthread_barrier_wait@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_replace_aux(unsigned int, unsigned int, unsigned int, char)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_replace(unsigned int, unsigned int, char const*, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::compare(std::__cxx11::basic_string, std::allocator > const&) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_stringbuf, std::allocator >::_M_sync(char*, unsigned int, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_stringstream, std::allocator >::~basic_stringstream()@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::runtime_error::runtime_error(char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::find_first_of(char const*, unsigned int, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_construct(unsigned int, char)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libroscpp.so: undefined reference to `fcntl@GLIBC_2.28'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::compare(unsigned int, unsigned int, std::__cxx11::basic_string, std::allocator > const&) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::assign(char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::logic_error::logic_error(std::logic_error const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_filesystem.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__pthread_get_minstack@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `vtable for std::__cxx11::basic_stringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::overflow_error::overflow_error(char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::compare(std::__cxx11::basic_string, std::allocator > const&) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `vtable for std::__cxx11::basic_stringbuf, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libdl.so.2: undefined reference to `_dl_signal_error@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::collate const& std::use_facet >(std::locale const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_construct(unsigned int, wchar_t)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::runtime_error::runtime_error(std::runtime_error const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::insert(unsigned int, char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libuuid.so.1: undefined reference to `getrandom@GLIBC_2.25'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_thread.so: undefined reference to `std::basic_istream >& std::getline, std::allocator >(std::basic_istream >&, std::__cxx11::basic_string, std::allocator >&, char)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::append(char const*)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__clock_gettime@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::compare(wchar_t const*) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_filesystem.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::find_first_not_of(char const*, unsigned int, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_stringstream, std::allocator >::basic_stringstream(std::_Ios_Openmode)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libaprutil-1.so.0: undefined reference to `__explicit_bzero_chk@GLIBC_2.25'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_assign(std::__cxx11::basic_string, std::allocator > const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::_M_create(unsigned int&, unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::compare(unsigned int, unsigned int, char const*) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__libc_pread@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_ostringstream, std::allocator >::~basic_ostringstream()@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::out_of_range::out_of_range(std::__cxx11::basic_string, std::allocator > const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf2_ros.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::compare(char const*) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_stringbuf, std::allocator >::str() const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::swap(std::__cxx11::basic_string, std::allocator >&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::compare(unsigned int, unsigned int, std::__cxx11::basic_string, std::allocator > const&, unsigned int, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `VTT for std::__cxx11::basic_ostringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_ostringstream, std::allocator >::~basic_ostringstream()@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `VTT for std::__cxx11::basic_ostringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/libcrypt.so.1: undefined reference to `__snprintf@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__socket@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::collate const& std::use_facet >(std::locale const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::operator=(std::__cxx11::basic_string, std::allocator >&&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/libtf.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::~basic_string()@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::numpunct const& std::use_facet >(std::locale const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::~basic_string()@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `vtable for std::__cxx11::basic_ostringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::messages const& std::use_facet >(std::locale const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::find_last_not_of(char, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/librt.so.1: undefined reference to `__pthread_barrier_init@GLIBC_PRIVATE'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `vtable for std::__cxx11::basic_stringstream, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::reserve(unsigned int)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `std::__cxx11::basic_string, std::allocator >::find_first_not_of(char, unsigned int) const@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/opt/ros/kinetic/lib/librosconsole.so: undefined reference to `std::runtime_error::runtime_error(std::__cxx11::basic_string, std::allocator > const&)@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/lib/arm-linux-gnueabihf/liblog4cxx.so: undefined reference to `vtable for std::__cxx11::basic_stringbuf, std::allocator >@GLIBCXX_3.4.21'
/home/liqiang/work/linux/raspberrypi/lib/usr/local/lib/libboost_regex.so: undefined reference to `std::__cxx11::messages const& std::use_facet >(std::locale const&)@GLIBCXX_3.4.21'
collect2: error: ld returned 1 exit status
robot_base/bin/CMakeFiles/robot_base.dir/build.make:143: recipe for target 'robot_base/bin/robot_base' failed
make[2]: *** [robot_base/bin/robot_base] Error 1
CMakeFiles/Makefile2:2080: recipe for target 'robot_base/bin/CMakeFiles/robot_base.dir/all' failed
make[1]: *** [robot_base/bin/CMakeFiles/robot_base.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
参考文献1,直接在PC端ubuntu上安装交叉编译工具:
sudo apt install gcc-arm-linux-gnueabihf
sudo apt install g++-arm-linux-gnueabihf
经确认,其自带的c库支持到GLIBC_2.23,自带的C++库支持到GLIBCXX_3.4.21,对于上面C++库兼容性问题,此工具链自带的库刚好满足,试着编译ros应用包,结果成功。