CMAKE和交叉编译

时间:2017-06-02 09:15:47

标签: cmake cross-compiling

我必须为我的cmake更改sysroot。我的磁盘上有/ u02 / rootfs。

我创建了toolchain_rootfs文件并将此配置添加到其中:

SET(CMAKE_INSTALL_PREFIX "/u02/rootfs")

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSROOT ${CMAKE_INSTALL_PREFIX})
#set(CMAKE_STAGING_PREFIX /home/devel/stage)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})


set(CMAKE_C_COMPILER "${CMAKE_INSTALL_PREFIX}/usr/bin/gcc")
set(CMAKE_CXX_COMPILER "${CMAKE_INSTALL_PREFIX}/usr/bin/c++")

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)


###
SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib")

之后我用选项运行cmake:

cmake ../myproject/ -DCMAKE_TOOLCHAIN_FILE=/u02/myproject/toolchain_rootfs

得到这样的错误:

------------  /u02/rootfs/usr/lib
------------  /u02/rootfs/usr/lib
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /u02/rootfs/usr/bin/gcc
------------  /u02/rootfs/usr/lib
-- Check for working C compiler: /u02/rootfs/usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/u02/rootfs/usr/bin/gcc" is not able to
  compile a simple test program.

  It fails with the following output:

   Change Dir: /u02/myproject/CMakeFiles/CMakeTmp



  Run Build Command:"/usr/bin/make" "cmTC_0e039/fast"

  /usr/bin/make -f CMakeFiles/cmTC_0e039.dir/build.make
  CMakeFiles/cmTC_0e039.dir/build

  make[1]: Entering directory '/u02/myproject_build/CMakeFiles/CMakeTmp'

  Building C object CMakeFiles/cmTC_0e039.dir/testCCompiler.c.o

  /u02/rootfs/usr/bin/gcc -o
  CMakeFiles/cmTC_0e039.dir/testCCompiler.c.o -c
  /u02/myproject_build/CMakeFiles/CMakeTmp/testCCompiler.c

  /u02/rootfs/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/cc1:
  error while loading shared libraries: libisl.so.10: cannot open shared
  object file: No such file or directory

你能帮我解决一下这个错误。我通过了cmake手册,设置了RPATH,但它对我不起作用。有什么问题?

UDP1:

我尝试使用sysroot,没有工具链,如:

SET(CMAKE_INSTALL_PREFIX "/u02/rootfs")
set(CMAKE_SYSROOT ${CMAKE_INSTALL_PREFIX})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib/x86_64-linux-gnu")

CMAKE已通过,但MAKE失败了。我收到了错误:

/u02/rootfs/usr/bin/ar: error while loading shared libraries: libbfd-2.25-system.so: cannot open shared object file: No such file or directory

rootfs有这个库。

如何在rootfs(sysroot)中为LIB指定PATH?

0 个答案:

没有答案