Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined reference error when using azure-iot-sdk-c LTS_08_2024 #2669

Open
amarKPIT opened this issue Feb 25, 2025 · 0 comments
Open

Undefined reference error when using azure-iot-sdk-c LTS_08_2024 #2669

amarKPIT opened this issue Feb 25, 2025 · 0 comments

Comments

@amarKPIT
Copy link

amarKPIT commented Feb 25, 2025

SDK version used: azure-iot-sdk-c LTS_08_2024

Issue:
Using the SDK installed on raspi, to develop a client that interacts with the Hub. Building using cmake. This is similar to https://github.com/Azure/azure-iot-sdk-c/issues/543 Issue #543. Getting this build error:

/usr/bin/ld: ../../azure-iot-sdk-c/cmake/iothub_client/libiothub_client_mqtt_transport.a(iothub_client_authorization.c.o): in function IoTHubClient_Auth_CreateFromDeviceAuth': /home/raspi2/azure/sdk-c/azure-iot-sdk-c/iothub_client/src/iothub_client_authorization.c:181: undefined reference to iothub_device_auth_create'
/usr/bin/ld: /home/raspi2/azure/sdk-c/azure-iot-sdk-c/iothub_client/src/iothub_client_authorization.c:192: undefined reference to iothub_device_auth_get_type' /usr/bin/ld: ../../azure-iot-sdk-c/cmake/iothub_client/libiothub_client_mqtt_transport.a(iothub_client_authorization.c.o): in function IoTHubClient_Auth_Destroy':
/home/raspi2/azure/sdk-c/azure-iot-sdk-c/iothub_client/src/iothub_client_authorization.c:217: undefined reference to iothub_device_auth_destroy' /usr/bin/ld: ../../azure-iot-sdk-c/cmake/iothub_client/libiothub_client_mqtt_transport.a(iothub_client_authorization.c.o): in function IoTHubClient_Auth_Set_xio_Certificate':
/home/raspi2/azure/sdk-c/azure-iot-sdk-c/iothub_client/src/iothub_client_authorization.c:275: undefined reference to iothub_device_auth_generate_credentials' /usr/bin/ld: ../../azure-iot-sdk-c/cmake/iothub_client/libiothub_client_mqtt_transport.a(iothub_client_authorization.c.o): in function IoTHubClient_Auth_Get_x509_info':
/home/raspi2/azure/sdk-c/azure-iot-sdk-c/iothub_client/src/iothub_client_authorization.c:323: undefined reference to iothub_device_auth_generate_credentials' /usr/bin/ld: ../../azure-iot-sdk-c/cmake/iothub_client/libiothub_client_mqtt_transport.a(iothub_client_authorization.c.o): in function IoTHubClient_Auth_Get_SasToken':
/home/raspi2/azure/sdk-c/azure-iot-sdk-c/iothub_client/src/iothub_client_authorization.c:406: undefined reference to `iothub_device_auth_generate_credentials'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/MyClient.dir/build.make:129: MyClient] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/MyClient.dir/all] Error 2
gmake: *** [Makefile:103: all] Error 2

The list was much longer, like in #543, but was brought down to these after adding the 4 libraries that were suggested as a resolution there. This is the CMakeLists.txt, I just kept on adding dependencies that I thought were not being linked, will need to clean up as per your suggestion for resolving this issue:

cmake_minimum_required(VERSION 3.10)
project(MyClient)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)

set(AzureIoTHub_REPOSITORY ${CMAKE_SOURCE_DIR}/../azure-iot-sdk-c)

add_executable(MyClient src/main.cpp src/iot_hub_adapter.cpp)

target_include_directories(MyClient PRIVATE
${AzureIoTHub_REPOSITORY}/c-utility/inc
${AzureIoTHub_REPOSITORY}/c-utility/cmake
${AzureIoTHub_REPOSITORY}/umqtt/inc
${AzureIoTHub_REPOSITORY}/uamqp/inc
${AzureIoTHub_REPOSITORY}/iothub_client/inc
${AzureIoTHub_REPOSITORY}/iothub_client/samples/common
${AzureIoTHub_REPOSITORY}/deps/umock-c/inc
${AzureIoTHub_REPOSITORY}/deps/azure-macro-utils-c/inc
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/include
)

add_library(iothub_client STATIC IMPORTED)
set_target_properties(iothub_client PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/iothub_client/libiothub_client.a)

add_library(umqtt STATIC IMPORTED)
set_target_properties(umqtt PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/umqtt/libumqtt.a)

add_library(azure_c_shared_util STATIC IMPORTED)
set_target_properties(azure_c_shared_util PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/c-utility/libaziotsharedutil.a)

add_library(uamqp STATIC IMPORTED)
set_target_properties(uamqp PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/uamqp/libuamqp.a)

add_library(prov_auth_client STATIC IMPORTED)
set_target_properties(prov_auth_client PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/provisioning_client/libprov_auth_client.a)

add_library(hsm_security_client STATIC IMPORTED)
set_target_properties(hsm_security_client PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/provisioning_client/libhsm_security_client.a)

add_library(uhttp STATIC IMPORTED)
set_target_properties(uhttp PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/deps/uhttp/libuhttp.a)

add_library(iothub_mqtt STATIC IMPORTED)
set_target_properties(iothub_mqtt PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/iothub_client/libiothub_client_mqtt_transport.a)

add_library(iothub_http STATIC IMPORTED)
set_target_properties(iothub_http PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/iothub_client/libiothub_client_http_transport.a)

add_library(prov_dev STATIC IMPORTED)
set_target_properties(prov_dev PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/provisioning_client/libprov_device_client.a)

add_library(iothub_mqtt_ws STATIC IMPORTED)
set_target_properties(iothub_mqtt_ws PROPERTIES IMPORTED_LOCATION ${AzureIoTHub_REPOSITORY}/cmake/iothub_client/libiothub_client_mqtt_ws_transport.a)

target_link_libraries(MyClient
prov_auth_client
hsm_security_client
iothub_mqtt
iothub_http
prov_dev
uamqp
umqtt
uhttp
iothub_client
iothub_mqtt_ws
azure_c_shared_util
-luuid
-lparson
-lwolfssl
rt
pthread
m
-lssl
-lcrypto
-lcurl
-ljson-c
)

set(CMAKE_CXX_WARNINGS "-Wall -Wextra")

What am I missing/overlooking? Any pointers would be greatly appreciated. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant