-- 作者:客人(218.90.*.*)
-- cmake交叉编译错误
使用 ESM6802-toolchain-x86_64-qt5-8.sh 安装编译工具链。使用默认安装目录/opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/
编译目录如下面 cmake-test |-- build |-- CMakeLists.txt |-- cross-compile.txt `-- hello.cpp 使用其他家的交叉编译器没有问题。使用你们家的出现如下编译错误 newrt@newrt-desktop:~/Documents/cmake-test/build$ cmake -DCMAKE_TOOLCHAIN_FILE=../cross-compile.txt .. -- The C compiler identification is GNU 5.3.0 -- The CXX compiler identification is GNU 5.3.0 -- Check for working C compiler: /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-emtronix-linux-gnueabi/arm-emtronix-linux-gnueabi-gcc -- Check for working C compiler: /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-emtronix-linux-gnueabi/arm-emtronix-linux-gnueabi-gcc -- broken CMake Error at /usr/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message): The C compiler "/opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-emtronix-linux-gnueabi/arm-emtronix-linux-gnueabi-gcc" is not able to compile a simple test program. It fails with the following output: Change Dir: /home/newrt/Documents/cmake-test/build/CMakeFiles/CMakeTmp Run Build Command:"/usr/bin/make" "cmTC_167cc/fast" /usr/bin/make -f CMakeFiles/cmTC_167cc.dir/build.make CMakeFiles/cmTC_167cc.dir/build make[1]: ����Ŀ¼��/home/newrt/Documents/cmake-test/build/CMakeFiles/CMakeTmp�� Building C object CMakeFiles/cmTC_167cc.dir/testCCompiler.c.o /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-emtronix-linux-gnueabi/arm-emtronix-linux-gnueabi-gcc -I/opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/cortexa9hf-neon-emtronix-linux-gnueabi/include/c++/5.3.0 -I/opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/cortexa9hf-neon-emtronix-linux-gnueabi/usr/include -o CMakeFiles/cmTC_167cc.dir/testCCompiler.c.o -c /home/newrt/Documents/cmake-test/build/CMakeFiles/CMakeTmp/testCCompiler.c Linking C executable cmTC_167cc /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_167cc.dir/link.txt --verbose=1 /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-emtronix-linux-gnueabi/arm-emtronix-linux-gnueabi-gcc -rdynamic CMakeFiles/cmTC_167cc.dir/testCCompiler.c.o -o cmTC_167cc /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find crt1.o: No such file or directory /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find crti.o: No such file or directory /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find crtbegin.o: No such file or directory /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find -lgcc /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find -lgcc_s /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find -lc /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find -lgcc /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find -lgcc_s /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find crtend.o: No such file or directory /opt/fsl-imx-x11/4.1.15-2.0.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-emtronix-linux-gnueabi/gcc/arm-emtronix-linux-gnueabi/5.3.0/real-ld: cannot find crtn.o: No such file or directory collect2: error: ld returned 1 exit status make[1]: *** [CMakeFiles/cmTC_167cc.dir/build.make:87��cmTC_167cc] ���� 1 make[1]: �뿪Ŀ¼��/home/newrt/Documents/cmake-test/build/CMakeFiles/CMakeTmp�� make: *** [Makefile:121��cmTC_167cc/fast] ���� 2
CMakeLists.txt 内容如下 project(hello) add_executable(hello hello.cpp) cross-compile.txt内容如下
#to set the toolpath variable set(TOOLCHAIN_DIR "/opt/fsl-imx-x11/4.1.15-2.0.1/sysroots") set(TOOLCHAIN_HOST "${TOOLCHAIN_DIR}/x86_64-pokysdk-linux/usr/bin/arm-emtronix-linux-gnueabi/arm-emtronix-linux-gnueabi") set(TOOLCHAIN_INCLUDE "${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi/usr/include" "${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi/usr/include/c++/5.3.0" ) set(TOOLCHAIN_LIB "${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi/lib" "${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi/usr/lib/arm-emtronix-linux-gnueabi/5.3.0/" "${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi/usr/lib" ) set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi) #message("${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE}") set(TOOLCHAIN_CC "${TOOLCHAIN_HOST}-gcc") set(TOOLCHAIN_CXX "${TOOLCHAIN_HOST}-g++")
#to tell cmake it is crosscompileing set(CMAKE_CROSSCOMPILING TRUE) # Define name of the target system set(CMAKE_SYSTEM_NAME "Linux") # define the name of target architecture set(CMAKE_SYSTEM_PROCESSOR arm) # Define the compiler set(CMAKE_C_COMPILER ${TOOLCHAIN_CC}) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_CXX}) #to tell cmake where to search the header or lib files #set(CMAKE_FIND_ROOT_PATH "${TOOLCHAIN_INCLUDE}" "${TOOLCHAIN_LIB}") include_directories ( ${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi/include/c++/5.3.0 ${TOOLCHAIN_DIR}/cortexa9hf-neon-emtronix-linux-gnueabi/usr/include ) set(CMAKE_INCLUDE_PATH ${TOOLCHAIN_INCLUDE} ) set(CMAKE_LIBRARY_PATH ${TOOLCHAIN_LIB} ) # search for programs in the build host directories set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) #set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 希望你们支持一下谢谢
|