Closed fgrz closed 2 months ago
Same happened using vcpkg under windows. Got exactly the same linker errors.
Using the overloaded
mqtt::make_message (string_ref topic, const void *payload, size_t len, int qos, bool retained)
function did the trick for me without changing the paho code.
I'm having the same issue. Currently resolved with suggestion from @swenp76 .
I also experienced the same issue and the suggestion from @swenp76 solved it. Thanks.
I think this tracks to some poorly-thought-out overloads that can collide and cause trouble on different compilers and platforms with different word sizes. There's a related issue from a few months back that was tracked back to the same problem. I will link to it if I find it.
There are a few old tickets regarding some of these problems and similar build issues on Windows. They were caused by several different issues, particularly that CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
does not export all symbols (news to me), and also that there was a change between how C++11 and C++17 handle static class constants. So there was a problem linking an app built for C++17 against the library built for C++11. Clang and gcc on Linux were more forgiving, but MSVC gave link errors.
I believe the export issues are solved in v1.4.0. That should fix the linker issues, regardless of the language version, but the upcoming v1.5 will also move the library to C++17, and further reduce any problems. In that version, the class static constants will also become constexpr
whenever possible.
If anyone is still having issues wit this using v1.4.0, please let me know and I will try to get it fixed before the v1.4.1 and v1.5.0 releases.
Hi
In our project we used v1.2.0 so far. I now wanted to update to v1.3.2 because we want to use websockets (wss://...) but the project does no longer compile with the new built libs: Severity Code Description Project File Line Suppression State Details Error LNK2001 unresolved external symbol "public: static int const mqtt::message::DFLT_QOS" (?DFLT_QOS@message@mqtt@@2HB) CutCenter C:\git\zcc\CutCenter\Mqtt.lib(MqttAsyncPublisher.obj) 1
Error LNK2001 unresolved external symbol "public: static bool const mqtt::message::DFLT_RETAINED" (?DFLT_RETAINED@message@mqtt@@2_NB) CutCenter C:\git\zcc\CutCenter\Mqtt.lib(MqttAsyncPublisher.obj) 1
The libs are built with a powershell-script (cmake is from VS 2022):
The include in our project is done like this:
The code stops compiling when using this line in our code:
When I modify message.h/message.cpp so DFLT_QOS and DFLT_RETAINED are initialized in the header-file, it works too - but we idealy do not want to change the paho mqtt-source before compile it:
Any ideas what I can do so the code compiles without change the paho mqtt-code?
Thanks!