【发布时间】:2017-04-24 11:10:39
【问题描述】:
我尝试为 BeagleBoard Black 交叉编译 Azure IoT C SDK (https://github.com/azure/azure-iot-sdk-c)。
我确实设置了 Debian GNU/Linux 8.7 (jessie) 机器并安装了如下所述的工具链:http://exploringbeaglebone.com/chapter7/。
然后我按照这里的步骤操作: https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/SDK_cross_compile_example.md 并创建了一个工具链文件:
INCLUDE(CMakeForceCompiler)
SET(CMAKE_SYSTEM_NAME Linux) # this one is important
SET(CMAKE_SYSTEM_VERSION 1) # this one not so much
# this is the location of the amd64 toolchain targeting the Raspberry Pi
SET(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_FIND_ROOT_PATH /usr/lib/arm-linux-gnueabihf)
# 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)
我使用以下命令调用 azure-sdk 的 Buildscript:
./build.sh --toolchain-file toolchain-bb.cmake -cl --sysroot=/usr/lib/arm-linux-gnueabihf
出现以下错误
CMake Error at /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.0/Modules/FindOpenSSL.cmake:328 (find_package_handle_standard_args)
c-utility/CMakeLists.txt:141 (find_package)
我尝试使用以下方法安装 openssl:
sudo apt-get install openssl:armhf
但错误仍然存在,如果我为 arm64 构建源代码(仅使用 azure-iot-sdk 的 build.sh 文件)一切正常。
如果我克隆 openssl 并针对 arm 构建它,我会收到以下错误:
CMake Error at /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found
version "1.1.1")
【问题讨论】:
-
交叉编译时,不会在host目录下搜索库。这正是
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)的含义(参见docs)。apt-get适用于 host 包。 -
@Tsyvarev 如果我克隆 openssl 并为 arm 构建它,我得到另一个错误,我编辑了问题
-
您需要在 sysroot 下安装 OpenSSL,并可能向 CMake 提示其位置(可能建议 OPENSSL_ROOT_DIR 会有所帮助)。
-
如果我将目录添加到 cmake 调用 -DOPENSSSL_ROOT_DIR 错误仍然存在。 sysroot下是什么意思
-
“在 sysroot 下安装”是指安装的文件应该在您设置为 sysroot (
/usr/lib/arm-linux-gnueabihf) 的目录下。使用给定的工具链,您不能要求 CMake 搜索此目录之外的库。我只是注意到,当您为“targeting arm”构建 openssl 时,CMake 找到了它的标头,但仍然缺少库。标题的位置是什么? (检查 CMake 缓存中 OPENSSL_INCLUDE_DIR 的值,CMakeCache.txt)。 openssl 库安装在哪里(哪个目录)?
标签: cmake debian cross-compiling beagleboard