0

I am using the mosquitto library in my Qt-Widget-Application under Linux with success. I wanted to do the same for Windows 7 MSVC2015 x64 but I am getting linker errors which I don't understand.

Using this snippet in my .pro-file where C:\mosquitto is the path to the downloaded and precompiled lib (.dll). The folder devel contains the headers and the .lib-files.

INCLUDEPATH += C:/mosquitto/devel DEPENDPATH += C:/mosquitto/devel LIBS += -LC:/mosquitto/devel -LC:/mosquitto -lmosquitto -lmosquittopp

I am getting linker errors to 14 unresolved symbols as if there were no libs at all. I can remove the line "LIBS" and will not get more unresolved symbols. If I misspell some paths or names in the LIBS-Variable I get the error that mosquitto.lib isn't found - so the paths are generally correct.

One hint could be the warning from the linker: library machine type 'X86' conflicts with target machine type 'x64'. So I compiled the library sources by hand in x64. After that the same appears with only one unresolved symbol. Why?

I don't get the clue. Under Linux it was relatively easy. Am I in trouble with 32/64bit? Or is there some other dependency that I missed?

Update: The unresolved symbol with the -hopefully correctly compiled- x64-version is public: virtual void __cdecl mosqpp::mosquittopp::on_message(struct mosqpp::mosquitto_message const *). At the moment I only open and publish to a MQTT-Connection: I am not using on_message(...) explicitly.

user2715068
  • 51
  • 1
  • 4
  • Post the single unresolved symbol error appearing when using x64 build of the library. – Dmitry Feb 13 '18 at 08:15
  • 1
    After studying github project. I see in [mosquito.hpp](https://github.com/iosphere/mosquitto/blob/master/lib/cpp/mosquittopp.h) several virtual function members are fully defined, between them `public: virtual void __cdecl mosqpp::mosquittopp::on_message(struct mosqpp::mosquitto_message const *)` and it is used inside cpp in line 44 in function member `on_message_wrapper`, so I think your problem is related with [this question](https://stackoverflow.com/questions/2898094/why-c-virtual-function-defined-in-header-may-not-be-compiled-and-linked-in-vta). – JTejedor Feb 13 '18 at 13:08

0 Answers0