Hello,
I am trying to set-up cross compile environment, so I can pre-build various libraries for xavier nx (target system) on more powerful host system - Ubuntu 18.04 x86_64. So I can create my own system image with pre-installed libraries which I need etc.
I am testing it with ArUco library, which is not heavily dependent on other libraries and is quite small project.
I added toolchain.cmake
file into cmake
dir inside aruco folder:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_SYSROOT /home/edo/rootfs-xavier)
set(tools /home/edo/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu)
set(CMAKE_C_COMPILER ${tools}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
Then, I create build
folder, where I all cmake like this:
cmake -DCMAKE_TOOLCHAIN_FILE:PATH="../cmake/toolchain.cmake" ..
CMake output:
-- The CXX compiler identification is GNU 7.3.1
-- Check for working CXX compiler: /home/edo/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
-- Check for working CXX compiler: /home/edo/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /home/edo/rootfs-xavier/usr (found version "4.1.1")
-- OpenCV found, version: 4.1.1 in dir /home/edo/rootfs-xavier/usr/include/opencv4
-- GLUT_glut_LIBRARY=GLUT_glut_LIBRARY-NOTFOUND
--
-- -------------------------------------------------------------------------------
-- General configuration for aruco 3.1.12
-- -------------------------------------------------------------------------------
--
-- Compiler:/home/edo/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
-- C++ flags (Release): -O3 -g0 -DNDEBUG
-- C++ flags (Debug): -O0 -g3 -DDEBUG -D_DEBUG -DPRINT_DEBUG_MESSAGES
-- CMAKE_CXX_FLAGS:
-- CMAKE_BINARY_DIR: /home/edo/rootfs-xavier/home/aruco-3.1.12/build
--
-- TARGET_PROCESSOR = aarch64
-- BUILD_SHARED_LIBS = ON
-- CMAKE_INSTALL_PREFIX = /usr/local
-- CMAKE_BUILD_TYPE = Debug
--
-- BUILD_SVM =
-- BUILD_UTILS = ON
-- BUILD_TESTS =
-- BUILD_GLSAMPLES = OFF
-- USE_OWN_EIGEN3=ON
-- OpenCV_DIR=/home/edo/rootfs-xavier/usr/lib/aarch64-linux-gnu/cmake/opencv4
--
-- --------------------------- Documentation -----------------------------
--
-- INSTALL_DOC = OFF
-- USE_LATEX =
-- USE_DOT =
-- USE_CHM =
--
-- FOUND OPENGL=NO LIBS=
-- OpenCV_LIB_DIR= OpenCV_INCLUDE_DIRS=/home/edo/rootfs-xavier/usr/include/opencv4
-- CMAKE_INSTALL_PREFIX=/home/edo/rootfs-xavier/home/aruco-3.1.12/build
-- EIGEN3_INCLUDE_DIR=3rdparty/eigen3
-- USE_TIMERS=OFF
--
--
-- Change a value with: cmake -D<Variable>=<Value>
--
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_TOOLCHAIN_FILE
-- Build files have been written to: /home/edo/rootfs-xavier/home/aruco-3.1.12/build
So, the output looks all right, it seems, that toolchain is properly set and found.
Then I run make -j8
:
Scanning dependencies of target aruco
[ 1%] Building CXX object src/CMakeFiles/aruco.dir/cameraparameters.cpp.o
[ 5%] Building CXX object src/CMakeFiles/aruco.dir/debug.cpp.o
[ 5%] Building CXX object src/CMakeFiles/aruco.dir/dictionary.cpp.o
[ 6%] Building CXX object src/CMakeFiles/aruco.dir/ippe.cpp.o
[ 8%] Building CXX object src/CMakeFiles/aruco.dir/markerdetector.cpp.o
[ 10%] Building CXX object src/CMakeFiles/aruco.dir/markerlabeler.cpp.o
[ 11%] Building CXX object src/CMakeFiles/aruco.dir/posetracker.cpp.o
[ 13%] Building CXX object src/CMakeFiles/aruco.dir/cvdrawingutils.cpp.o
[ 15%] Building CXX object src/CMakeFiles/aruco.dir/dictionary_based.cpp.o
[ 16%] Building CXX object src/CMakeFiles/aruco.dir/marker.cpp.o
[ 18%] Building CXX object src/CMakeFiles/aruco.dir/markerdetector_impl.cpp.o
[ 20%] Building CXX object src/CMakeFiles/aruco.dir/markermap.cpp.o
[ 21%] Building CXX object src/CMakeFiles/aruco.dir/fractaldetector.cpp.o
[ 23%] Building CXX object src/CMakeFiles/aruco.dir/fractallabelers/fractalposetracker.cpp.o
[ 25%] Building CXX object src/CMakeFiles/aruco.dir/fractallabelers/fractalmarkerset.cpp.o
[ 26%] Building CXX object src/CMakeFiles/aruco.dir/fractallabelers/fractalmarker.cpp.o
[ 28%] Building CXX object src/CMakeFiles/aruco.dir/fractallabelers/fractallabeler.cpp.o
[ 30%] Building CXX object src/CMakeFiles/aruco.dir/dcf/dcfmarkermaptracker.cpp.o
[ 31%] Building CXX object src/CMakeFiles/aruco.dir/dcf/dcfmarkertracker.cpp.o
[ 33%] Building CXX object src/CMakeFiles/aruco.dir/dcf/dcf_utils.cpp.o
[ 35%] Building CXX object src/CMakeFiles/aruco.dir/dcf/trackerimpl.cpp.o
[ 36%] Linking CXX shared library libaruco.so
/home/edo/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/../../../../aarch64-linux-gnu/bin/ld: /home/edo/rootfs-xavier/usr/lib/aarch64-linux-gnu/libm.a(e_atan2.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against external symbol `__stack_chk_guard@@GLIBC_2.17' can not be used when making a shared object; recompile with -fPIC
/home/edo/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/../../../../aarch64-linux-gnu/bin/ld: /home/edo/rootfs-xavier/usr/lib/aarch64-linux-gnu/libm.a(e_atan2.o)(.text+0x18): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17'
/home/edo/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/../../../../aarch64-linux-gnu/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
src/CMakeFiles/aruco.dir/build.make:619: recipe for target 'src/libaruco.so.3.1.12' failed
make[2]: *** [src/libaruco.so.3.1.12] Error 1
CMakeFiles/Makefile2:117: recipe for target 'src/CMakeFiles/aruco.dir/all' failed
make[1]: *** [src/CMakeFiles/aruco.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
It seems, that build itself is working, but then the linking process fails. I also tried setting set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
- then -fPIC
flag is also present in cmake
output, but the result is the same.
Can anybody please help with this?
Thank you very much!