Mosquitto Build Notes (Windows Visual Studio) Sept 14 2018 - bapowell/bapowell.github.io GitHub Wiki
Build Mosquitto x64 (with websockets) on Windows - Visual Studio
Install prerequisite software
Used Visual Studio 2017
Download and unzip cmake.
Download and install Win64 OpenSSL.
- https://slproweb.com/products/Win32OpenSSL.html
- Tested with Win64OpenSSL-1_1_0i
- Installed to c:\Temp\OpenSSL-Win64\
libwebsockets
Download Windows binary build of libwebsockets.
- https://github.com/warmcat/libwebsockets
- Section: "Windows binary builds"
- Tested with lws-x64-18706490.zip
- Extracted to c:\Temp\libwebsockets-x64-18706490\
Download libuv source.
- https://github.com/libuv/libuv/releases
- Tested with libuv-1.23.0.zip
- Extracted to c:\Temp\libuv-1.23.0\
Build Mosquitto
Download and extract the Mosquitto source code.
- https://mosquitto.org/download/
- Tested with mosquitto-1.5.1.tar.gz
- Extracted to c:\Temp\mosquitto-1.5.1-src\
Create folder for the build
- C:\Temp\mosquitto-1.5.1-src\build\
Use cmake-gui to generate the Visual Studio project solution.
- Should be generated to c:\Temp\mosquitto-1.5.1-src\build\
- See this link to find out the version number corresponding to your Visual Studio edition: http://superuser.com/a/194065
- Generator used: "Visual Studio 15 2017 Win64" (note: Win64)
- After Configure step, errors indicated couldn't find OpenSSL-related items:
- Added OPENSSL_ROOT_DIR, pointed to c:\Temp\OpenSSL-Win64\
- Checked the WITH_WEBSOCKETS option.
- Unchecked the STATIC_WEBSOCKETS option (could not get build to work with the static websockets lib).
- Made sure WITH_THREADING was unchecked.
- Changed CMAKE_INSTALL_PREFIX to c:\Temp\mosquitto-install
- Configure again.
- Generate.
Open and build solution in Visual Studio.
- C:\Temp\mosquitto-1.5.1-src\build\mosquitto.sln
- Include directory paths for libwebsockets (and libuv):
- Right-click "mosquitto" project in Solution Explorer --> Properties --> VC++ Directories -->
- Include Directories --> (add paths) ... :
- C:\Temp\libwebsockets-x64-18706490\include (for libwebsockets.h, lws_config.h, ...)
- C:\Temp\libuv-1.23.0\include (for uv.h, ...)
- Library Directories --> (add paths) ... :
- C:\Temp\libwebsockets-x64-18706490\lib\Release (for websockets.lib)
- Include Directories --> (add paths) ... :
- Right-click "mosquitto" project in Solution Explorer --> Properties --> VC++ Directories -->
- Before building, in Visual Studio menu bar select "Release" and "x64".
- Build solution.
- Executables and libraries are in:
- C:\Temp\mosquitto-1.5.1-src\build\src\Release (mosquitto.exe, mosquitto_passwd.exe)
- C:\Temp\mosquitto-1.5.1-src\build\client\Release (mosquitto_pub.exe, mosquitto_sub.exe)
- C:\Temp\mosquitto-1.5.1-src\build\lib\Release (mosquitto.dll, mosquitto.lib)
- Build the INSTALL project (within the solution), to install to the CMAKE_INSTALL_PREFIX folder that was specified in cmake (e.g. c:\Temp\mosquitto-install).
Test
Before running:
- Copy the following dll files to C:\Temp\mosquitto-1.5.1-src\build\src\Release (and/or C:\Temp\mosquitto-install) :
- C:\Temp\OpenSSL-Win64\bin\libcrypto-1_1-x64.dll
- C:\Temp\OpenSSL-Win64\bin\libssl-1_1-x64.dll
- C:\Temp\libwebsockets-x64-18706490\bin\Release\websockets.dll
- C:\Temp\libwebsockets-x64-18706490\bin\Release\libuv.dll
- The following files need to come from an earlier version of OpenSSL (e.g. 1.0.2):
- C:\Temp\OpenSSL-Win32\bin\libeay32.dll
- C:\Temp\OpenSSL-Win32\bin\ssleay32.dll
Run
C:\Temp\mosquitto-1.5.1-src\build\src\Release\mosquitto.exe -v -c {config file}
or
C:\Temp\mosquitto-install\mosquitto.exe -v -c {config file}