-
Notifications
You must be signed in to change notification settings - Fork 458
LNK2001 error occurred after update version from V1.5.0 to V1.5.2 via vcpkg #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Crazy. The v1.5.2 was released, specifically to fix this, and by my tests, it did. I don't maintain the vcpkg, so am not sure what happened. I can try to investigate. |
I'm having the same issue with the latest release, 1.5.3, and strangely it doesn't seem to have this compilation error on the mac |
I had this issue and was able to fix the unresolved external by defining PAHO_MQTTPP_IMPORTS in my project which consumes the Paho C++ library. |
🤦♂ I guess I should RTFM. (The one I wrote)
|
I hate that this is required. I really don't like how Windows works with symbols in DLLs, but after 30yrs, I really need to stop complaining about it. I had worked around it a while back, but then that broke another compiler. I'l look to see if I can satisfy both with some conditional compilation. @Masterlovsky, this isn't strange. This is Windows. It links just fine on Linux and Mac. |
I think in the file export.h the definition of PAHO_MQTTPP_EXPORT should be simplified to this: Whenever I create a shared DLL I do it in a similar way. The project which creates the DLL should have PAHO_MQTTPP_EXPORTS defined which will make the symbol exported. In every other project (consumer of the DLL) where PAHO_MQTTPP_EXPORTS is not defined will automatically go into the else branch and will import the symbol from the DLL. I actually don’t know which use case is the last option (where PAHO_MQTTPP_EXPORT will be empty) in the original code meant for. We need either export (creation of the DLL) or import (use of the DLL) the symbol and nothing else in between. |
Well... for every other platform that isn't Windows! |
But I mean the one which is inside the #if defined(_WIN32) block. I think that there is no use case for it on Windows (I don't know other platforms). |
I think defining PAHO_MQTTPP_EXPORT only on the Windows platform is sufficient, while on other platforms it can be defined as empty. It can be written similarly to the following code:: |
Couple questions...
And, yes, my previous comment was incomplete. The empty |
I don't understand why dynamic libraries cannot use export symbols? I used the paho library before and all depend on dynamic libraries. |
Yes, previously the constant that it is complaining about was a static inside a function, but that cause a crash when using the clang compiler, so I moved it into the file scope, and now that's causing linker errors for Windows. It's infuriating since either way should be valid C++ and yet the different compilers and platforms can't agree how to handle it. |
I have a question about this update.
After I installed paho-mqttpp3@1.5.2 via vcpkg, When building using libraries installed in VS, the following error occurs.
unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits,class std::allocator > const mqtt::message::EMPTY_STR" (?EMPTY_STR@message@mqtt@@0V?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@b)
I had checked EMPTY_STR exist in massages.cpp/massages.h.
How do I fix it?
The text was updated successfully, but these errors were encountered: