Azure / azure-iot-sdk-c

A C99 SDK for connecting devices to Microsoft Azure IoT services
https://azure.github.io/azure-iot-sdk-c
Other
587 stars 739 forks source link

Error make undefined reference MQTT_Protocol #794

Closed JensVial closed 5 years ago

JensVial commented 5 years ago

I setup a autotools c++ project and try to use the iothub_ll_client_x509_sample.

My Makefile.am looks like this

bin_PROGRAMS = azureSendingMessage

azureSendingMessage_SOURCES = azureSendingMessageMain.cc

azureSendingMessage_CPPFLAGS = -isystem/usr/local/include/azureiot

azureSendingMessage_LDADD = /usr/local/lib/libiothub_client_mqtt_transport.a \ /usr/local/lib/libiothub_client_amqp_transport.a \ /usr/local/lib/libiothub_client_http_transport.a \ /usr/local/lib/libiothub_client.a \ /usr/local/lib/libumqtt.a \ /usr/local/lib/libprov_auth_client.a \ /usr/local/lib/libhsm_security_client.a \ /usr/local/lib/libuhttp.a \ /usr/local/lib/libaziotsharedutil.a \ /usr/local/lib/libparson.a \ -luuid \ -lpthread \ -lcurl \ -lssl \ -lcrypto \ -lm

This is the same like the CMakeLists.txt for the linux example provides. I also try other differend orders of the librarys for the makefile.am.

But i get always the following errors

/usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In functiongenerate_root_ca_info': hsm_client_riot.c:(.text+0xa6): undefined reference to DERInitContext' hsm_client_riot.c:(.text+0xc4): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0xe6): undefined reference to X509GetDeviceCertTBS' hsm_client_riot.c:(.text+0x150): undefined reference toRiotCrypt_Sign' hsm_client_riot.c:(.text+0x1b4): undefined reference to X509MakeRootCert' hsm_client_riot.c:(.text+0x239): undefined reference toDERtoPEM' hsm_client_riot.c:(.text+0x2e5): undefined reference to X509GetDEREcc' hsm_client_riot.c:(.text+0x34d): undefined reference toDERtoPEM' /usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function produce_device_cert': hsm_client_riot.c:(.text+0x409): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0x426): undefined reference to X509GetDeviceCertTBS' hsm_client_riot.c:(.text+0x48e): undefined reference toRiotCrypt_Sign' hsm_client_riot.c:(.text+0x4f3): undefined reference to X509MakeDeviceCert' hsm_client_riot.c:(.text+0x56e): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0x58b): undefined reference to X509GetDERCsrTbs' hsm_client_riot.c:(.text+0x5f3): undefined reference toRiotCrypt_Sign' hsm_client_riot.c:(.text+0x658): undefined reference to X509GetDERCsr' hsm_client_riot.c:(.text+0x6c9): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0x6e6): undefined reference to X509GetDeviceCertTBS' hsm_client_riot.c:(.text+0x74e): undefined reference toRiotCrypt_Sign' hsm_client_riot.c:(.text+0x7b0): undefined reference to X509MakeDeviceCert' hsm_client_riot.c:(.text+0x832): undefined reference toDERtoPEM' /usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function produce_alias_key_cert': hsm_client_riot.c:(.text+0x8c6): undefined reference toDERtoPEM' /usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function produce_alias_key_pair': hsm_client_riot.c:(.text+0x976): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0x9d9): undefined reference to X509GetDEREcc' hsm_client_riot.c:(.text+0xa4e): undefined reference toDERtoPEM' /usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function produce_device_id_public': hsm_client_riot.c:(.text+0xb01): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0xb25): undefined reference to X509GetDEREccPub' hsm_client_riot.c:(.text+0xb9a): undefined reference toDERtoPEM' /usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function process_riot_key_info': hsm_client_riot.c:(.text+0xcc8): undefined reference toRiotCrypt_Hash' hsm_client_riot.c:(.text+0xd3f): undefined reference to RiotCrypt_DeriveEccKey' hsm_client_riot.c:(.text+0xdb4): undefined reference toRiotCrypt_Hash2' hsm_client_riot.c:(.text+0xe31): undefined reference to RiotCrypt_DeriveEccKey' hsm_client_riot.c:(.text+0xf84): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0xfb1): undefined reference to X509GetAliasCertTBS' hsm_client_riot.c:(.text+0x101c): undefined reference toRiotCrypt_Sign' hsm_client_riot.c:(.text+0x1084): undefined reference to X509MakeAliasCert' /usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In functionhsm_client_x509_init': hsm_client_riot.c:(.text+0x1295): undefined reference to DiceSHA256' hsm_client_riot.c:(.text+0x12b9): undefined reference toDiceSHA256_2' /usr/local/lib/libhsm_security_client.a(hsm_client_riot.c.o): In function hsm_client_riot_create_leaf_cert': hsm_client_riot.c:(.text+0x1c22): undefined reference toDERInitContext' hsm_client_riot.c:(.text+0x1c3f): undefined reference to X509GetDeviceCertTBS' hsm_client_riot.c:(.text+0x1cad): undefined reference toRiotCrypt_Sign' hsm_client_riot.c:(.text+0x1d15): undefined reference to X509MakeDeviceCert' hsm_client_riot.c:(.text+0x1de9): undefined reference toDERtoPEM' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function GetEkTemplate': hsm_client_tpm.c:(.text+0x1f): undefined reference toToTpmaObject' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function GetSrkTemplate': hsm_client_tpm.c:(.text+0x95): undefined reference toToTpmaObject' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function dps_umarshal_array': hsm_client_tpm.c:(.text+0x114): undefined reference toUINT32_Unmarshal' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function unmarshal_array': hsm_client_tpm.c:(.text+0x1f2): undefined reference toUINT32_Unmarshal' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function marshal_array_values': hsm_client_tpm.c:(.text+0x32b): undefined reference toUINT32_Unmarshal' hsm_client_tpm.c:(.text+0x452): undefined reference to UINT32_Unmarshal' hsm_client_tpm.c:(.text+0x579): undefined reference toUINT32_Unmarshal' hsm_client_tpm.c:(.text+0x6a2): undefined reference to TPM2B_PUBLIC_Unmarshal' hsm_client_tpm.c:(.text+0x742): undefined reference toUINT16_Unmarshal' hsm_client_tpm.c:(.text+0x7de): undefined reference to TPM2B_PRIVATE_Unmarshal' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In functioncreate_tpm_session': hsm_client_tpm.c:(.text+0x8a1): undefined reference to TSS_StartAuthSession' hsm_client_tpm.c:(.text+0x907): undefined reference toTSS_PolicySecret' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function insert_key_in_tpm': hsm_client_tpm.c:(.text+0xa94): undefined reference toTPM2B_ID_OBJECT_Unmarshal' hsm_client_tpm.c:(.text+0xaf4): undefined reference to TPM2B_ENCRYPTED_SECRET_Unmarshal' hsm_client_tpm.c:(.text+0xb54): undefined reference toTPM2B_PRIVATE_Unmarshal' hsm_client_tpm.c:(.text+0xbb4): undefined reference to TPM2B_ENCRYPTED_SECRET_Unmarshal' hsm_client_tpm.c:(.text+0xc13): undefined reference toTPM2B_PUBLIC_Unmarshal' hsm_client_tpm.c:(.text+0xc73): undefined reference to UINT16_Unmarshal' hsm_client_tpm.c:(.text+0xcee): undefined reference toTPM2_ActivateCredential' hsm_client_tpm.c:(.text+0xd7b): undefined reference to TPM2_Import' hsm_client_tpm.c:(.text+0xe2d): undefined reference toToTpmaObject' hsm_client_tpm.c:(.text+0xecc): undefined reference to TSS_Create' hsm_client_tpm.c:(.text+0xf46): undefined reference toTPM2_Load' hsm_client_tpm.c:(.text+0xfb4): undefined reference to TPM2_EvictControl' hsm_client_tpm.c:(.text+0xfdc): undefined reference toTPM2_EvictControl' hsm_client_tpm.c:(.text+0x1036): undefined reference to TPM2_FlushContext' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In functiondecrypt_data': hsm_client_tpm.c:(.text+0x1131): undefined reference to TSS_GetTpmProperty' hsm_client_tpm.c:(.text+0x11f8): undefined reference toTPM2B_ID_OBJECT_Unmarshal' hsm_client_tpm.c:(.text+0x1258): undefined reference to TPM2B_ENCRYPTED_SECRET_Unmarshal' hsm_client_tpm.c:(.text+0x12b8): undefined reference toTPM2B_PRIVATE_Unmarshal' hsm_client_tpm.c:(.text+0x1318): undefined reference to TPM2B_ENCRYPTED_SECRET_Unmarshal' hsm_client_tpm.c:(.text+0x1377): undefined reference toTPM2B_PUBLIC_Unmarshal' hsm_client_tpm.c:(.text+0x13d7): undefined reference to UINT16_Unmarshal' hsm_client_tpm.c:(.text+0x14fa): undefined reference toTPM2_ActivateCredential' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In function initialize_tpm_device': hsm_client_tpm.c:(.text+0x15dc): undefined reference toTSS_CreatePwAuthSession' hsm_client_tpm.c:(.text+0x1632): undefined reference to Initialize_TPM_Codec' hsm_client_tpm.c:(.text+0x16a9): undefined reference toTSS_CreatePersistentKey' hsm_client_tpm.c:(.text+0x1720): undefined reference to TSS_CreatePersistentKey' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In functionhsm_client_tpm_destroy': hsm_client_tpm.c:(.text+0x1885): undefined reference to Deinit_TPM_Codec' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In functionhsm_client_tpm_get_endorsement_key': hsm_client_tpm.c:(.text+0x1a8f): undefined reference to TPM2B_PUBLIC_Marshal' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In functionhsm_client_tpm_get_storage_key': hsm_client_tpm.c:(.text+0x1c63): undefined reference to TPM2B_PUBLIC_Marshal' /usr/local/lib/libhsm_security_client.a(hsm_client_tpm.c.o): In functionhsm_client_tpm_sign_data': hsm_client_tpm.c:(.text+0x1e01): undefined reference to SignData' /usr/local/lib/libumqtt.a(mqtt_message.c.o): In functionmqttmessage_getTopicLevels': mqtt_message.c:(.text+0x67e): undefined reference to StringToken_Split' collect2: error: ld returned 1 exit status Makefile:361: recipe for target 'azureSendingMessage' failed make[2]: *** [azureSendingMessage] Error 1 make[2]: Leaving directory '/var/opt/ExampleAzureProg/src' Makefile:352: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/var/opt/ExampleAzureProg' Makefile:293: recipe for target 'all' failed make: *** [all] Error 2

I know this problem was discussed in earlier issues and was solved by reorder the librarys. But reordering the librarys do not help in my case.

I'm using the 2018-12-13 release

Edit: If i make a cmake-project with a CMakeLists.txt the project compiles. But if i try to make a equivalent make (autotools) project the above error of undefined references occured. Unfortunately i need a make (Autotools) project.

EditEdit:

I figure out that the code lines

IOTHUB_DEVICE_CLIENT_LL_HANDLE device_ll_handle; device_ll_handle = IoTHubClientCore_LL_CreateFromConnectionString(connectionString, MQTT_Protocol);

produce the error of undefined references. Can anyone tell me which libs I have to include for the MQTT_Protocol, IOTHUB_DEVICE_CLIENT_LL_HANDLE and the IoTHubClientCore_LL_CreateFromConnectionString?

jebrando commented 5 years ago

@AngelsEnd Are you building and installing the libraries?

jebrando commented 5 years ago

@AngelsEnd Let us know if this is still an issue.

Thanks

az-iot-builder-01 commented 5 years ago

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