paho.mqtt.c icon indicating copy to clipboard operation
paho.mqtt.c copied to clipboard

Libraries having "-static" prefix are compiled with "Multi-treaded DLL" option on Windows

Open Alexk12 opened this issue 1 year ago • 3 comments

Describe the bug Libraries having "-static" prefix are compiled with "Multi-treaded DLL" and "Multi-treaded Debug DLL" option on Windows.

This actually means "Dynamic" libraries requiring run-time DLLs. Not static.

As a result, it is impossible to link a C++ project compiled with /MT or /MTd options with Paho C library (paho-mqtt3as-static.lib).

Alexk12 avatar Jul 07 '23 12:07 Alexk12

Are you building the library yourself? If so, how are you doing it - with CMake? What options?

icraggs avatar Jul 12 '23 11:07 icraggs

Are you building the library yourself? If so, how are you doing it - with CMake? What options?

Building Paho C:

call vc_env.bat cd .\paho.mqtt.c cmake -G "Visual Studio 16 2019" -A x64 -Bbuild -H. -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_SHARED=FALSE -DPAHO_BUILD_STATIC=TRUE -DCMAKE_INSTALL_PREFIX=C:\mqtt\paho-c -DLIB_EAY_DEBUG=C:/OpenSSL/lib/VC/static/libcrypto64MTd.lib -DLIB_EAY_RELEASE=C:/OpenSSL/lib/VC/static/libcrypto64MT.lib -DSSL_EAY_DEBUG=C:/OpenSSL/lib/VC/static/libssl64MTd.lib -DSSL_EAY_RELEASE=C:/OpenSSL/lib/VC/static/libssl64MT.lib cmake --build build/ --target install cd ..

Resulting "Eclipse Paho C.sln" includes project for Paho C static library, this project uses "Multi-theaded Debug DLL" option instead of "Multi-theaded Debug" and "Multi-theaded DLL" option instead of "Multi-theaded".

Building Paho CPP:

call vc_env.bat cd .\paho.mqtt.cpp cmake -G "Visual Studio 16 2019" -A x64 -Bbuild -H. -DPAHO_WITH_SSL=ON -DCMAKE_PREFIX_PATH=C:\mqtt\paho-c cd ..

OS: Windows Versions: Microsoft Visual Studio Community 2019 Version 16.11.27 cmake version 3.20.21032501-MSVC_2 paho.mqtt.c 1.3.12 paho.mqtt.cpp 1.2.0

Alexk12 avatar Jul 12 '23 14:07 Alexk12

Ok, I thought I knew what to do but now I'm not sure. I don't think the CMake config sets the build options except to identifty the libraries as static in the add_library CMake command.

icraggs avatar Oct 12 '23 10:10 icraggs