Closed zambranohally closed 1 year ago
You need to install the parson vcpkg package.
C:\Repos\vcpkg>vcpkg search parson
parson 2022-11-13 a lightweight json library written in C
@ericwol-msft Thank you for your reply. I did install parson and also added it to cmakelists.txt but still the error persist.
dump your linker paths and see what is going on.
@ericwol-msft I am using cmake all of my other libraries are working except azure iot.
You can use cmake options--debug-output
and --trace
to debug your cmake.
@ericwol-msft This is what I got.
This is a paho mqqt issues and not related to this repo. Have you tried searching the internet for your issue?
@ericwol-msft sorry for my previous post but that was already solve. I mistakenly paste the wrong screenshot. Please can you help me what is wrong, what am I lacking. I already added parson in cmakelists still the error persist.
root@xxx:/mnt/e/c++/xxx# cmake --build /root/.vs/xxx/out/build/linux-debug --target xxx--config Debug --verbose [1/1] : && /usr/bin/g++ -g CMakeFiles/xxx.dir/sources/xxx.cpp.o CMakeFiles/xxx.dir/sources/db_config.cpp.o CMakeFiles/xxx.dir/sources/api.cpp.o CMakeFiles/xxx.dir/sources/options.cpp.o CMakeFiles/xxx.dir/sources/cli.cpp.o CMakeFiles/xxx.dir/sources/m_device.cpp.o CMakeFiles/xxx.dir/sources/heartbeat.cpp.o CMakeFiles/xxx.dir/sources/m_heartbeat.cpp.o CMakeFiles/xxx.dir/sources/device.cpp.o CMakeFiles/xxx.dir/sources/camera.cpp.o CMakeFiles/xxx.dir/sources/m_camera.cpp.o CMakeFiles/xxx.dir/sources/m_rss_payload.cpp.o CMakeFiles/xxx.dir/sources/mqtt.cpp.o CMakeFiles/xxx.dir/sources/mqtt_callback.cpp.o CMakeFiles/xxx.dir/sources/command_queue.cpp.o CMakeFiles/xxx.dir/sources/command_consumer.cpp.o -o xxx /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libserializer.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libprov_auth_client.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libhsm_security_client.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libboost_program_options.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libspdlogd.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libpaho-mqttpp3.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libpaho-mqtt3as.a -luuid /mnt/e/vcpkg/installed/x64-linux/debug/lib/libuhttp.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_http_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_amqp_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_amqp_ws_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libuamqp.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libssl.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libcrypto.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_mqtt_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_mqtt_ws_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libumqtt.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libaziotsharedutil.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libcurl-d.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libz.a -lm -lparson /mnt/e/vcpkg/installed/x64-linux/debug/lib/libfmtd.a -lstdc++ /mnt/e/vcpkg/installed/x64-linux/debug/lib/libpaho-mqtt3cs.a -lc /mnt/e/vcpkg/installed/x64-linux/debug/lib/libssl.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libcrypto.a -lpthread -ldl -lpthread -lrt -lanl && : FAILED: xxx : && /usr/bin/g++ -g CMakeFiles/xxx.dir/sources/vianad.cpp.o CMakeFiles/xxx.dir/sources/db_config.cpp.o CMakeFiles/xxx.dir/sources/api.cpp.o CMakeFiles/vianad.dir/sources/options.cpp.o CMakeFiles/vianad.dir/sources/cli.cpp.o CMakeFiles/xxx.dir/sources/m_device.cpp.o CMakeFiles/xxx.dir/sources/heartbeat.cpp.o CMakeFiles/xxx.dir/sources/m_heartbeat.cpp.o CMakeFiles/xxx.dir/sources/device.cpp.o CMakeFiles/xxx.dir/sources/camera.cpp.o CMakeFiles/xxx.dir/sources/m_camera.cpp.o CMakeFiles/xxx.dir/sources/m_rss_payload.cpp.o CMakeFiles/xxx.dir/sources/mqtt.cpp.o CMakeFiles/xxx.dir/sources/mqtt_callback.cpp.o CMakeFiles/xxx.dir/sources/command_queue.cpp.o CMakeFiles/xxx.dir/sources/command_consumer.cpp.o -o xxx /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libserializer.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libprov_auth_client.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libhsm_security_client.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libboost_program_options.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libspdlogd.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libpaho-mqttpp3.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libpaho-mqtt3as.a -luuid /mnt/e/vcpkg/installed/x64-linux/debug/lib/libuhttp.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_http_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_amqp_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_amqp_ws_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libuamqp.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libssl.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libcrypto.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_mqtt_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libiothub_client_mqtt_ws_transport.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libumqtt.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libaziotsharedutil.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libcurl-d.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libz.a -lm -lparson /mnt/e/vcpkg/installed/x64-linux/debug/lib/libfmtd.a -lstdc++ /mnt/e/vcpkg/installed/x64-linux/debug/lib/libpaho-mqtt3cs.a -lc /mnt/e/vcpkg/installed/x64-linux/debug/lib/libssl.a /mnt/e/vcpkg/installed/x64-linux/debug/lib/libcrypto.a -lpthread -ldl -lpthread -lrt -lanl && : /usr/bin/ld: cannot find -lparson collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.
are you using the cmake option use_installed_dependencies
if(${use_installed_dependencies})
find_package(parson REQUIRED CONFIG)
endif()
You need to a.) dump the cmake generate debug and find out how parson is getting pulled in. b.) dump the linker paths and find out why the lib can not be found.
@RLeclair, @vaavva and I looked at this today. The issue is that cmake does not detect the path: -lparson
instead of something on the lines of
/mnt/e/vcpkg/installed/x64-linux/debug/lib/libparson.a
.
We couldn't find anything that changed in our library. My suspicion is that https://github.com/microsoft/vcpkg/pull/27885 might have changed something that we need to update on our side.
We couldn't find anything that changed in our library. My suspicion is that microsoft/vcpkg#27885 might have changed something that we need to update on our side.
What microsoft/vcpkg#27885 changed is that instead of creating parson
as an alias target for vcpkg's proprietary unofficial::parson::parson
, it now relies on parson's official cmake config which provides an imported target parson::parson
.
So in vcpkg, azure-iot-sdk-c's use of target_link_libraries(... parson)
is no longer backed by a target with location properties. And due to absence of a namespace::
, CMake can't offer good diagnostics but must pass parson
as namespec to the linker (-lparson
). Which may or may not find some matching lib, and not necessarily at the location provided by find_package(parson CONFIG REQUIRED)
.
So the bug is here, indeed, and you need to update how the projects links to parson in CMake, in this and other spots: https://github.com/Azure/azure-iot-sdk-c/blob/97fef570416467598100b782ef27ceadad9ca796/serializer/CMakeLists.txt#L71 should either become
target_link_libraries(serializer parson::parson)
or an alias needs to be created again. (This is the new fix in vcpkg.)
(And maybe it would be good to start using the PUBLIC
/PRIVATE
/INTERFACE
keywords, but this has a larger scope.)
Thank you @dg0yt for your detailed answer and the fix in VCPKG!
In the future, we plan to add VCPKG support within the library itself (instead of maintaining .patch files in VCPKG) as well as a CI step that uses VCPKG (to detect issues faster instead of just during our release workflow).
@zambranohally this issue should be fixed within LTS_08_2023
I have a cross platform project that will use iothub in c++. I am using Visual Studio 2022 together cmake and vcpkg. install the latest release for vcpkg. Below are my steps in installing the azure-iot-sdk-c.