簡體   English   中英

azure-iot-sdk-c 交叉編譯鏈接器問題:ld:找不到 -luuid

[英]azure-iot-sdk-c cross-compiling linker issue: ld: cannot find -luuid

一般來說,我嘗試遵循交叉編譯 azure iot sdk 中的指導方針。

這里是azure-iot-sdk-c/build_all/linuxtoolchain-bb.cmake的內容

INCLUDE(CMakeForceCompiler)

SET(CMAKE_SYSTEM_NAME Linux)     # this one is important
SET(CMAKE_SYSTEM_VERSION 1)     # this one not so much

SET(CMAKE_C_COMPILER /mnt/yocto/bsp-yocto/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_FIND_ROOT_PATH /mnt/yocto/yocto_repo/build/arago-tmp-external-linaro-toolchain/sysroots/am57xx-evm/usr)

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

# openssl directories
SET(OPENSSL_ROOT_DIR /mnt/yocto/yocto_repo/build/tmp/sysroots/am57xx-evm/usr/lib/)
SET(OPENSSL_INCLUDE_DIR /mnt/yocto/yocto_repo/build/tmp/sysroots/am57xx-evm/usr/include/)

SET(CURL_LIBRARY /mnt/yocto/yocto_repo/build/tmp/sysroots/am57xx-evm/usr/lib/libcurl.a)
SET(CURL_INCLUDE_DIR /mnt/yocto/yocto_repo/build/tmp/sysroots/am57xx-evm/usr/include/curl/)

SET(UUID_LIBRARY_DIRS /mnt/yocto/yocto_repo/build/arago-tmp-external-linaro-toolchain/sysroots/am57xx-evm/usr/lib)

azure-iot-sdk-c/build_all/linux/我使用以下命令:

sudo ./build.sh --toolchain-file toolchain-bb.cmake

這是輸出:

Linking C static library libumqtt.a
Linking C executable iot_c_utility
[ 68%] Built target umqtt
Scanning dependencies of target iothub_client_mqtt_transport
Scanning dependencies of target iothub_client_mqtt_ws_transport
/mnt/yocto/bsp-yocto/gcc-linaro-5.3-2016.02-x86_64_arm-linux-
gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-
gnueabihf/bin/ld: cannot find -luuid
collect2: error: ld returned 1 exit status
make[2]: *** [c-utility/samples/iot_c_utility/iot_c_utility] Error 1
make[1]: *** [c-
utility/samples/iot_c_utility/CMakeFiles/iot_c_utility.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

在上面列出的 StackOverflow 鏈接中,它提到--sysroot非常重要。 但是,當我如下所示指定--sysroot時,構建很早就失敗了(即大約 [5%] 進入構建)。

 sudo ./build.sh --toolchain-file toolchain-bb.cmake -cl --sysroot=/mnt/yocto/bsp-yocto/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/lib

重要說明: libuuid.a存在於:

/mnt/yocto/yocto_repo/build/arago-tmp-external-linaro-toolchain/sysroots/am57xx-evm/usr/lib

你應該包括這一行:

set(compileOption_C "--sysroot=<your_path_to_sysroot>")

並確保您已在主機系統中安裝 libuuid

sudo apt-get install uuid-dev

我不熟悉您正在使用的特定工具鏈,但通常您不會在 sysroot 路徑上擁有 /lib。 您絕對必須指定一個 sysroot,否則鏈接器將嘗試鏈接主機庫而不是工具鏈中的庫。

至於您的第一個問題,請檢查您的工具鏈以查看 libuuid.a 是否存在。 如果沒有,請查看它是否存在於您的設備上。 您始終可以從那里復制到您的工具鏈。 它可能需要像 /mnt/yocto/bsp-yocto/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/usr/lib 這樣的地方。

如果沒有您所使用的工具鏈的具體知識,就很難做到更精確。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM