I'm trying to build paho_mqtt.c
on Windows X86 (64-bit). I'm using Visual Studio Community 2013. Its a supported configuration.
To build paho_mqtt.c
for 64-bit, one needs OpenSSL compiled for Windows 64-bit. To build OpenSSL I found I needed a new version of Active Perl. I then used the following commands to build OpenSSL:
- perl Configure -no-asm VC-WIN64A
- nmake
- nmake test
All the tests worked so I have believe I have working SSL/TLS libraries.
When building MQTT paho it couldn't find the ssl.h
. I used the trick on this page listed below to set the environment variables so msbuild would get the include path from the environment variables:
Adding additional library and include paths when compiling from command line
That worked and paho found ssl.h.
Next msbuild of paho.mqtt.c could not find libeay32 / ssleay32.dll. First I used the trick from above again so msbuild would search the correct directory for the openssl libraries. Although the new libraries work, the library names are different. I used the information in 2) on Compiling OpenSSL for Windows, Linux, and Macintosh and I did the following:
cp libssl.lib libeay32.lib
cp libcrypto.lib ssleay32.lib
This is questionable I know, but it appears to have worked; that is, the link command that was failing now runs without warning or error. But it might have just deferred any unresolved symbol problems until later.
msbuild is failing later when trying to link an executable (shown at the bottom of this post). msbuild is complaining it cannot resolve the MQTTClient_* funcitons/symbols (e.g. MQTTClient_connect). Those functions are all in MQTTClient.c, and msbuild built MQTTClient.obj without emitting any errors.
My questions revolve around "what is the real problem?":
- Is the problem with MQTTClient.obj:
- maybe it is not included in the link command?
- or maybe the symbols are not in the object file?
- Is the problem that I renamed the libraries?
msbuild is not reporting that it cannot find the MQTTClient.obj. If the problem is with the openssl libraries I expect it would report some openssl symbols are not found.
On linux I would use nm -g to see whether the undefined symbols are in the MQTT_Client.obj. How do I verify this in Windows?
Thanks for any help you can provide,
Link:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\don\paho.mqtt.c\Windows Build\x64\Release\paho-cs-pub.exe" /INCREMENTAL:NO /NOLOGO /LIBPA
TH:"C:\Users\don\paho.mqtt.c\Windows Build\\x64\Release" "paho-mqtt3a.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc3
2.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\don\paho.mqtt.c\Windows Build\x64\Release\paho-cs-pub.pdb" /SUBSYSTEM:CONSOLE /O
PT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:\Users\don\paho.mqtt.c\Windows Build\x64\Release\paho-cs-pub.lib" /MACHINE:X64 x64\Release\paho_cs_pub.obj
paho_cs_pub.obj : error LNK2001: unresolved external symbol MQTTClient_create [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]
paho_cs_pub.obj : error LNK2001: unresolved external symbol MQTTClient_yield [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]
paho_cs_pub.obj : error LNK2001: unresolved external symbol MQTTClient_setCallbacks [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]
paho_cs_pub.obj : error LNK2001: unresolved external symbol MQTTClient_disconnect [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]
paho_cs_pub.obj : error LNK2001: unresolved external symbol MQTTClient_publish [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]
paho_cs_pub.obj : error LNK2001: unresolved external symbol MQTTClient_destroy [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]
paho_cs_pub.obj : error LNK2001: unresolved external symbol MQTTClient_connect [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]
C:\Users\don\paho.mqtt.c\Windows Build\x64\Release\paho-cs-pub.exe : fatal error LNK1120: 7 unresolved externals [C:\Users\don\paho.mqtt.c\Windows Build\stdoutsuba\stdoutsuba.vcxproj]