eclipse / paho.mqtt.cpp

Other
1.01k stars 432 forks source link

Build errors in Visual Studio 2022 #490

Closed Wolfgg73 closed 3 months ago

Wolfgg73 commented 5 months ago

In the recent months, I finished a series of programs, all based on the PAHO MQTT CPP package. They all worked in Debug mode, very well. When I finally started to build the release versions, I received a series of Linker errors. There were several posts about the issues. My understanding was that I made a mistake just at the beginning of the project.

So I decided to start from scratch and re-cloned the C and C++ codes. I started the cross-compiling process. After several tries and re-tries (and reading), I ended up twice with created builds without error messages. However, when using them, I always end up now with the following errors - in debug and release mode. I have the feeling going in circles. Looking for nudges. ;-) . I would also appreciate paying for a virtual meeting session with an experienced software developer, helping me out here.

Configuration: Visual Studio 2022, CMakeGUI.

Rebuild started at 14:51... 1>------ Rebuild All started: Project: ml4TwinCrossCompiled, Configuration: Debug x64 ------ 1>ml4TwinCrossCompiled.cpp 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_closesocket referenced in function Socket_close_only 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_connect referenced in function Socket_new 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_ioctlsocket referenced in function Socket_setnonblocking 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_getpeername referenced in function Socket_getpeer 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_htons referenced in function Socket_new 1>paho-mqtt3a-static.lib(WebSocket.obj) : error LNK2001: unresolved external symbol __imp_htons 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_recv referenced in function Socket_getch 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol __imp_shutdown referenced in function Socket_close_only 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_socket referenced in function Socket_new 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_WSAStartup referenced in function Socket_outInitialize 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_WSACleanup referenced in function Socket_outTerminate 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_WSAGetLastError referenced in function Socket_error 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_WSASend referenced in function Socket_writev 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_WSAAddressToStringW referenced in function Socket_getaddrname 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_WSAPoll referenced in function Socket_getReadySocket 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_getaddrinfo referenced in function Socket_new 1>paho-mqtt3a-static.lib(Socket.obj) : error LNK2019: unresolved external symbol imp_freeaddrinfo referenced in function Socket_new 1>paho-mqtt3a-static.lib(MQTTAsyncUtils.obj) : error LNK2019: unresolved external symbol imp_getsockopt referenced in function MQTTAsync_connecting 1>paho-mqtt3a-static.lib(WebSocket.obj) : error LNK2019: unresolved external symbol __imp_ntohs referenced in function WebSocket_receiveFrame 1>E:\menschlicht\Repos\ml4TwinCrossCompiled\x64\Debug\ml4TwinCrossCompiled.exe : fatal error LNK1120: 18 unresolved externals 1>Done building project "ml4TwinCrossCompiled.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== ========== Rebuild completed at 14:52 and took 01.402 seconds ==========

Wolfgg73 commented 5 months ago

Sorted. Did not create myself debug and release versions cmake --build build/ --target install --config Debug cmake --build build/ --target install --config Release

Wolfgg73 commented 5 months ago

And added #pragma comment(lib, "Ws2_32.lib")

fpagliughi commented 3 months ago

The transient dependency for ws2_32.lib should now be fixed in master, coming to the v1.4 release. Lat me know if there is still an issue with the latest code.

fpagliughi commented 3 months ago

I believe this is fixed. If not, please re-open.