简体   繁体   English

azure-iot-sdk-c 交叉编译链接器问题:ld:找不到 -luuid

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

In general, I've tried to follow the guidelines in cross compile azure iot sdk .一般来说,我尝试遵循交叉编译 azure iot sdk 中的指导方针。

Here are the contents of toolchain-bb.cmake in azure-iot-sdk-c/build_all/linux这里是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)

At azure-iot-sdk-c/build_all/linux/ I use the following command:azure-iot-sdk-c/build_all/linux/我使用以下命令:

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

Here is the output:这是输出:

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....

In the StackOverflow link listed above, it mentions that --sysroot is very important.在上面列出的 StackOverflow 链接中,它提到--sysroot非常重要。 However, when I specify --sysroot as shown below, the build fails very early on (ie about [5%] into the build).但是,当我如下所示指定--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

Important note: libuuid.a exists in:重要说明: libuuid.a存在于:

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

You should include this line:你应该包括这一行:

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

And be sure that you have installed libuuid in your host system并确保您已在主机系统中安装 libuuid

sudo apt-get install uuid-dev sudo apt-get install uuid-dev

I'm not familiar with the particular toolchain you are using but typically you would not have the /lib on the sysroot path.我不熟悉您正在使用的特定工具链,但通常您不会在 sysroot 路径上拥有 /lib。 You absolutely have to specify a sysroot or the linker will attempt to link with the host libraries rather than those in the toolchain.您绝对必须指定一个 sysroot,否则链接器将尝试链接主机库而不是工具链中的库。

As for your first question, check your toolchain to see if libuuid.a exists.至于您的第一个问题,请检查您的工具链以查看 libuuid.a 是否存在。 If not then see if it exists on your device.如果没有,请查看它是否存在于您的设备上。 You can always copy from there to your toolchain.您始终可以从那里复制到您的工具链。 It would likely need to be somewhere like /mnt/yocto/bsp-yocto/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/usr/lib.它可能需要像 /mnt/yocto/bsp-yocto/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/usr/lib 这样的地方。

Without specific knowledge of the toolchain you are using it is difficult to be more precise.如果没有您所使用的工具链的具体知识,就很难做到更精确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM