Build zeromq on Windows 10 with CMake
Asked Answered
E

2

6

In the past I’ve used the Visual Studio solution files to build zeromq (libzmq) on Windows. I just noticed that the Visual Studio solutions have been deprecated because they are too difficult to maintain.

The alternative is to use CMake; trouble is I’ve no experience of how to invoke the build this way. Is anyone please able to demonstrate the necessary commands, step-by-step?

I’d like to achieve 32 & 64bit libzmq binaries using libsodium and compiled with VS2015 on Windows 10. (I’ve installed CMake 64bit and allowed it to add to the system path at installation.)

Thanks

Exurbia answered 28/8, 2018 at 11:17 Comment(4)
Have you consult INSTALL file of the project? Its "Windows Builds" section describes building the project for VS2015 on Windows 10.Ingrowing
I did see that but it is not clear enough to get me started. Never used CMake before, do I use the GUI or on the command line? How do I specify to build 32/64bit, use libsodium etc.Exurbia
The command cmake -H ... is for command line. But you may build the project from CMake GUI, its general usage is described in many places (in short: 1. Select source and build directories. 2. Select proper generator. 3. Press "Configure". 4. Possibly adjust options and press "Configure" again). Selecting between 32 and 64bit libraries is achieved by using proper generator, "Visual Studio 14 2015" or "Visual Studio 14 2015 Win64".Ingrowing
As for using libsodium, It should be described somewhere in the project's documentation. In CMakeLists.txt I have found line option (WITH_LIBSODIUM "Use libsodium instead of built-in tweetnacl" OFF) which is probably what do you want: in CMake GUI you need to check "WITH_LIBSODIUM" option.Ingrowing
E
8

So eventually I managed to build zeromq on Windows 10 from source using CMake.

CMake is used to set the various zeromq project options; in this case to use the libsodium library for cryptography and to provide the necessary include & linker paths for the build. Once the options are configured CMake is used to generate a Visual Studio solution from which to build the libzmq binaries.

Briefly this is how I did it using the CMake GUI:

  1. Specify to where the libzmq source code was cloned and tell CMake where to build the binaries. Hint; make a separate folder for each Visual Studio version & 32/64bit as necessary, see screenshot below.

  2. Click Configure to load the project options. From the pop up window choose the compiler you wish to use from the list. Set the necessary project options and click Configure again.

  3. If all is well click Generate to create the Visual Studio files.

  4. Click Open Project; once loaded in Visual Studio choose Debug/Release as you need and click Build Solution.

  5. Repeat the process for other architectures eg. choose the 32bit compiler as you require. Remember to adjust build output location & libsodium linker path to reflect that architecture.

Screenshot: Cmake screenshot

Exurbia answered 5/9, 2018 at 11:34 Comment(1)
I upvoted this answer because it reflects what I also did to build the library. However, I had to disable libsodium and TLS because I was not able to install those packages in such a way they were found by cmake. More in depth explanations on this point would be appreciated.Cuesta
G
2
  1. VS2015 Toolbar -> Open -> CMake -> ZMQ folder

  2. Toolbar -> CMake -> Cache -> Generate -> ZeroMQ

  3. Toolbar -> CMake -> Install -> ZeroMQ

You can find builds in /Users/UserName/CMakeBuilds/...

Galinagalindo answered 8/3, 2019 at 13:10 Comment(3)
Tried this, but Visual Studio 2017's CMake parsing doesn't appear to be up to the task. Switched to standalone CMake installer and generated a vs2017 sln, per the answer below, and it worked.Chefoo
Me too. I tried using Visual Studio 2019. When you create new project via git clone within Visual Studio, it immediately opens up Visual Studio's CMake program. CMake Error: failed with: ninja: error: build.ninja:1253: multiple rules generate precompiled.hpp [-w dupbuild=err] and CMake Generate step failed. Build files cannot be regenerated correctly. But it is nice to know CMake is built in there.. thx.Morena
In case it helps anyone - the following is in the CMakeLists.txt for zmq "The problem is, both libzmq-static libzmq try to use/generate # precompiled.pch at the same time Add a dependency, so they run in order and so they dont get in each others way TODO # still generates warning "build\x64-Debug\ninja : warning : multiple rules generate precompiled.hpp. builds involving # this target will not be correct; continuing anyway [-w dupbuild=warn]" And i was able to get around it by hacking around in the file a bit to remove references to BUILD_STATIC so that there wasn't a conflictAyer

© 2022 - 2024 — McMap. All rights reserved.