Build and static link ZeroMQ on Windows

ZeroMQ ( http://zeromq.org and https://github.com/zeromq/libzmq ) is a library that allows code to communicate between threads, processes, or computers in just a few lines and uses simple, composable patterns (like publish-subscribe and broadcast).

In this post, we’ll build ZeroMQ on Windows as a static library (to take advantage of the “static linking exception” in its license: http://zeromq.org/area:licensing ) and then bake that static library into a simple Windows executable.  There are many posts around the web that show you how to do this … here’s one more:

Steps:

  1. Build Vcpkg ( https://github.com/Microsoft/vcpkg )
  2. Use vcpkg to build ZeroMQ ( vcpkg install zeromq:x64-windows-static )
  3. Build an executable that statically links ZeroMQ

Step 1: Build Vcpkg ( https://github.com/Microsoft/vcpkg )

Notes:

  • Vcpkg does not manage pre-built binaries (like NuGet or Homebrew)
  • Vcpkg manages source code and builds that source code on Windows, Linux, and MacOS.
  • At the time of this post, the documentation for Vcpkg was located here:
    https://docs.microsoft.com/en-us/cpp/vcpkg

In a Visual Studio 2017 developer command prompt (with Git installed), execute the following commands:

cd /d C:\
mkdir Repos
cd /d C:\Repos\
git clone https://github.com/Microsoft/vcpkg
cd /d C:\Repos\vcpkg\
bootstrap-vcpkg.bat

… now, C:\Repos\vcpkg\vcpkg.exe should exist.

Step 2: Use vcpkg to build ZeroMQ ( vcpkg install zeromq:x64-windows-static )

Note:

  • On purpose … to make things more explicit and more difficult in Step 3, we do not execute the following command:
vcpkg integrate install

Now that C:\Repos\vcpkg\vcpkg.exe exists, execute the following commands:

cd /d C:\Repos\vcpkg\
vcpkg install zeromq:x64-windows-static

… now, we should have the following:

  • ZeroMQ source code folder: C:\Repos\vcpkg\buildtrees\zeromq\src
  • ZeroMQ debug build folder: C:\Repos\vcpkg\buildtrees\zeromq\x64-windows-static-dbg
  • ZeroMQ release build folder: C:\Repos\vcpkg\buildtrees\zeromq\x64-windows-static-rel
  • ZeroMQ target folder: C:\Repos\vcpkg\packages\zeromq_x64-windows-static
  • ZeroMQ target include folder: C:\Repos\vcpkg\packages\zeromq_x64-windows-static\include
  • ZeroMQ target debug lib folder: C:\Repos\vcpkg\packages\zeromq_x64-windows-static\debug\lib
    • At the time of this post, the static library built was: libzmq-mt-sgd-4_3_1.lib
    • Note: The mt and d in libzmq-mt-sgd-4_3_1.lib means multi-threaded debug (requiring the debug executable in the next step to be compiled using /MTd)
  • ZeroMQ target release lib folder: C:\Repos\vcpkg\packages\zeromq_x64-windows-static\lib
    • At the time of this post, the static library built was: libzmq-mt-s-4_3_1.lib
    • Note: The mt in libzmq-mt-s-4_3_1.lib means multi-threaded (requiring the release executable in the next step to be compiled using /MT)

Step 3: Build an executable that statically links ZeroMQ

In Visual Studio 2017, do the following:

  • File / New / Project…

     

     
  • Add / New Item…

     
  • Paste the following code into Source.cpp:
    #include <zmq.h>
    #include <iostream>
     
    int main()
    {
    	int major = 0;
    	int minor = 0;
    	int patch = 0;
    	zmq_version( &major, &minor, &patch );
    	std::wcout << "Current 0MQ version is " << major << '.' << minor << '.' << patch << '\n';
    }
  • Change the Solution Platform to x64:

     
  • Select the “ZeroMQ-Version” project, select Project / Properties, change the Configuration to “All Configurations“, select Configuration Properties / C/C++ / General, and then add the following include folder to “Additional Include Directories“:
    C:\Repos\vcpkg\packages\zeromq_x64-windows-static\include

     

     
  • Next, for “All Configurations“, select Configuration Properties / C/C++ / Preprocessor, and then add the following preprocessor definition to “Preprocessor Definitions“:
    ZMQ_STATIC

     
  • Next, change the Configuration to “Debug“, select Configuration Properties / C/C++ / Code Generation, and then change the “Runtime Library” to “Multi-threaded Debug (/MTd)“:

     

     
  • Next, change the Configuration to “Release“, select Configuration Properties / C/C++ / Code Generation, and then change the “Runtime Library” to “Multi-threaded (/MT)“:

     

     
  • Next, we’ll add the static libraries … and while we could break these up into separate lib folder and lib file entries, I’ll just use each lib’s full file path here.
  • First, switch the Configuration back to “Debug“, select Configuration Properties / Linker / Input, and then add the following entries to “Additional Dependencies“:
    C:\Repos\vcpkg\packages\zeromq_x64-windows-static\debug\lib\libzmq-mt-sgd-4_3_1.lib
    Ws2_32.lib
    Iphlpapi.lib

     

     
  • Second, switch the Configuration back to “Release“, select Configuration Properties / Linker / Input, and then add the following entries to “Additional Dependencies“:
    C:\Repos\vcpkg\packages\zeromq_x64-windows-static\lib\libzmq-mt-s-4_3_1.lib
    Ws2_32.lib
    Iphlpapi.lib

     

     
  • Build / Rebuild Solution:

     
  • Debug / Start Without Debugging:

     


     

Note:

  • When building for Debug, my Output window reads:
    1>------ Rebuild All started: Project: ZeroMQ-Version, Configuration: Debug x64 ------
    1>Source.cpp
    1>ZeroMQ-Version.vcxproj -> C:\Repos\ZeroMQ-Version\x64\Debug\ZeroMQ-Version.exe
    ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  • When building for Release, my Output window reads:
    1>------ Rebuild All started: Project: ZeroMQ-Version, Configuration: Release x64 ------
    1>Source.cpp
    1>Generating code
    1>All 3752 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
    1>Finished generating code
    1>ZeroMQ-Version.vcxproj -> C:\Repos\ZeroMQ-Version\x64\Release\ZeroMQ-Version.exe
    ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Hope This Helps!

Tagged on: , ,

15 thoughts on “Build and static link ZeroMQ on Windows

  1. Joshua Burkholder

    ZeroMQ has the best layout of MSBuild files of any project I’ve seen to date. When you clone ZeroMQ, these MSBuild files are located under its builds/deprecated-msvc/ path. For Visual Studio 2017, the combination of the *.props file under the builds/deprecated-msvc/properties/ path and the files under the builds/deprecated-msvc/vs2017/ path contains the magic. Unfortunately, as the path indicates, these MSBuild files are currently deprecated. This is one reason why my instructions above utilized Vcpkg instead of ZeroMQ’s own MSBuild files. Another reason is that Vcpkg is currently essential technology for rapid application development in C++ … esp. for MSBuild-based projects. Ensure you take a look at Vcpkg’s ability to export *.h/*.hpp, *.lib, *.dll, and *.exe to a NuGet package that you can then import into your C++ MSBuild projects and your MSBuild-based build systems (like Azure DevOps / VSTS / VSO):

    vcpkg export package1:x64-windows ... packageN:x64-windows --nuget

    … or, in the case of this post:

    vcpkg export zeromq:x64-windows-static --nuget

    … and adding the following to the *.vcxproj file where you installed this NuGet package (since you’ve exported a x64-windows-static package):

    <PropertyGroup Label="Globals">
      <!-- Keep the stuff that was already in your "Globals" PropertyGroup here and then add the following: -->
      <VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
      <VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
    </PropertyGroup>

    … Note: You’ll still need to add the ZMQ_STATIC define, static link the C++ runtimes, and add the Ws2_32.lib and Iphlpapi.lib libraries to your C++ project, but you won’t need to add the ZeroMQ include path nor the ZeroMQ libraries (as the *.targets files inside that NuGet package you just installed hooked your C++ project up with all those entries).
    You can read more about vcpkg export here:

    https://blogs.msdn.microsoft.com/vcblog/2017/05/03/vcpkg-introducing-export-command/

    … and here:

    https://github.com/Microsoft/vcpkg/blob/master/docs/users/integration.md#export
  2. Cosma Cristian-Sebastian

    Hi there,
    this example you shown us is for c language…
    what should i do to get the correct c++ libraries?
    Thanks in advance.

    Best Regards Cris

    1. Joshua Burkholder Post author

      For portability reasons, the main interface for ZeroMQ is its C interface. Based on that C interface, bindings exists for various languages … including C++. Take note that a binding may bind a previous version of the C interface, not necessarily the current version of the C interface. Because most of C is a subset of C++, the C++ bindings are extremely trivial … so some people just create their own RAII wrappers around those C interfaces; however, ZeroMQ advertises the following C++ bindings:

      In addition to the ZeroMQ port, Vcpkg contains ports for the first two C++ bindings mentioned above:

      • cppzmq: vcpkg install cppzmq:x64-windows-static
      • azmq: vcpkg install azmq:x64-windows-static
  3. Surya Karmakar

    Do i need to do any other steps to use in my source files of different projects? I can’t get it to work with an empty project in VS. Also can i use this on other C++ compiler, like devC++ or codeBlocks?

    1. Joshua Burkholder Post author

      The output of Step 2 above is a Header file (zmq.h) and some Static Libraries (libzmq-mt-sgd-4_3_1.lib for Debug and libzmq-mt-s-4_3_1.lib for Release). These ZeroMQ Static Libraries depend on some Windows Import Libraries that are found in the Windows SDK (like Ws2_32.lib, Iphlpapi.lib, and some of the other common Import Libraries). The Header, Static Libraries, and Import Libraries are all you need to use ZeroMQ in any other project on Windows. Step 3 above is a simple example of this. Since we are using a Static Library, we should use the same version of the compiler/linker toolchain for both Steps 2 and 3.

      Sometimes things are clearer if we have another example to compare and contrast things against. In that vein, here’s one of several different ways to build and static link ZeroMQ on Windows using MinGW-w64 (the GCC compiler/linker toolchain on Windows) and CMake:

      1. Download and install MinGW-w64. Note: I’m using version x86_64-8.1.0-posix-seh-rt_v6-rev0.
      2. Download and install CMake. Note: I’m using version 3.13.2 via cmake-3.13.2-win64-x64.msi.
      3. Download the latest release of libzmq. Note: I’m using libzmq 4.3.0.
      4. From the Start menu, select MinGW-W64 project / Run terminal to launch a command prompt with all the MinGW-w64 environment variables set.
      5. From that MinGW-w64 Run terminal command prompt, execute "C:\Program Files\CMake\bin\cmake-gui.exe" to launch the CMake GUI with access to those same MinGW-w64 environment variables.
      6. Unzip the libzmq source code and create a build folder. Note: I unzipped my libzmq source code to C:\Repos\libzmq-4.3.0 and created the build folder C:\Repos\libzmq-4.3.0-build.
      7. In the CMake GUI, enter the source code folder, enter the build folder, press Configure, and specify the following generator for this project: MinGW Makefiles … ensuring that the Use default native compilers radio button is selected … and then press Finish.
      8. Once the initial configuration is complete and the usual red-highlights-indicating-new-changes are shown, press Configure again to keep the default entries and then press Generate.
      9. Back in the MinGW-w64 Run terminal command prompt, execute the following:
        cd /d C:\Repos\libzmq-4.3.0-build
        mingw32-make.exe
        

        … in order to kick off the build of ZeroMQ.

      10. Once the build completes, locate the following files of interest:
        • Header: C:\Repos\libzmq-4.3.0\include\zmq.h
        • Static Library: C:\Repos\libzmq-4.3.0-build\lib\libzmq.a
      11. Create a folder for a new project using the ZeroMQ bits we just built and copy the Source.cpp file from Step 3 above into that folder. Note: I created the following folder: C:\Repos\ZeroMQ-Version-MinGW containing C:\Repos\ZeroMQ-Version-MinGW\Source.cpp.
      12. In the MinGW-w64 Run terminal command prompt, execute the following:
        cd /d C:\Repos\ZeroMQ-Version-MinGW
        g++ -o ZeroMQ-Version-MinGW.exe Source.cpp -O3 -Wall -Wextra -Werror -IC:\Repos\libzmq-4.3.0\include -DZMQ_STATIC -static -LC:\Repos\libzmq-4.3.0-build\lib -lzmq -lWs2_32 -lIphlpapi
        ZeroMQ-Version-MinGW.exe
        

        … in order to build and run the ZeroMQ-Version-MinGW.exe executable.

      Note: Based on the choices I noted above, my output was:

      Current 0MQ version is 4.3.0
      

      Dev-C++ and Code::Blocks are both IDEs, not compiler/linker toolchains. Any IDE that wraps a compiler/linker toolchain with access to the Import Libraries from the Windows SDK will be good to go. If memory serves, both Dev-C++ and Code::Blocks wrap the MinGW toolchain … so if that’s still the case, you should be able to translate the MinGW-w64 steps above to the respective GUI-isms of those IDEs.

      Hope This Helps.

  4. Alfred Handke

    Hi there,
    Joshua, thank you for the great step-by-step guide. I have three more questions:
    1) Is ZeroMQ running stable on Windows 10?
    2) Will it be supported in the future?
    3) Is there a step-by-step guide for building and installing ZeroMQ as a dynamic library (with visual studio 2017)?
    Thank you in advance.

    Best regards
    Alfred

    1. Joshua Burkholder Post author

      For 1) ZeroMQ was running great on Windows 10 and Windows Server 2016 when I wrote the instructions above. I would check the latest issues ( https://github.com/zeromq/libzmq/issues ) and the ZeroMQ Community ( https://zeromq.org/our-community/ ) to make sure that current builds have remained good to go for Windows 10, Windows Server 2016, and Windows Server 2019. Per the Supported Platforms ( https://github.com/zeromq/libzmq/blob/master/README.md#zeromq ), ZeroMQ is only built and tested on Windows Server 2016 for x86 … so you’ll need to build and run tests in a separate Continuous Integration environment on Windows 10 for x64.

      For 2) ZeroMQ has been around for about a decade … and it’s been used by thousands of projects in multiple programming languages … so it’s not going away anytime soon; however, if you want to get a sense of where ZeroMQ is headed, I would ask the Community ( https://zeromq.org/our-community/ ).

      For 3) You’ll just need to drop the “-static” portion of the Vcpkg “triplet” to build ZeroMQ as a dynamic link library … and then create a regular C++ project that uses that dynamic link library:

      // In a Visual Studio 2017 Command Prompt, do the following:
      cd /d E:\Temp
      git clone https://github.com/Microsoft/vcpkg.git
      cd /d E:\Temp\vcpkg
      bootstrap-vcpkg.bat
      vcpkg install zeromq:x64-windows
      set PATH=E:\Temp\vcpkg\packages\zeromq_x64-windows\debug\bin;E:\Temp\vcpkg\packages\zeromq_x64-windows\bin;%PATH%
      devenv
      // Note: devenv ( above ) is just used to launch Visual Studio with the new PATH set above
      // so that the ZeroMQ DLLs can be found without having to copy those DLLs to a target folder
      // while building and debugging your executable using those DLLs in Visual Studio.

      … then the Release dynamic link library, program database, and import library are here:

      E:\Temp\vcpkg\packages\zeromq_x64-windows\bin\libzmq-mt-4_3_3.dll
      E:\Temp\vcpkg\packages\zeromq_x64-windows\bin\libzmq-mt-4_3_3.pdb
      E:\Temp\vcpkg\packages\zeromq_x64-windows\lib\libzmq-mt-4_3_3.lib

      … the Debug dynamic link library, program database, and import library are here:

      E:\Temp\vcpkg\packages\zeromq_x64-windows\debug\bin\libzmq-mt-gd-4_3_3.dll
      E:\Temp\vcpkg\packages\zeromq_x64-windows\debug\bin\libzmq-mt-gd-4_3_3.pdb
      E:\Temp\vcpkg\packages\zeromq_x64-windows\debug\lib\libzmq-mt-gd-4_3_3.lib

      … and the headers are here:

      E:\Temp\vcpkg\packages\zeromq_x64-windows\include\

      … such as:

      E:\Temp\vcpkg\packages\zeromq_x64-windows\include\zmq.h

      Note: I prefer using the “E:\Temp\vcpkg\packages\zeromq_x64-windows” folder over the “E:\Temp\vcpkg\installed\x64-windows” folder … but either will work.

      For information purposes, here’s the link to the ZeroMQ port for Vcpkg:
      https://github.com/microsoft/vcpkg/blob/master/ports/zeromq/CONTROL

      Hope This Helps,
      Joshua

  5. EVERETT C WILLIAMS

    This pretty much gave me a path forward after a few days of trying to get zeroMQ to work. I’m using Visual Studio 2019, Windows 10 (unfortunately) and zeroMQ 4.3.3. and was able to use this guide to set up sockets locally. Again, thanks so much for sharing.

  6. Zip Zit

    I concur with Everett Williams. I was totally able to get VisualStudio 2019, Win10 and zeroMQ / cppzmq to totally work with the work shared here. For anyone else using cppzmq, you just combine both includes (zmq and cppzmq) and use zmq libraries. I really wanted to verify that the VCPkg build was whole.

    Unfortunately for me, I’m hoping to push to Unreal Game engine (UE4), and there, the project property pages config tool is essentially locked out. I can add includes and libraries manually via third party plugins, but no go (so far) on changing C++ / Code Generation / Runtime Library setting. I’m still trying to understand how that system works.

    Joshua, I will say this posting was invaluable to aiding me in understanding what a successful run looks like in Windows. And this confirms the VCPKG build process is right. Again, many thanks for posting…

  7. Jaehyung Choi

    I am using Windows 10 and Visual Studio 2019. I followed your step-by-step guide, but at the very end, the build and the debug fails. I get an error message that says Cannot open source file “zmq.h”
    Any ideas on how to fix this? Thank you!

    1. Joshua Burkholder Post author

      In order to resolve this, I’d put the following in a batch script and execute ( see additional info below ):

      @echo off
      setlocal
      call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
      set REPOS_FOLDER=C:\Repos
      set VCPKG_FOLDER=%REPOS_FOLDER%\vcpkg
      set PROJECT=ZeroMQ-Version
      set PROJECT_FOLDER=%REPOS_FOLDER%\%PROJECT%
      set SOURCE=Source
      echo.
      echo Remove %VCPKG_FOLDER% and %PROJECT_FOLDER%.
      echo.
      rmdir /S /Q "%VCPKG_FOLDER%"
      rmdir /S /Q "%PROJECT_FOLDER%"
      echo.
      echo Build Vcpkg.
      echo.
      mkdir "%REPOS_FOLDER%"
      cd /d "%REPOS_FOLDER%"
      REM Checkout the following commit hash from June 5th, 2021:
      REM https://github.com/microsoft/vcpkg/commit/b2544fd780b2e9a05d903314cbbd37268ba43d81
      git clone --no-checkout https://github.com/Microsoft/vcpkg
      cd /d "%VCPKG_FOLDER%"
      git checkout b2544fd780b2e9a05d903314cbbd37268ba43d81
      REM To get the latest, comment out the three commands above and replace with just the following two commands:
      REM git clone https://github.com/Microsoft/vcpkg
      REM cd /d "%VCPKG_FOLDER%"
      call bootstrap-vcpkg.bat
      echo.
      echo Build ZeroMQ.
      echo.
      vcpkg install zeromq:x64-windows-static
      echo.
      echo Create %SOURCE%.cpp.
      echo.
      mkdir "%PROJECT_FOLDER%"
      cd /d "%PROJECT_FOLDER%"
      echo #include ^<zmq.h^>                                                                                           > "%SOURCE%.cpp"
      echo #include ^<iostream^>                                                                                       >> "%SOURCE%.cpp"
      echo.                                                                                                            >> "%SOURCE%.cpp"
      echo int main()                                                                                                  >> "%SOURCE%.cpp"
      echo {                                                                                                           >> "%SOURCE%.cpp"
      echo     int major = 0;                                                                                          >> "%SOURCE%.cpp"
      echo     int minor = 0;                                                                                          >> "%SOURCE%.cpp"
      echo     int patch = 0;                                                                                          >> "%SOURCE%.cpp"
      echo     zmq_version( ^&major, ^&minor, ^&patch );                                                               >> "%SOURCE%.cpp"
      echo     std::wcout ^<^< "Current 0MQ version is " ^<^< major ^<^< '.' ^<^< minor ^<^< '.' ^<^< patch ^<^< '\n'; >> "%SOURCE%.cpp"
      echo }                                                                                                           >> "%SOURCE%.cpp"
      echo.
      echo Compile %SOURCE%.cpp to x64\Debug\%SOURCE%.obj.
      echo.
      mkdir "%PROJECT_FOLDER%\x64\Debug"
      cd /d "%PROJECT_FOLDER%"
      cl.exe                                                            ^
          /c                                                            ^
          /I"%VCPKG_FOLDER%\packages\zeromq_x64-windows-static\include" ^
          /ZI                                                           ^
          /JMC                                                          ^
          /nologo                                                       ^
          /W3                                                           ^
          /WX-                                                          ^
          /diagnostics:column                                           ^
          /sdl                                                          ^
          /Od                                                           ^
          /D ZMQ_STATIC                                                 ^
          /D _DEBUG                                                     ^
          /D _CONSOLE                                                   ^
          /D _UNICODE                                                   ^
          /D UNICODE                                                    ^
          /Gm-                                                          ^
          /EHsc                                                         ^
          /RTC1                                                         ^
          /MTd                                                          ^
          /GS                                                           ^
          /fp:precise                                                   ^
          /permissive-                                                  ^
          /Zc:wchar_t                                                   ^
          /Zc:forScope                                                  ^
          /Zc:inline                                                    ^
          /Fo"x64\Debug\\"                                              ^
          /Fd"x64\Debug\vc142.pdb"                                      ^
          /external:env:EXTERNAL_INCLUDE                                ^
          /external:W3                                                  ^
          /Gd                                                           ^
          /TP                                                           ^
          /FC                                                           ^
          /errorReport:prompt                                           ^
          "%SOURCE%.cpp"
      echo.
      echo Link x64\Debug\%SOURCE%.obj to x64\Debug\%PROJECT%.exe.
      echo.
      cd /d "%PROJECT_FOLDER%"
      link.exe                                                                                  ^
          /ERRORREPORT:PROMPT                                                                   ^
          /OUT:"%PROJECT_FOLDER%\x64\Debug\%PROJECT%.exe"                                       ^
          /INCREMENTAL                                                                          ^
          /ILK:"x64\Debug\%PROJECT%.ilk"                                                        ^
          /NOLOGO                                                                               ^
          "%VCPKG_FOLDER%\packages\zeromq_x64-windows-static\debug\lib\libzmq-mt-sgd-4_3_4.lib" ^
          Ws2_32.lib                                                                            ^
          Iphlpapi.lib                                                                          ^
          kernel32.lib                                                                          ^
          user32.lib                                                                            ^
          gdi32.lib                                                                             ^
          winspool.lib                                                                          ^
          comdlg32.lib                                                                          ^
          advapi32.lib                                                                          ^
          shell32.lib                                                                           ^
          ole32.lib                                                                             ^
          oleaut32.lib                                                                          ^
          uuid.lib                                                                              ^
          odbc32.lib                                                                            ^
          odbccp32.lib                                                                          ^
          kernel32.lib                                                                          ^
          user32.lib                                                                            ^
          gdi32.lib                                                                             ^
          winspool.lib                                                                          ^
          comdlg32.lib                                                                          ^
          advapi32.lib                                                                          ^
          shell32.lib                                                                           ^
          ole32.lib                                                                             ^
          oleaut32.lib                                                                          ^
          uuid.lib                                                                              ^
          odbc32.lib                                                                            ^
          odbccp32.lib                                                                          ^
          /MANIFEST                                                                             ^
          /MANIFESTUAC:"level='asInvoker' uiAccess='false'"                                     ^
          /manifest:embed                                                                       ^
          /DEBUG                                                                                ^
          /PDB:"%PROJECT_FOLDER%\x64\Debug\%PROJECT%.pdb"                                       ^
          /SUBSYSTEM:CONSOLE                                                                    ^
          /TLBID:1                                                                              ^
          /DYNAMICBASE                                                                          ^
          /NXCOMPAT                                                                             ^
          /IMPLIB:"%PROJECT_FOLDER%\x64\Debug\%PROJECT%.lib"                                    ^
          /MACHINE:X64                                                                          ^
          "x64\Debug\%SOURCE%.obj"
      echo.
      echo Run x64\Debug\%PROJECT%.exe.
      echo.
      "%PROJECT_FOLDER%\x64\Debug\%PROJECT%.exe"
      echo.
      echo Compile %SOURCE%.cpp to x64\Release\%SOURCE%.obj.
      echo.
      mkdir "%PROJECT_FOLDER%\x64\Release"
      cd /d "%PROJECT_FOLDER%"
      cl.exe                                                            ^
          /c                                                            ^
          /I"%VCPKG_FOLDER%\packages\zeromq_x64-windows-static\include" ^
          /Zi                                                           ^
          /nologo                                                       ^
          /W3                                                           ^
          /WX-                                                          ^
          /diagnostics:column                                           ^
          /sdl                                                          ^
          /O2                                                           ^
          /Oi                                                           ^
          /GL                                                           ^
          /D ZMQ_STATIC                                                 ^
          /D NDEBUG                                                     ^
          /D _CONSOLE                                                   ^
          /D _UNICODE                                                   ^
          /D UNICODE                                                    ^
          /Gm-                                                          ^
          /EHsc                                                         ^
          /MT                                                           ^
          /GS                                                           ^
          /Gy                                                           ^
          /fp:precise                                                   ^
          /permissive-                                                  ^
          /Zc:wchar_t                                                   ^
          /Zc:forScope                                                  ^
          /Zc:inline                                                    ^
          /Fo"x64\Release\\"                                            ^
          /Fd"x64\Release\vc142.pdb"                                    ^
          /external:env:EXTERNAL_INCLUDE                                ^
          /external:W3                                                  ^
          /Gd                                                           ^
          /TP                                                           ^
          /FC                                                           ^
          /errorReport:prompt                                           ^
          "%SOURCE%.cpp"
      echo.
      echo Link x64\Release\%SOURCE%.obj to x64\Release\%PROJECT%.exe.
      echo.
      cd /d "%PROJECT_FOLDER%"
      link.exe                                                                          ^
          /ERRORREPORT:PROMPT                                                           ^
          /OUT:"%PROJECT_FOLDER%\x64\Release\%PROJECT%.exe"                             ^
          /INCREMENTAL:NO                                                               ^
          /NOLOGO                                                                       ^
          "%VCPKG_FOLDER%\packages\zeromq_x64-windows-static\lib\libzmq-mt-s-4_3_4.lib" ^
          Ws2_32.lib                                                                    ^
          Iphlpapi.lib                                                                  ^
          kernel32.lib                                                                  ^
          user32.lib                                                                    ^
          gdi32.lib                                                                     ^
          winspool.lib                                                                  ^
          comdlg32.lib                                                                  ^
          advapi32.lib                                                                  ^
          shell32.lib                                                                   ^
          ole32.lib                                                                     ^
          oleaut32.lib                                                                  ^
          uuid.lib                                                                      ^
          odbc32.lib                                                                    ^
          odbccp32.lib                                                                  ^
          kernel32.lib                                                                  ^
          user32.lib                                                                    ^
          gdi32.lib                                                                     ^
          winspool.lib                                                                  ^
          comdlg32.lib                                                                  ^
          advapi32.lib                                                                  ^
          shell32.lib                                                                   ^
          ole32.lib                                                                     ^
          oleaut32.lib                                                                  ^
          uuid.lib                                                                      ^
          odbc32.lib                                                                    ^
          odbccp32.lib                                                                  ^
          /MANIFEST                                                                     ^
          /MANIFESTUAC:"level='asInvoker' uiAccess='false'"                             ^
          /manifest:embed                                                               ^
          /DEBUG                                                                        ^
          /PDB:"%PROJECT_FOLDER%\x64\Release\%PROJECT%.pdb"                             ^
          /SUBSYSTEM:CONSOLE                                                            ^
          /OPT:REF                                                                      ^
          /OPT:ICF                                                                      ^
          /LTCG:incremental                                                             ^
          /LTCGOUT:"x64\Release\%PROJECT%.iobj"                                         ^
          /TLBID:1                                                                      ^
          /DYNAMICBASE                                                                  ^
          /NXCOMPAT                                                                     ^
          /IMPLIB:"%PROJECT_FOLDER%\x64\Release\%PROJECT%.lib"                          ^
          /MACHINE:X64                                                                  ^
          "x64\Release\%SOURCE%.obj"
      echo.
      echo Run x64\Release\%PROJECT%.exe.
      echo.
      "%PROJECT_FOLDER%\x64\Release\%PROJECT%.exe"
      endlocal
      pause
      

      If this batch script executes successfully, you probably just made a typo in Visual Studio when you were working through the post.

      Note: This batch script essentially does the same thing that this post does … except using the current version of ZeroMQ from Vcpkg. At the time I’m writing this reply, the current version of ZeroMQ from Vcpkg is version 4.3.4. Since the ZeroMQ static libraries that get built by Vcpkg contain this version number info in their file names, you’ll need to edit the script above when Vcpkg upgrades to a higher version of ZeroMQ. Lastly, this batch script does not contain any error handling … if one command fails, this script just continues to the next command … so add the appropriate error handling for your environment.

      When I copied the text above into a batch script named “build-zeromq-on-windows.bat” and ran that script on Windows 10 with Visual Studio 2019 ( version 16.10.0 ), here was its output:

      **********************************************************************
      ** Visual Studio 2019 Developer Command Prompt v16.10.0
      ** Copyright (c) 2021 Microsoft Corporation
      **********************************************************************
      [vcvarsall.bat] Environment initialized for: 'x64'
      
      Remove C:\Repos\vcpkg and C:\Repos\ZeroMQ-Version.
      
      
      Build Vcpkg.
      
      A subdirectory or file C:\Repos already exists.
      Cloning into 'vcpkg'...
      remote: Enumerating objects: 112051, done.
      remote: Counting objects: 100% (464/464), done.
      remote: Compressing objects: 100% (327/327), done.
      Receiving objects: 100% (112051/112051), 34.41 Mita 137), pack-reused 111587 eceiving objects: 100% (112051/112051), 33.07 MiB | 4.57 MiB/s
      B | 3.25 MiB/s, done.
      Resolving deltas: 100% (70602/70602), done.
      Updating files: 100% (7758/7758), done.
      Note: switching to 'b2544fd780b2e9a05d903314cbbd37268ba43d81'.
      
      You are in 'detached HEAD' state. You can look around, make experimental
      changes and commit them, and you can discard any commits you make in this
      state without impacting any branches by switching back to a branch.
      
      If you want to create a new branch to retain commits you create, you may
      do so (now or later) by using -c with the switch command. Example:
      
        git switch -c <new-branch-name>
      
      Or undo this operation with:
      
        git switch -
      
      Turn off this advice by setting config variable advice.detachedHead to false
      
      HEAD is now at b2544fd78 [vcpkg_download_distfile] fix download while in manifest mode (#18283)
      Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2021-05-05-9f849c4c43e50d1b16186ae76681c27b0c1be9d9/vcpkg.exe -> C:\Repos\vcpkg\vcpkg.exe
      Done.
      
      Telemetry
      ---------
      vcpkg collects usage data in order to help us improve your experience.
      The data collected by Microsoft is anonymous.
      You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
      passing --disable-metrics to vcpkg on the command line,
      or by setting the VCPKG_DISABLE_METRICS environment variable.
      
      Read more about vcpkg telemetry at docs/about/privacy.md
      
      Build ZeroMQ.
      
      Computing installation plan...
      The following packages will be built and installed:
          zeromq[core]:x64-windows-static -> 4.3.4
      Detecting compiler hash for triplet x64-windows-static...
      A suitable version of powershell-core was not found (required v7.1.0). Downloading portable powershell-core v7.1.0...
      Downloading powershell-core...
        https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x86.zip -> C:\Repos\vcpkg\downloads\PowerShell-7.1.3-win-x86.zip
      Extracting powershell-core...
      A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
      Downloading 7zip...
        https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\Repos\vcpkg\downloads\7-zip.commandline.18.1.0.nupkg
      Extracting 7zip...
      A suitable version of nuget was not found (required v5.5.0). Downloading portable nuget v5.5.0...
      Downloading nuget...
        https://dist.nuget.org/win-x86-commandline/v5.5.1/nuget.exe -> C:\Repos\vcpkg\downloads\22ea847d-nuget.exe
      Using cached binary package: C:\Users\%USERNAME%\AppData\Local\vcpkg\archives\d0\d0e7ae8cfceb1fdab3659cce5d9c6ff55e55b825.zip
      Starting package 1/1: zeromq:x64-windows-static
      Building package zeromq[core]:x64-windows-static...
      Building package zeromq[core]:x64-windows-static... done
      Installing package zeromq[core]:x64-windows-static...
      Installing package zeromq[core]:x64-windows-static... done
      Elapsed time for package zeromq:x64-windows-static: 208.1 ms
      
      Total elapsed time: 29.07 s
      
      The package zeromq:x64-windows-static provides CMake targets:
      
          find_package(ZeroMQ CONFIG REQUIRED)
          target_link_libraries(main PRIVATE libzmq libzmq-static)
      
      
      Create Source.cpp.
      
      
      Compile Source.cpp to x64\Debug\Source.obj.
      
      Source.cpp
      
      Link x64\Debug\Source.obj to x64\Debug\ZeroMQ-Version.exe.
      
      
      Run x64\Debug\ZeroMQ-Version.exe.
      
      Current 0MQ version is 4.3.4
      
      Compile Source.cpp to x64\Release\Source.obj.
      
      Source.cpp
      
      Link x64\Release\Source.obj to x64\Release\ZeroMQ-Version.exe.
      
      Generating code
      Previous IPDB not found, fall back to full compilation.
      All 3792 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
      Finished generating code
      
      Run x64\Release\ZeroMQ-Version.exe.
      
      Current 0MQ version is 4.3.4
      Press any key to continue . . .
      

      … so both the Debug and Release configurations worked: Both printed “Current 0MQ version is 4.3.4”.

      Hope This Helps.

  8. Ravitej

    Hi,

    After “vcpkg install zeromq:x86-windows-static”, I don’t find the below folders:

    ZeroMQ source code folder: C:\Repos\vcpkg\buildtrees\zeromq\src
    ZeroMQ debug build folder: C:\Repos\vcpkg\buildtrees\zeromq\x64-windows-static-dbg
    ZeroMQ release build folder: C:\Repos\vcpkg\buildtrees\zeromq\x64-windows-static-rel

    What am I doing wrong?

    1. Joshua Burkholder Post author

      After “vcpkg install zeromq:x86-windows-static”, I don’t find the below folders:

      ZeroMQ source code folder: C:\Repos\vcpkg\buildtrees\zeromq\src
      ZeroMQ debug build folder: C:\Repos\vcpkg\buildtrees\zeromq\x64-windows-static-dbg
      ZeroMQ release build folder: C:\Repos\vcpkg\buildtrees\zeromq\x64-windows-static-rel

      What am I doing wrong?

      Two things:

      • This post targets x64, not x86; however, vcpkg install zeromq:x86-windows-static will work if the steps are translated appropriately.
      • Vcpkg did not have binary caching when I originally wrote this post, so now we’ll need to disable binary caching ( --binarysource=clear ) in order to ensure those folders exist.

      After vcpkg install zeromq:x86-windows-static --binarysource=clear, the following type of folders should exist:

      • C:\Repos\vcpkg\buildtrees\zeromq\src
      • C:\Repos\vcpkg\buildtrees\zeromq\x86-windows-static-dbg
      • C:\Repos\vcpkg\buildtrees\zeromq\x86-windows-static-rel

      Similar to the script I wrote above that targets x64, here’s a batch script that targets x86 with binary caching disabled ( see additional info below ):

      @echo off
      setlocal
      call "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
      set REPOS_FOLDER=C:\Repos
      set VCPKG_FOLDER=%REPOS_FOLDER%\vcpkg
      set PROJECT=ZeroMQ-Version
      set PROJECT_FOLDER=%REPOS_FOLDER%\%PROJECT%
      set SOURCE=Source
      echo.
      echo Remove %VCPKG_FOLDER% and %PROJECT_FOLDER%.
      echo.
      rmdir /S /Q "%VCPKG_FOLDER%"
      rmdir /S /Q "%PROJECT_FOLDER%"
      echo.
      echo Build Vcpkg.
      echo.
      mkdir "%REPOS_FOLDER%"
      cd /d "%REPOS_FOLDER%"
      REM Checkout the following commit hash from August 10th, 2021:
      REM https://github.com/microsoft/vcpkg/commit/69478c5caafcde4c490bb1fccb960296801dbb5f
      git clone --no-checkout https://github.com/Microsoft/vcpkg
      cd /d "%VCPKG_FOLDER%"
      git checkout 69478c5caafcde4c490bb1fccb960296801dbb5f
      REM To get the latest, comment out the three commands above and replace with just the following two commands:
      REM git clone https://github.com/Microsoft/vcpkg
      REM cd /d "%VCPKG_FOLDER%"
      call bootstrap-vcpkg.bat
      echo.
      echo Build ZeroMQ.
      echo.
      vcpkg install zeromq:x86-windows-static --binarysource=clear
      echo.
      echo Create %SOURCE%.cpp.
      echo.
      mkdir "%PROJECT_FOLDER%"
      cd /d "%PROJECT_FOLDER%"
      echo #include ^<zmq.h^>                                                                                           > "%SOURCE%.cpp"
      echo #include ^<iostream^>                                                                                       >> "%SOURCE%.cpp"
      echo.                                                                                                            >> "%SOURCE%.cpp"
      echo int main()                                                                                                  >> "%SOURCE%.cpp"
      echo {                                                                                                           >> "%SOURCE%.cpp"
      echo     int major = 0;                                                                                          >> "%SOURCE%.cpp"
      echo     int minor = 0;                                                                                          >> "%SOURCE%.cpp"
      echo     int patch = 0;                                                                                          >> "%SOURCE%.cpp"
      echo     zmq_version( ^&major, ^&minor, ^&patch );                                                               >> "%SOURCE%.cpp"
      echo     std::wcout ^<^< "Current 0MQ version is " ^<^< major ^<^< '.' ^<^< minor ^<^< '.' ^<^< patch ^<^< '\n'; >> "%SOURCE%.cpp"
      echo }                                                                                                           >> "%SOURCE%.cpp"
      echo.
      echo Compile %SOURCE%.cpp to x86\Debug\%SOURCE%.obj.
      echo.
      mkdir "%PROJECT_FOLDER%\x86\Debug"
      cd /d "%PROJECT_FOLDER%"
      cl.exe                                                            ^
          /c                                                            ^
          /I"%VCPKG_FOLDER%\packages\zeromq_x86-windows-static\include" ^
          /ZI                                                           ^
          /JMC                                                          ^
          /nologo                                                       ^
          /W3                                                           ^
          /WX-                                                          ^
          /diagnostics:column                                           ^
          /sdl                                                          ^
          /Od                                                           ^
          /D ZMQ_STATIC                                                 ^
          /D _DEBUG                                                     ^
          /D _CONSOLE                                                   ^
          /D _UNICODE                                                   ^
          /D UNICODE                                                    ^
          /Gm-                                                          ^
          /EHsc                                                         ^
          /RTC1                                                         ^
          /MTd                                                          ^
          /GS                                                           ^
          /fp:precise                                                   ^
          /permissive-                                                  ^
          /Zc:wchar_t                                                   ^
          /Zc:forScope                                                  ^
          /Zc:inline                                                    ^
          /Fo"x86\Debug\\"                                              ^
          /Fd"x86\Debug\vc142.pdb"                                      ^
          /external:env:EXTERNAL_INCLUDE                                ^
          /external:W3                                                  ^
          /Gd                                                           ^
          /TP                                                           ^
          /FC                                                           ^
          /errorReport:prompt                                           ^
          "%SOURCE%.cpp"
      echo.
      echo Link x86\Debug\%SOURCE%.obj to x86\Debug\%PROJECT%.exe.
      echo.
      cd /d "%PROJECT_FOLDER%"
      link.exe                                                                                  ^
          /ERRORREPORT:PROMPT                                                                   ^
          /OUT:"%PROJECT_FOLDER%\x86\Debug\%PROJECT%.exe"                                       ^
          /INCREMENTAL                                                                          ^
          /ILK:"x86\Debug\%PROJECT%.ilk"                                                        ^
          /NOLOGO                                                                               ^
          "%VCPKG_FOLDER%\packages\zeromq_x86-windows-static\debug\lib\libzmq-mt-sgd-4_3_4.lib" ^
          Ws2_32.lib                                                                            ^
          Iphlpapi.lib                                                                          ^
          kernel32.lib                                                                          ^
          user32.lib                                                                            ^
          gdi32.lib                                                                             ^
          winspool.lib                                                                          ^
          comdlg32.lib                                                                          ^
          advapi32.lib                                                                          ^
          shell32.lib                                                                           ^
          ole32.lib                                                                             ^
          oleaut32.lib                                                                          ^
          uuid.lib                                                                              ^
          odbc32.lib                                                                            ^
          odbccp32.lib                                                                          ^
          kernel32.lib                                                                          ^
          user32.lib                                                                            ^
          gdi32.lib                                                                             ^
          winspool.lib                                                                          ^
          comdlg32.lib                                                                          ^
          advapi32.lib                                                                          ^
          shell32.lib                                                                           ^
          ole32.lib                                                                             ^
          oleaut32.lib                                                                          ^
          uuid.lib                                                                              ^
          odbc32.lib                                                                            ^
          odbccp32.lib                                                                          ^
          /MANIFEST                                                                             ^
          /MANIFESTUAC:"level='asInvoker' uiAccess='false'"                                     ^
          /manifest:embed                                                                       ^
          /DEBUG                                                                                ^
          /PDB:"%PROJECT_FOLDER%\x86\Debug\%PROJECT%.pdb"                                       ^
          /SUBSYSTEM:CONSOLE                                                                    ^
          /TLBID:1                                                                              ^
          /DYNAMICBASE                                                                          ^
          /NXCOMPAT                                                                             ^
          /IMPLIB:"%PROJECT_FOLDER%\x86\Debug\%PROJECT%.lib"                                    ^
          /MACHINE:X86                                                                          ^
          "x86\Debug\%SOURCE%.obj"
      echo.
      echo Run x86\Debug\%PROJECT%.exe.
      echo.
      "%PROJECT_FOLDER%\x86\Debug\%PROJECT%.exe"
      echo.
      echo Compile %SOURCE%.cpp to x86\Release\%SOURCE%.obj.
      echo.
      mkdir "%PROJECT_FOLDER%\x86\Release"
      cd /d "%PROJECT_FOLDER%"
      cl.exe                                                            ^
          /c                                                            ^
          /I"%VCPKG_FOLDER%\packages\zeromq_x86-windows-static\include" ^
          /Zi                                                           ^
          /nologo                                                       ^
          /W3                                                           ^
          /WX-                                                          ^
          /diagnostics:column                                           ^
          /sdl                                                          ^
          /O2                                                           ^
          /Oi                                                           ^
          /GL                                                           ^
          /D ZMQ_STATIC                                                 ^
          /D NDEBUG                                                     ^
          /D _CONSOLE                                                   ^
          /D _UNICODE                                                   ^
          /D UNICODE                                                    ^
          /Gm-                                                          ^
          /EHsc                                                         ^
          /MT                                                           ^
          /GS                                                           ^
          /Gy                                                           ^
          /fp:precise                                                   ^
          /permissive-                                                  ^
          /Zc:wchar_t                                                   ^
          /Zc:forScope                                                  ^
          /Zc:inline                                                    ^
          /Fo"x86\Release\\"                                            ^
          /Fd"x86\Release\vc142.pdb"                                    ^
          /external:env:EXTERNAL_INCLUDE                                ^
          /external:W3                                                  ^
          /Gd                                                           ^
          /TP                                                           ^
          /FC                                                           ^
          /errorReport:prompt                                           ^
          "%SOURCE%.cpp"
      echo.
      echo Link x86\Release\%SOURCE%.obj to x86\Release\%PROJECT%.exe.
      echo.
      cd /d "%PROJECT_FOLDER%"
      link.exe                                                                          ^
          /ERRORREPORT:PROMPT                                                           ^
          /OUT:"%PROJECT_FOLDER%\x86\Release\%PROJECT%.exe"                             ^
          /INCREMENTAL:NO                                                               ^
          /NOLOGO                                                                       ^
          "%VCPKG_FOLDER%\packages\zeromq_x86-windows-static\lib\libzmq-mt-s-4_3_4.lib" ^
          Ws2_32.lib                                                                    ^
          Iphlpapi.lib                                                                  ^
          kernel32.lib                                                                  ^
          user32.lib                                                                    ^
          gdi32.lib                                                                     ^
          winspool.lib                                                                  ^
          comdlg32.lib                                                                  ^
          advapi32.lib                                                                  ^
          shell32.lib                                                                   ^
          ole32.lib                                                                     ^
          oleaut32.lib                                                                  ^
          uuid.lib                                                                      ^
          odbc32.lib                                                                    ^
          odbccp32.lib                                                                  ^
          kernel32.lib                                                                  ^
          user32.lib                                                                    ^
          gdi32.lib                                                                     ^
          winspool.lib                                                                  ^
          comdlg32.lib                                                                  ^
          advapi32.lib                                                                  ^
          shell32.lib                                                                   ^
          ole32.lib                                                                     ^
          oleaut32.lib                                                                  ^
          uuid.lib                                                                      ^
          odbc32.lib                                                                    ^
          odbccp32.lib                                                                  ^
          /MANIFEST                                                                     ^
          /MANIFESTUAC:"level='asInvoker' uiAccess='false'"                             ^
          /manifest:embed                                                               ^
          /DEBUG                                                                        ^
          /PDB:"%PROJECT_FOLDER%\x86\Release\%PROJECT%.pdb"                             ^
          /SUBSYSTEM:CONSOLE                                                            ^
          /OPT:REF                                                                      ^
          /OPT:ICF                                                                      ^
          /LTCG:incremental                                                             ^
          /LTCGOUT:"x86\Release\%PROJECT%.iobj"                                         ^
          /TLBID:1                                                                      ^
          /DYNAMICBASE                                                                  ^
          /NXCOMPAT                                                                     ^
          /IMPLIB:"%PROJECT_FOLDER%\x86\Release\%PROJECT%.lib"                          ^
          /MACHINE:X86                                                                  ^
          "x86\Release\%SOURCE%.obj"
      echo.
      echo Run x86\Release\%PROJECT%.exe.
      echo.
      "%PROJECT_FOLDER%\x86\Release\%PROJECT%.exe"
      endlocal
      pause
      

      Note: This batch script essentially does the same thing that this post does … except using the current version of ZeroMQ from Vcpkg and building for x86. At the time I’m writing this reply, the current version of ZeroMQ from Vcpkg is version 4.3.4. Since the ZeroMQ static libraries that get built by Vcpkg contain this version number info in their file names, you’ll need to edit the script above when Vcpkg upgrades to a higher version of ZeroMQ. Lastly, this batch script does not contain any error handling … if one command fails, this script just continues to the next command … so add the appropriate error handling for your environment.

      When I copied the text above into a batch script named “build-zeromq-for-x86-on-windows.bat” and ran that script on Windows 10 with Visual Studio 2019 ( version 16.11.0 ), here was its output:

      **********************************************************************
      ** Visual Studio 2019 Developer Command Prompt v16.11.0
      ** Copyright (c) 2021 Microsoft Corporation
      **********************************************************************
      [vcvarsall.bat] Environment initialized for: 'x86'
      
      Remove C:\Repos\vcpkg and C:\Repos\ZeroMQ-Version.
      
      
      Build Vcpkg.
      
      A subdirectory or file C:\Repos already exists.
      Cloning into 'vcpkg'...
      remote: Enumerating objects: 117581, done.
      remote: Counting objects: 100% (99/99), done.
      remote: Compressing objects: 100% (23/23), done.
      Receiving objects: 100% (117581/117581), 37.20 MiB | 5.54 MiB/s, done.482
      
      Resolving deltas: 100% (73110/73110), done.
      Updating files: 100% (7912/7912), done.
      Note: switching to '69478c5caafcde4c490bb1fccb960296801dbb5f'.
      
      You are in 'detached HEAD' state. You can look around, make experimental
      changes and commit them, and you can discard any commits you make in this
      state without impacting any branches by switching back to a branch.
      
      If you want to create a new branch to retain commits you create, you may
      do so (now or later) by using -c with the switch command. Example:
      
        git switch -c <new-branch-name>
      
      Or undo this operation with:
      
        git switch -
      
      Turn off this advice by setting config variable advice.detachedHead to false
      
      HEAD is now at 69478c5ca [vcpkg-cmake] Fix vcpkg_copy_pdbs false alarm (#19369)
      Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2021-08-03/vcpkg.exe -> C:\Repos\vcpkg\vcpkg.exe... done.
      Validating signature... done.
      
      Telemetry
      ---------
      vcpkg collects usage data in order to help us improve your experience.
      The data collected by Microsoft is anonymous.
      You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
      passing --disable-metrics to vcpkg on the command line,
      or by setting the VCPKG_DISABLE_METRICS environment variable.
      
      Read more about vcpkg telemetry at docs/about/privacy.md
      
      Build ZeroMQ.
      
      Computing installation plan...
      The following packages will be built and installed:
        * vcpkg-cmake[core]:x64-windows -> 2021-07-30
        * vcpkg-cmake-config[core]:x64-windows -> 2021-05-22#1
          zeromq[core]:x86-windows-static -> 4.3.4#1
      Additional packages (*) will be modified to complete this operation.
      Detecting compiler hash for triplet x64-windows...
      A suitable version of git was not found (required v2.32.0). Downloading portable git v2.32.0...
      Downloading git...
        https://github.com/git-for-windows/git/releases/download/v2.32.0.windows.2/PortableGit-2.32.0.2-32-bit.7z.exe -> C:\Repos\vcpkg\downloads\PortableGit-2.32.0.2-32-bit.7z.exe
      Extracting git...
      A suitable version of 7zip was not found (required v19.0.0). Downloading portable 7zip v19.0.0...
      Downloading 7zip...
        https://www.7-zip.org/a/7z1900-x64.msi -> C:\Repos\vcpkg\downloads\7z1900-x64.msi
      Extracting 7zip...
      A suitable version of powershell-core was not found (required v7.1.3). Downloading portable powershell-core v7.1.3...
      Downloading powershell-core...
        https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x86.zip -> C:\Repos\vcpkg\downloads\PowerShell-7.1.3-win-x86.zip
      Extracting powershell-core...
      Detecting compiler hash for triplet x86-windows-static...
      Starting package 1/3: vcpkg-cmake:x64-windows
      Building package vcpkg-cmake[core]:x64-windows...
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_get_vars.cmake
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/cmake_get_vars
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/cmake_get_vars/CMakeLists.txt
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg-port-config.cmake
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/copyright
      -- Performing post-build validation
      -- Performing post-build validation done
      Building package vcpkg-cmake[core]:x64-windows... done
      Installing package vcpkg-cmake[core]:x64-windows...
      Installing package vcpkg-cmake[core]:x64-windows... done
      Elapsed time for package vcpkg-cmake:x64-windows: 181.9 ms
      Starting package 2/3: vcpkg-cmake-config:x64-windows
      Building package vcpkg-cmake-config[core]:x64-windows...
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/vcpkg-port-config.cmake
      -- Installing: C:/Repos/vcpkg/packages/vcpkg-cmake-config_x64-windows/share/vcpkg-cmake-config/copyright
      -- Performing post-build validation
      -- Performing post-build validation done
      Building package vcpkg-cmake-config[core]:x64-windows... done
      Installing package vcpkg-cmake-config[core]:x64-windows...
      Installing package vcpkg-cmake-config[core]:x64-windows... done
      Elapsed time for package vcpkg-cmake-config:x64-windows: 187.3 ms
      Starting package 3/3: zeromq:x86-windows-static
      Building package zeromq[core]:x86-windows-static...
      -- Using community triplet x86-windows-static. This triplet configuration is not guaranteed to succeed.
      -- [COMMUNITY] Loading triplet configuration from: C:\Repos\vcpkg\triplets\community\x86-windows-static.cmake
      -- Downloading https://github.com/zeromq/libzmq/archive/v4.3.4.tar.gz -> zeromq-libzmq-v4.3.4.tar.gz...
      -- Extracting source C:/Repos/vcpkg/downloads/zeromq-libzmq-v4.3.4.tar.gz
      -- Applying patch fix-arm.patch
      -- Using source at C:/Repos/vcpkg/buildtrees/zeromq/src/v4.3.4-bced836184.clean
      -- Found external ninja('1.10.2').
      -- Configuring x86-windows-static
      CMake Warning at installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake:472 (message):
        The following variables are not used in CMakeLists.txt:
      
            WITH_PERF_TOOL
      
        Please recheck them and remove the unnecessary options from the
        `vcpkg_cmake_configure` call.
      
        If these options should still be passed for whatever reason, please use the
        `MAYBE_UNUSED_VARIABLES` argument.
      Call Stack (most recent call first):
        ports/zeromq/portfile.cmake:27 (vcpkg_cmake_configure)
        scripts/ports.cmake:141 (include)
      
      
      -- Building x86-windows-static-dbg
      -- Building x86-windows-static-rel
      -- Performing post-build validation
      -- Performing post-build validation done
      Building package zeromq[core]:x86-windows-static... done
      Installing package zeromq[core]:x86-windows-static...
      Installing package zeromq[core]:x86-windows-static... done
      Elapsed time for package zeromq:x86-windows-static: 29.71 s
      
      Total elapsed time: 1.353 min
      
      The package zeromq:x86-windows-static provides CMake targets:
      
          find_package(ZeroMQ CONFIG REQUIRED)
          target_link_libraries(main PRIVATE libzmq libzmq-static)
      
      
      Create Source.cpp.
      
      
      Compile Source.cpp to x86\Debug\Source.obj.
      
      Source.cpp
      
      Link x86\Debug\Source.obj to x86\Debug\ZeroMQ-Version.exe.
      
      
      Run x86\Debug\ZeroMQ-Version.exe.
      
      Current 0MQ version is 4.3.4
      
      Compile Source.cpp to x86\Release\Source.obj.
      
      Source.cpp
      
      Link x86\Release\Source.obj to x86\Release\ZeroMQ-Version.exe.
      
      Generating code
      Previous IPDB not found, fall back to full compilation.
      All 3789 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
      Finished generating code
      
      Run x86\Release\ZeroMQ-Version.exe.
      
      Current 0MQ version is 4.3.4
      Press any key to continue . . .
      

      … so both the Debug and Release configurations worked for x86: Both printed “Current 0MQ version is 4.3.4”.

      Hope This Helps.

Leave a Reply to Jaehyung Choi Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.