Comments (9)
Did you try to build any executables (like the samples) after you did this? I'm getting a .lib file (although it's only 32kB) and getting all sorts of errors and warnings now.
from paho.mqtt.cpp.
If you ask for a static build, does it still try to build the DLL?
from paho.mqtt.cpp.
According to this Stackoverflow's question, the paho-mqttpp3.lib is not created because there are no symbols exported. Then, I used the DLLExport
macro from Paho MQTT C to test:
class DLLExport async_client : public virtual iasync_client
{
// ...
};
And it forces the Visual Studio to create the paho-mqttpp3.lib:
C:\Temp\paho.mqtt.cpp\build_cmake>dir src
Volume in drive C is OSDisk
Volume Serial Number is C2D6-0DCE
Directory of C:\Temp\paho.mqtt.cpp\build_cmake\src
06/01/2017 11:54 AM <DIR> .
06/01/2017 11:54 AM <DIR> ..
06/01/2017 11:54 AM <DIR> CMakeFiles
05/31/2017 06:23 PM 1,449 cmake_install.cmake
05/31/2017 06:23 PM 25,405 Makefile
06/01/2017 11:54 AM <DIR> mqtt
05/31/2017 06:24 PM 639,488 paho-mqttpp3.dll
05/31/2017 06:24 PM 381 paho-mqttpp3.dll.manifest
05/31/2017 06:24 PM 94,568 paho-mqttpp3.exp
05/31/2017 06:24 PM 156,904 paho-mqttpp3.lib
6 File(s) 918,195 bytes
4 Dir(s) 809,452,789,760 bytes free
from paho.mqtt.cpp.
I guess the DLLExport
is required in every class/symbol the samples (or other binary) will use. Otherwise, you will get a lot of "undefined reference" errors. Also, I'm struggling with other errors, like library paths and machine architecture mismatch. The things get complicated because I don't have too much experience with NMake.
from paho.mqtt.cpp.
I went through and tried adding it to all the classes, but then started having errors from static data, so then tried to figure that out.
I also got lots and lots of C4251 warnings. This seems to be mostly (if not all) from things that Microsoft tells you to ignore, but I can't really be sure if they are all safe to ignore without reading through each and every of them, and I don't really feel like doing that!
What's worrisome, though, is a couple of issues raised by the documentation for the warning:
https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k(C4251);k(vs.output)&rd=true
- No inlined methods of your class can modify static data.
- No inlined methods of your class use CRT functions or other library functions use static data
I don't know if I can make this promise, or that I can remember it in the future!
By this, I would claim that Windows DLL's are not fully compliant with C++11, and that is the one thing I have tried to stick with, and require, in this library.
So, basically, if the static library CMake build works for Windows, I am content that release 1.0 doesn't support DLL's. Then we can make an issue to be addressed in the next release, if ever.
from paho.mqtt.cpp.
Can we use CMake to just build a static .lib file on Windows?
from paho.mqtt.cpp.
So, basically, if the static library CMake build works for Windows,
@fpagliughi yes, it works. Clients can link against the paho-mqttpp3-static.lib instead of the pair paho-mqttpp3.lib / paho-mqttpp3.dll.
I am content that release 1.0 doesn't support DLL's.
We must state somewhere (documentation? enforce through the CMakeLists.txt?) that the current version does not support DLLs.
Then we can make an issue to be addressed in the next release, if ever.
Perfect.
Can we use CMake to just build a static .lib file on Windows?
Yes, it already does. If the option PAHO_BUILD_STATIC
is enabled , the compilation produces the paho-mqttpp3-static.lib file.
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX="C:\Temp\paho-cpp" -DPAHO_MQTT_C_PATH="C:\Temp\paho-c" -DPAHO_WITH_SSL=FALSE -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_STATIC=TRUE -DGTEST_PATH="C:\Temp\GTest" -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=TRUE ..
from paho.mqtt.cpp.
If you ask for a static build, does it still try to build the DLL?
Yes, @fpagliughi. Currently, the static library creation is optional, the DLL is mandatory.
from paho.mqtt.cpp.
Fixed in the 'develop' branch. Windows can now build static and shared lib.
from paho.mqtt.cpp.
Related Issues (20)
- MQTT traffic over Https Proxy HOT 1
- MQTTAsync_send cpu load increases a lot while buffering messages HOT 2
- Subscribe to broker creates a random queue HOT 2
- Arm cross compile fails on version 1.3.x - disconnect options HOT 1
- SESSION_EXPIRY_INTERVAL is int, not uint HOT 7
- token->wait() hangs when publishing from 2 threads HOT 4
- Build error on Windows 11 - Visual Studio community 2022 - Cmake 3.29.6 HOT 8
- Can not run subscription!Info:0x00007FFB16EFCF19 处(位于 mqtt_install_test_vs.exe 中)有未经处理的异常: Microsoft C++ 异常: std::bad_alloc,位于内存位置 0x000000B68D9AE370 处。 HOT 3
- Running unit tests in GitHub CI Action on Windows
- Generated docs are empty HOT 2
- Confusion with oudated installation instructions - can't find paho-mqtt3a HOT 14
- msg->get_properties() not working in message_arrived HOT 4
- Paho sync client ssl return "Error: MQTT error [-13]: SSL is not supported [0]" HOT 12
- Is there a need to resubscribe to topics in async client clean_session(false) when disconnect event [-3] occurs. HOT 2
- paho-mqtt3a-static not found(does not already exist) HOT 2
- async_client does not use MQTTAsync_connect5 when connecting to MQTT brokers with protocol version 5 HOT 2
- 如何设置本地指定的ip 和 服务端建立连接 HOT 2
- Do you know which interface to call to set the specified network ip HOT 1
- mqtt\ssl_options.h(470): error C2062: type 'auto' unexpected HOT 7
- can't use get method in properties because of missing const HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paho.mqtt.cpp.