交叉编译Azure IOT SDK [英] cross compile azure iot sdk

查看:244
本文介绍了交叉编译Azure IOT SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试交叉编译Azure IoT C SDK( https://github.com / azure / azure-iot-sdk-c )表示BeagleBoard黑色。



我确实设置了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)#这个很重要
SET(CMAKE_SYSTEM_VERSION 1)#这个不是很多

#这是以Raspberry Pi为目标的amd64工具链的位置
SET(CMAKE_C_COMPILER / usr / bin / arm-linux-gnueabihf-gcc)
SET(CMAKE_FIND_ROOT_PATH / usr / lib / arm-linux-gnueabihf)

#在构建主机目录中搜索程序
SET(CMA KE_FIND_ROOT_PATH_MODE_PROGRAM永不)

#用于目标目录中的库和标题
SET(仅CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
SET(仅CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)


我使用以下命令调用azure-sdk的构建脚本:

  ./ build.sh --toolchain-file工具链-bb.cmake -cl --sysroot = / usr / lib / arm-linux-gnueabihf 

以下错误发生

  CMake错误位于/ usr / share / cmake- 3.0 / Modules / FindPackageHandleStandardArgs.cmake:136(消息):
找不到OpenSSL,尝试在
系统变量OPENSSL_ROOT_DIR中设置OpenSSL根文件夹的路径(丢失:OPENSSL_LIBRARIES
OPENSSL_INCLUDE_DIR)
调用堆栈(最近调用一次):
/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_ar gs)
c-utility / CMakeLists.txt:141(find_package)

我试图使用以下命令安装openssl:

  sudo apt-get安装openssl:armhf 

但错误仍然存​​在,如果我为arm64构建源代码(仅使用azure-iot-sdk的build.sh文件),一切正常。



如果我克隆openssl并针对arm进行构建,则会出现以下错误:

  CMake错误,位于/usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:136(消息):
找不到OpenSSL,请尝试在
系统变量中将路径设置为OpenSSL根文件夹OPENSSL_ROOT_DIR(丢失:OPENSSL_LIBRARIES)(发现
版本为 1.1.1)


方案

如果工具链中存在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


I try to crosscompile the Azure IoT C SDK (https://github.com/azure/azure-iot-sdk-c) for a BeagleBoard Black.

I did setup a Debian GNU/Linux 8.7 (jessie) Machine and installed the toolchain as described here: http://exploringbeaglebone.com/chapter7/.

Then i followed the steps here: https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/SDK_cross_compile_example.md and Created a Toolchain file:

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)

i call the Buildscript of the azure-sdk using:

./build.sh --toolchain-file toolchain-bb.cmake -cl --sysroot=/usr/lib/arm-linux-gnueabihf

The following Error Occures

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)

i tried to install openssl using:

sudo apt-get install openssl:armhf 

but the error remains, if i build the source for arm64 (using just the build.sh file of the azure-iot-sdk) everything works fine.

if i clone openssl and build it targeting arm i get the following error:

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")

解决方案

If you have Openssl present in your tool chain then you simply need to add a couple of additional lines to your cmake toolchain file. This will help cmake find your libraries and headers. Something like this:

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

If it is not present then you will need to cross compile openssl for your target and install it into your toolchain. Typically into /<sysroot>/usr/lib and /<sysroot>/usr/include.

Alternatively if openssl is on your device but not in your toolchain then you can simply copy it from the device. There is an example of copying dependencies to the toolchain in the Raspberry Pi demo here: https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/SDK_cross_compile_example.md

这篇关于交叉编译Azure IOT SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆