2017-04-24 239 views
0

我嘗試交叉編譯BeagleBoard Black的Azure IoT C SDK(https://github.com/azure/azure-iot-sdk-c)。交叉編譯azure iot sdk

我的確設置了Debian GNU/Linux 8.7(jessie)Machine並安裝了這裏描述的工具鏈:http://exploringbeaglebone.com/chapter7/

然後我也跟着這裏的步驟: https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/SDK_cross_compile_example.md並創建了一個工具鏈文件:

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

以下錯誤Occures

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

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和構建它靶臂我得到以下錯誤:

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

* * * *時,*庫不在*主目錄*下搜索庫。這正是「SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)」的意思(參見[docs](https://cmake.org/cmake/help/v3.7/variable/CMAKE_FIND_ROOT_PATH_MODE_LIBRARY.html))。 'apt-get'可以和* host *包一起使用。 – Tsyvarev

+0

@Tsyvarev如果我克隆openssl併爲它構建它我得到另一個錯誤,我編輯了問題 – Console

+0

您需要在sysroot下安裝OpenSSL,並可能提供一個有關它的位置提示給CMake(可能,建議* OPENSSL_ROOT_DIR *會幫助) 。 – Tsyvarev

回答

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