WebSocket.c:(.text+0x8ba): undefined reference to `uuid_generate'
Z-J-X opened this issue · 3 comments
Line 413 in 7db2132
I encountered this error when integrating PahoMqttCpp using vcpkg,there was no issue with the previous version. I changed Paho mqtt from 1.3.9 to 1.3.12 and OpenSSL from 3.0.3 to 3.1.0, which caused this issue.
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /usr/local/vcpkg/installed/x64-linux/lib/libpaho-mqtt3a.a(WebSocket.c.o): in function `WebSocket_connect':
WebSocket.c:(.text+0x8ba): undefined reference to `uuid_generate'
collect2: error: ld returned 1 exit status
make[2]: *** [Demo/PahoMqtt/CMakeFiles/DemoMqtt.dir/build.make:225: Demo/PahoMqtt/DemoMqtt] Error 1
make[1]: *** [CMakeFiles/Makefile2:1288: Demo/PahoMqtt/CMakeFiles/DemoMqtt.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
The use of an external uuid_generate call looks to be predicated on the existence of a LIBUUID environment variable so maybe that is now set? Anyway, the uuid library is missing from the list
SET(LIBS_SYSTEM c dl pthread rt)
in src/CMakeLists.txt.
Thank you for your reply, but according to the settings you mentioned, it doesn't seem to work.
I think there may be some issues with the latest cmake script provided by vcpkg, mainly in the link section.
When using cmake with vcpkg :
target_include_directories( ${PROJECT_NAME} PRIVATE ${**UUID_INCLUDE_DIRS**})
target_link_directories(${PROJECT_NAME} PRIVATE ${**UUID_LIB_DIRS**})
Find_package (PahoMqttCpp CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC PahoMqttCpp::paho-mqttpp3-static uuid)
There will be the errors mentioned earlier.
Then I gave up using 'find_package' and succeeded.
target_include_directories( ${PROJECT_NAME} PRIVATE ${**INCLUDE_DIRS**})
target_link_directories(${PROJECT_NAME} PRIVATE ${**LIB_DIRS**})
Find_package (PahoMqttCpp CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC paho-mqttpp3 paho-mqtt3a pthread uuid)
So I think there is a problem with the cmake file in the latest version of vcpkg.
Then I switched vcpkg to tag 2023.04.15 and install
openssl:x64-linux 3.1.0#1 OpenSSL is an open source project that provides ...
paho-mqtt:x64-linux 1.3.10 Paho project provides open-source client impleme...
paho-mqttpp3:x64-linux 1.2.0#1 Paho project provides open-source C++ wrapper fo...
paho-mqttpp3[ssl]:x64-linux Build with SSL support
Then continue using the previous cmake script without uuid
Find_package (PahoMqttCpp CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC PahoMqttCpp::paho-mqttpp3-static )
The result was successful.
note: The version of the paho-mqttpp3 library in these tests is 1.2.0#1
The vcpkg
package is maintained by Microsoft. You should report the bug there if it is a vcpkg
problem.