ZMQ Setup for Qt Dev on Windows

Aug 11, 2018 | C++, Programming, Qt, Windows

Currently, I am working on a project that is a Qt application targeting modern Linux desktop distributions and Windows. The application needs to communicate with some onboard hardware via ZMQ. Normally in a Windows only .Net environment, I’d use NetMQ and C# and be off the the races, but that just wasn’t an option here — partially because I want to work on Linux and partially because Linux-based systems are becoming increasingly common in the aerospace field. The requirement to run cross-platform lead me through a long period of evaluating different technical stacks including Qt. Ultimately, I went with Qt and things were going great. On my Pop!_OS (read Ubuntu) Linux development machine installing ZMQ was just an `apt install` and `make`
away. Windows was another story.
Here’s the unfortunate but obviously reality — Windows is not a POSIX compliant operating system. For better or worse Windows is its own beautiful little snowflake, complete with DLLs. As you might get it was those DLLs that caused all the mischief here. I started as any naive developer using Windows might by finding an MSI for ZMQ and going to town with that. After integrated the generated .lib and DLL, I was getting this error at run-time only.

After days of seeing this it became something out of Poe, a telltale error dialog. I know that the most likely cause of this error appearing at run-time and not being caught by the compiler was that it must have been an error reading into a DLL and since I only had one external dependency at the time I knew the culprit had to be libzmq.

Though it took me a day or so to figure it out I finally found a good way to install ZMQ correctly so that it can be used for Qt / C++ development. The first step is to clone the git repo for VCPKG in PowerShell: `git clone https://github.com/Microsoft/vcpkg.git`. From the `cd` into the vcpkg directory and run these commands in order:


.\bootstrap-vcpkg.bat

.\vcpkg integrate install
.\vcpkg install zeromq:x64-windows
.\vcpkg integrate install

From there you can either link to the DLL and pull in the .lib the DLL. They will be somewhere like: `C:\\Users\vcpkg\installed\x64-windows\debug\bin\libzmq-mt-gd-4_3_1.dll` and the .lib will be in the same root but under the lib or include directory next to the bin directory listed above. From there you’ll need to clean and rebuild your project on QtCreator, then debug it. If you have your paths correct, then you’ll be ready to send messages over ZMQ with the best of them.

I hope this helps! Let me know what you think on Twitter and do reach out to me at The Mad Botter if you have any software development needs.

More from Mike:

About Me

Hi! I’m Mike! I’m a software engineer who codes at The Mad Botter INC. You might know me from Coder Radio or The Mike Dominick Show.  Drop me a line if you’re interested in having some custom mobile or web development done.

Follow Me

© 2024 Copyright Michael Dominick | All rights reserved