交叉编译azure iot sdk

时间:2017-04-24 11:10:39

标签: cmake debian cross-compiling beagleboard

我尝试为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")

1 个答案:

答案 0 :(得分:0)

如果您的工具链中存在Openssl,那么您只需要在cmake工具链文件中添加几行。这将有助于cmake找到您的库和标题。像这样:

SET(OPENSSL_ROOT_DIR /path/to/openssl/lib) SET(OPENSSL_INCLUDE_DIR /path/to/openssl/include/)

如果它不存在,那么您需要为目标交叉编译openssl并将其安装到您的工具链中。通常分为/<sysroot>/usr/lib/<sysroot>/usr/include

或者,如果openssl在您的设备上但不在您的工具链中,那么您只需从设备中复制它即可。这里有一个将依赖项复制到Raspberry Pi演示中的工具链的示例:https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/SDK_cross_compile_example.md