Description
Development Machine, OS, Compiler (and Other Relevant Toolchain Info)
Cross Compiled on Ubuntu 20.04 using GNU 9.4.0
SDK Version (Please Give Commit SHA if Manually Compiling)
lts_01_2023
Protocol
MQTT/HTTP
Describe the Bug
I'm having the same issue as this person here #1479. I didn't find a solution on his thread regarding the fix. His issue was with the Prov_device_HTTP_Protocol mine is the Prov_device_MQTT_Protocol
undefined reference to Prov_Device_MQTT_Protocol
CMakeFiles/iotd.dir/azure_iot_ctrl.cpp.o: In function `azure_iot_ctrl::iot_provision()':
/home/umair/ASP/asp/iotmgmt/azure_iot_ctrl.cpp:2176: undefined reference to `Prov_Device_MQTT_Protocol'
/home/umair/ASP/asp/iotmgmt/azure_iot_ctrl.cpp:2176: undefined reference to `Prov_Device_MQTT_Protocol'
collect2: error: ld returned 1 exit status
make[3]: *** [iotmgmt/CMakeFiles/iotd.dir/build.make:177: iotmgmt/iotd] Error 1
make[2]: *** [CMakeFiles/Makefile2:919: iotmgmt/CMakeFiles/iotd.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:931: iotmgmt/CMakeFiles/iotd.dir/rule] Error 2
make: *** [Makefile:372: iotd] Error 2
From the same line of code:
PROV_DEVICE_TRANSPORT_PROVIDER_FUNCTION prov_transport = Prov_Device_MQTT_Protocol;
Headers included:
#include <azure_prov_client/prov_device_client.h>
#include <azure_prov_client/prov_security_factory.h>
#include <azure_prov_client/prov_transport_mqtt_client.h>
#include <azure_c_shared_utility/crt_abstractions.h>
#include <azure_c_shared_utility/shared_util_options.h>
#include <azure_c_shared_utility/threadapi.h>
#include <iothub.h>
#include <iothub_client.h>
#include <iothub_client_core.h>
#include <iothub_client_core_common.h>
#include <iothub_client_options.h>
#include <iothub_device_client.h>
#include <iothub_message.h>
#include <iothubtransportmqtt.h>
CMake file:
cmake_minimum_required(VERSION 3.8)
project(iotmgmt)
include(../CommonCMake.txt)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azureiot")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/c-utility/inc/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/provisioning_client/inc/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/provisioning_client/inc/azure_prov_client/internal/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/provisioning_client/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/provisioning_client/adapters/")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/iothub_client/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/iothub_client/inc/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/iothub_client/inc/internal/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/deps/umock-c/inc/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I=/usr/include/azure-iot-sdk-c/deps/azure-macro-utils-c/inc/")
#add_subdirectory(../azure-iot-sdk-c out)
set_source_files_properties(iotmgmt_states.cpp PROPERTIES COMPILE_FLAGS -Wno-psabi)
add_executable(iotd iotmgmt.cpp iotmgmt_states.cpp azure_hsm_client.cpp azure_iot_ctrl.cpp)
target_link_libraries(iotd msg asp gain_config iothub_client aziotsharedutil_dll prov_device_client curl zmq rt z)
# ESX uses Azure IOT SDK 1.3.8 with the following dependencies
if(${PRODUCT} MATCHES "esx")
target_link_libraries(iotd prov_mqtt_transport umqtt)
endif()
install(TARGETS iotd DESTINATION /usr/bin)
install(FILES iotd.service DESTINATION /lib/systemd/system)
install(FILES iot_conf.json DESTINATION /etc/iot)
I also tried running a nm command on an old version of the SDK shared object and the latest version to see whether that particular function is included in both but it was included in the older version of the shared object and not the new.
nm --print-file-name --dynamic libprov_device_client.so.1.2.10 | grep Prov_Device_MQTT_Protocol
libprov_device_client.so.1.2.10:000135b0 T Prov_Device_MQTT_Protocol
nm --print-file-name --dynamic libprov_device_client.so.1.10.0 | grep Prov_Device_MQTT_Protocol
No output
Thanks in advance!
Update:
I noticed that when I set the Use_installed_dependencies flag in the cmake file, I get these build errors for azure-macro-utils-c. I think this issue I'm facing with Prov_Device_MQTT_Protocol could be related to this flag not being set before building all the SDK binaries, reason why that function(Prov_Device_MQTT_Protocol) is not found in the shared object.