Reputation: 11
In general, I've tried to follow the guidelines in cross compile azure iot sdk .
Here are the contents of toolchain-bb.cmake
in azure-iot-sdk-c/build_all/linux
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:
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. However, when I specify --sysroot
as shown below, the build fails very early on (i.e. about [5%] into the build).
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:
/mnt/yocto/yocto_repo/build/arago-tmp-external-linaro-toolchain/sysroots/am57xx-evm/usr/lib
Upvotes: 1
Views: 573
Reputation: 653
I'm not familiar with the particular toolchain you are using but typically you would not have the /lib on the sysroot path. You absolutely have to specify a sysroot or the linker will attempt to link with the host libraries rather than those in the toolchain.
As for your first question, check your toolchain to see if libuuid.a exists. 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.
Without specific knowledge of the toolchain you are using it is difficult to be more precise.
Upvotes: 0
Reputation: 31
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
sudo apt-get install uuid-dev
Upvotes: 1