Azure-iot-sdk-c: hsm_custom_lib > Compile issue

Created on 2 Sep 2020  路  12Comments  路  Source: Azure/azure-iot-sdk-c

Am on Raspberry PI (Latest version)

Am trying to compile the custom hsm sample.

Running into an issue recognizing libcustom_hsm_example.a

[Command]---------------------------------------------------------

cmake -Duse_prov_client:BOOL=ON -Dhsm_custom_lib="~/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a" .
cmake --build .

[Errror]---------------------------------------------------------

[ 74%] Building C object iothub_client/CMakeFiles/iothub_client.dir/src/blob.c.o
[ 75%] Linking C static library libiothub_client.a
[ 75%] Built target iothub_client
Scanning dependencies of target iothub_convenience_sample
[ 75%] Building C object iothub_client/samples/iothub_convenience_sample/CMakeFiles/iothub_convenience_sample.dir/iothub_convenience_sample.c.o
make[2]: * No rule to make target '/root/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a', needed by 'iothub_client/samples/iothub_convenience_sample/iothub_convenience_sample'. Stop.
make[1]:
[CMakeFiles/Makefile2:2201: iothub_client/samples/iothub_convenience_sample/CMakeFiles/iothub_convenience_sample.dir/all] Error 2
make: *
* [Makefile:141: all] Error 2

Most helpful comment

Great support Dane!

All 12 comments

Hi @qzzf1w can you try adding this -> -Dhsm_type_custom=ON to your cmake command?

Same issue

sudo cmake -Duse_prov_client:BOOL=ON -Dhsm_type_custom=ON -Dhsm_custom_lib="~/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a" .

sudo cmake --build .

Running from

pi@raspberrypi:~/azure-iot-sdk-c/cmake

[Error]--------------------
make[2]: * No rule to make target '/root/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a', needed by 'iothub_client/samples/iothub_convenience_sample/iothub_convenience_sample'. Stop.

And one more thing.

All of this works on windows

Okay yea so unfortunately I think the CMake situation could be better here.
TLDR to get you unblocked:

cmake -Duse_prov_client=ON ..
cmake --build .
cmake -Duse_prov_client:BOOL=ON -Dhsm_type_custom=ON -Dhsm_custom_lib="~/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a" .
cmake --build .

Reasoning being the first pass, it will build the custom lib and then the second pass it will link that newly built lib in your solution.

Let me know if that works. I can look to get this to work better on a first pass only but for now that's how it'll work.

EDIT: I ran this on Linux Ubuntu 18.04 and it seemed to work.

I beleive I did two pass but will try again
Stay posted

Here is what I am using (Latest Raspbian build)

Operating System: Raspbian GNU/Linux 10 (buster)
Kernel: Linux 5.4.51+

My precise steps to repro as follows

  1. Install new Raspbian image on Micro SD Card
  2. Boot
  3. sudo apt-get install cmake build-essential
    sudo apt-get install git-core
    sudo apt-get purge -y libssl-dev
    sudo apt-get install libcurl4-openssl-dev
    sudo apt-get install libssl-dev
    sudo apt-get update
    sudo apt-get upgrade
    sudo reboot
  4. sudo git clone -b LTS_07_2020_Ref01 --recursive https://github.com/azure/azure-iot-sdk-c.git
    cd azure-iot-sdk-c
    sudo mkdir cmake
    cd cmake
    sudo cmake -Duse_prov_client:BOOL=ON ..
    sudo cmake --build .
    sudo cmake -Duse_prov_client:BOOL=ON -Dhsm_type_custom=ON -Dhsm_custom_lib="~/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a" .
    sudo cmake --build .

Same results

[Error]------------------------
[ 74%] Building C object iothub_client/CMakeFiles/iothub_client.dir/src/blob.c.o
[ 75%] Linking C static library libiothub_client.a
[ 75%] Built target iothub_client
Scanning dependencies of target iothub_convenience_sample
[ 75%] Building C object iothub_client/samples/iothub_convenience_sample/CMakeFiles/iothub_convenience_sample.dir/iothub_convenience_sample.c.o
make[2]: * No rule to make target '/root/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a', needed by 'iothub_client/samples/iothub_convenience_sample/iothub_convenience_sample'. Stop.
make[1]:
[CMakeFiles/Makefile2:2201: iothub_client/samples/iothub_convenience_sample/CMakeFiles/iothub_convenience_sample.dir/all] Error 2
make: *
* [Makefile:141: all] Error 2

Interesting just tried it on a raspberry pi following your exact steps and it worked. One caveat on your list of commands above. What you have as

sudo cmake -Duse_prov_client:BOOL=ON -Dhsm_type_custom=ON -Dhsm_custom_lib="~/azure-iot-sdk-c/cmake/provisioning_client/samples/custom_hsm_example/libcustom_hsm_example.a" .

It's missing a . at the end. It should be ... But otherwise I ran exactly the same thing and it worked.

actually maybe try expanding out the relative path of the custom lib?

That is it ~ resolves to "root" I wanted "home/pi"

Nice! Alright so I'll go ahead and close this for now. Let me know if you want it reopened for any reason.

@danewalton, @qzzf1w, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

Great support Dane!

Was this page helpful?
0 / 5 - 0 ratings