README 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. % win32/README 2024-01-18
  2. Visual Studio 2022
  3. ------------------
  4. To build the Zint library DLL and the command line tool "zint.exe" with PNG
  5. support for x86/Win32:
  6. Install git (https://git-scm.com/downloads)
  7. Install cmake (https://cmake.org/download/)
  8. Open a "Developer Command Prompt for VS 2022" (should be available under the
  9. "Visual Studio 2022" tab in the Start menu).
  10. Make sure git and cmake are in your PATH, e.g. (your paths may differ)
  11. set "PATH=C:\Program Files\Git\cmd;%PATH%"
  12. set "PATH=C:\Program Files\CMake\bin;%PATH%"
  13. Download zint, zlib and libpng by going to the directory you want to clone them
  14. into:
  15. cd <project-directory>
  16. and cloning each:
  17. git clone https://git.code.sf.net/p/zint/code zint
  18. git clone https://git.code.sf.net/p/libpng/code lpng
  19. git clone https://github.com/madler/zlib.git zlib
  20. First build zlib:
  21. cd zlib
  22. nmake -f win32\Makefile.msc clean
  23. nmake -f win32\Makefile.msc
  24. cd ..
  25. and then lpng:
  26. cd lpng
  27. nmake -f scripts\makefile.vcwin32 clean
  28. nmake -f scripts\makefile.vcwin32
  29. cd ..
  30. If you now open "%cd%\zint\win32\zint.sln" with Visual Studio 2022, you
  31. should be able to build the Release configuration for Win32.
  32. "zint.dll" and "zint.exe" will be in "zint\win32\Release".
  33. To build Zint Studio ("qtZint.exe"), you need to have Qt installed, which
  34. involves signing up for a Qt account and installing the Qt Maintenance Tool.
  35. (https://www.qt.io/download-qt-installer)
  36. Using this tool you can install various versions of Qt and various optional
  37. components.
  38. The following requires the "MSVC 2019 32-bit" component to be installed.
  39. As of writing Qt 5.15.2 is the latest release that includes this component and
  40. is used here. Add the location of this component to your PATH, e.g. (your path
  41. may differ):
  42. set "PATH=C:\Qt\5.15.2\msvc2019\bin;%PATH%"
  43. Next build the Zint backend Qt library "QtZintDLL.lib":
  44. cd zint\backend_qt
  45. qmake backend_qt_zintdll.pro
  46. nmake clean
  47. nmake release
  48. cd ..\..
  49. Then Zint Studio "qtZint.exe":
  50. cd zint\frontend_qt
  51. qmake frontend_qt_zintdll.pro
  52. nmake clean
  53. nmake release
  54. cd ..\..
  55. This creates "zint\frontend_qt\release\qtZint.exe". It requires the Zint DLL to
  56. run, so add its location to your PATH:
  57. set "PATH=%cd%\zint\win32\Release;%PATH%"
  58. You should now be able to run Zint Studio:
  59. zint\frontend_qt\release\qtZint
  60. Visual Studio 2019 and 2017
  61. ---------------------------
  62. Solutions for Visual Studio 2019 and 2017 are in sub-directories vs2019 and
  63. vs2017. The steps are the same as for Visual Studio 2022.
  64. Visual Studio 2015
  65. ------------------
  66. A solution for Visual Studio 2015 is in sub-directory vs2015. The steps are
  67. almost the same as for Visual Studio 2022, except that "rc.exe" may not be
  68. available. If so, you need to install a Windows Kit and then update your PATH,
  69. e.g. (adjust for version):
  70. set "PATH=C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x86;%PATH%"
  71. Recent versions of Qt no longer supply a specific component for Visual Studio
  72. 2015 32-bit, but you can use "MSVC 2019 32-bit" instead as it's compatible.
  73. For information on building a standalone version of Zint Studio using Visual
  74. Studio 2015, see "frontend_qt\howto_build_qzint_using_msvs2015.txt"
  75. CMake and Visual Studio
  76. -----------------------
  77. Zint can also be built using CMake with Visual Studio 2022, 2019, 2017 or 2015.
  78. The following example uses Visual Studio 2019 to build for x86/Win32:
  79. As above, follow the steps to build zlib and lpng.
  80. CMake needs to be able to find zlib and lpng. One way to do this (requires
  81. Administrator privileges) is to create two sub-directories in
  82. "C:\Program Files (x86)" called "include" and "lib", and then copy
  83. "zlib\zlib.h", "zlib\zconf.h", "lpng\png.h", "lpng\pngconf.h" and
  84. "lpng\pnglibconf.h" into "include", and
  85. "zlib\zlib.lib" and "lpng\libpng.lib" into "lib".
  86. This example uses Qt 5.15.2 and component "MSVC 2019 32-bit" so install them and
  87. add to path (your path may differ):
  88. set "PATH=C:\Qt\5.15.2\msvc2019\bin;%PATH%"
  89. Now build zint:
  90. cd zint
  91. cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_BUILD_TYPE=Release -B build
  92. cmake --build build --config Release
  93. cd ..
  94. You should be able to run zint CLI and Zint Studio:
  95. set "PATH=%cd%\zint\build\backend\Release;%PATH%"
  96. zint\build\frontend\Release\zint.exe
  97. zint\build\frontend_qt\Release\zint-qt.exe
  98. Note that the program name for Zint Studio when built using CMake is not
  99. "qtZint.exe" but "zint-qt.exe".
  100. For MSVC 2015 32-bit, MSVC 2017 32-bit and MSVC 2022 32-bit, the zint cmake
  101. equivalents are:
  102. cmake -G "Visual Studio 14 2015" -DCMAKE_BUILD_TYPE=Release -B build
  103. cmake -G "Visual Studio 15 2017" -DCMAKE_BUILD_TYPE=Release -B build
  104. cmake -G "Visual Studio 17 2022" -A Win32 -DCMAKE_BUILD_TYPE=Release -B build
  105. Visual C++ 6
  106. ------------
  107. The zint library and command line tool can be built using VC6.
  108. See "win32\zint_cmdline_vc6\readme.txt"
  109. MinGW/MSYS
  110. ----------
  111. If not already installed, download and run the MinGW Installation Manager setup
  112. (https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/) and
  113. using it install the packages:
  114. mingw-developer-toolkit-bin
  115. mingw32-base-bin
  116. mingw32-gcc-g++-bin
  117. msys-base-bin
  118. (This should include mingw32-libz-dll)
  119. Any reasonably modern version of Qt can be used. The following uses Qt 5.15.2.
  120. Using the Qt Maintenance Tool (see the Visual Studio 2022 instructions above)
  121. install the "MinGW 8.1.0 32-bit" component.
  122. (Note the Qt MinGW versions actually refer to Mingw-w64, the 64-bit fork of
  123. MinGW, but versions up to 8.1.0 at least are compatible.)
  124. Open a MinGW/MSYS shell by clicking/running e.g. (your path may differ)
  125. C:\MinGW\msys\1.0\msys.bat
  126. As above make sure git and cmake are in your PATH.
  127. Add the Qt MinGW 8.1.0 32-bit component to your PATH, e.g. (your path may
  128. differ):
  129. export PATH="/c/Qt/5.15.2/mingw81_32/bin":${PATH}
  130. Go into the directory you want to use and clone zint and libpng:
  131. cd <project-directory>
  132. git clone https://git.code.sf.net/p/zint/code zint
  133. git clone https://git.code.sf.net/p/libpng/code lpng
  134. To compile lpng on MSYS, a bit of fiddling is needed. Go to the directory:
  135. cd lpng
  136. On Windows git usually converts UNIX line endings to DOS ones. Undo this:
  137. dos2unix * scripts/*
  138. Attempt to do the usual GNU make:
  139. ./configure
  140. make
  141. This will fail with a syntax error. To fix:
  142. sed -i 's/\r//' pnglibconf.h
  143. (ignore "preserving permissions" warning if any)
  144. And then do the make again:
  145. make
  146. make install
  147. cd ..
  148. The lpng includes should be in "/usr/local/include". Tell gcc to search there by
  149. setting C_INCLUDE_PATH:
  150. export C_INCLUDE_PATH=/usr/local/include
  151. Now we should be able to build zint normally, except for telling cmake to
  152. generate MSYS compatible makefiles:
  153. cd zint
  154. mkdir build
  155. cd build
  156. cmake -G "MSYS Makefiles" ..
  157. make
  158. cd ../..
  159. This creates:
  160. zint/build/backend/libzint.dll
  161. zint/build/frontend/zint.exe
  162. zint/build/backend_qt/libQZint.lib
  163. zint/build/frontend_qt/zint-qt.exe
  164. The Zint command line tool "zint.exe" and Zint Studio "zint-qt.exe" need
  165. "libzint.dll" to run so add its location to your PATH:
  166. export PATH="$(pwd)/zint/build/backend":${PATH}
  167. You should now be able to run the command line tool:
  168. zint/build/frontend/zint
  169. And Zint Studio:
  170. zint/build/frontend_qt/zint-qt