Commit 389396dbbf83f3df62a62601c5963d12fc1143f6
1 parent
af9e36b5
Support Windows builds with MSYS2
Replace the old msys, mingw-w64, ActiveState perl setup with MSYS2. This greatly simplifies the Windows build. This was facilitated by the need to incorporate JPEG.
Showing
8 changed files
with
108 additions
and
160 deletions
README-windows.txt
| @@ -3,52 +3,38 @@ Common Setup | @@ -3,52 +3,38 @@ Common Setup | ||
| 3 | 3 | ||
| 4 | You may need to disable antivirus software to run qpdf's test suite. | 4 | You may need to disable antivirus software to run qpdf's test suite. |
| 5 | 5 | ||
| 6 | -To be able to build qpdf and run its test suite, you must have MSYS | ||
| 7 | -from MinGW installed, and you must have ActiveState Perl. The Perl | ||
| 8 | -provided by MSYS won't work reliably. It partially works, but some | ||
| 9 | -tests will fail with it because it doesn't support all the | ||
| 10 | -capabilities required by the test driver. Here's what I did on my | ||
| 11 | -system: | ||
| 12 | - | ||
| 13 | -Install ActiveState perl. The versions of perl included with git bash | ||
| 14 | -and mingw are not able to run the test suite. | ||
| 15 | - | ||
| 16 | -Install MinGW-w64. From MinGW-w64 download page, grab the installer | ||
| 17 | -and run it. First install the i686 compiler to C:\mingw-w64, and then | ||
| 18 | -install x86_64 compiler to the same location. The installer will | ||
| 19 | -automatically created mingw32 and mingw64 directories under mingw-w64. | ||
| 20 | - | ||
| 21 | -Grab the latest mingw-get-inst from the MinGW project. We are using | ||
| 22 | -this for shell and build utilties but not for the compiler. Run the | ||
| 23 | -installer. | ||
| 24 | - | ||
| 25 | -Install under basic: | ||
| 26 | - mingw-developer-toolkit | ||
| 27 | - msys-base | ||
| 28 | - | ||
| 29 | -Use C:\mingw32\msys\1.0\msys.bat to start a shell. In the shell, run | ||
| 30 | - | ||
| 31 | -mingw32-get install msys-zip | ||
| 32 | - | ||
| 33 | -Add to path in this order: | ||
| 34 | - C:\mingw32\msys\1.0\bin | ||
| 35 | - C:\mingw-w64\mingw64\bin | ||
| 36 | - C:\mingw-w64\mingw32\bin | ||
| 37 | - | ||
| 38 | -ensuring that they are after ActiveState perl. | ||
| 39 | - | ||
| 40 | -Check to make sure zip and unzip are in your path, make --version | ||
| 41 | -shows at least 3.81, perl --version shows the perl from ActiveState, | ||
| 42 | -and gcc --version is the 64-bit gcc. (zip is not actually needed | ||
| 43 | -unless you are running the tools to create the releases.) | ||
| 44 | - | ||
| 45 | -Install suitable Microsoft Visual Studio edition. In early 2016, 2015 | 6 | +To be able to build qpdf and run its test suite, you must have MSYS2 |
| 7 | +installed. This replaces the old process of having a mixture of msys, | ||
| 8 | +mingw-w64, and ActiveState perl. It is now possible to do everything | ||
| 9 | +with just MSYS2. | ||
| 10 | + | ||
| 11 | +Here's what I did on my system: | ||
| 12 | + | ||
| 13 | +* Download msys2 (64-bit) from msys2.org | ||
| 14 | +* Run the installer. | ||
| 15 | +* Run msys2_shell.cmd by allowing the installer to start it. | ||
| 16 | +* From the prompt: | ||
| 17 | + * Run `pacman -Syuu` and follow the instructions, which may tell you | ||
| 18 | + to close the window and rerun the command multiple times. | ||
| 19 | + * pacman -S make base-devel git zip unzip | ||
| 20 | + * pacman -S mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain | ||
| 21 | + | ||
| 22 | +If you would like to build with Microsoft Visual C++, install a | ||
| 23 | +suitable Microsoft Visual Studio edition. In early 2016, 2015 | ||
| 46 | community edition with C++ support is fine. It may crash a few times | 24 | community edition with C++ support is fine. It may crash a few times |
| 47 | during installation, but repeating the installation will allow it to | 25 | during installation, but repeating the installation will allow it to |
| 48 | finish, and the resulting software is stable. | 26 | finish, and the resulting software is stable. |
| 49 | 27 | ||
| 50 | -To build qpdf, start the msys shell from a command window started from | ||
| 51 | -one of the Visual Studio shell windows. | 28 | +To build qpdf with Visual Studio, start the msys2 mingw32 or mingw64 |
| 29 | +shell from a command window started from one of the Visual Studio | ||
| 30 | +shell windows. You must use the mingw shell for the same word size (32 | ||
| 31 | +or 64 bit) as the Windows compiler since the MSVC build uses objdump | ||
| 32 | +from the msys distribution. You must also have it inherit the path. | ||
| 33 | +For example: | ||
| 34 | + | ||
| 35 | +* Start x64 native tools command prompt from msvc | ||
| 36 | +* set MSYS2_PATH_TYPE=inherit | ||
| 37 | +* C:\msys64\mingw64 | ||
| 52 | 38 | ||
| 53 | Image comparison tests are disabled by default, but it is possible to | 39 | Image comparison tests are disabled by default, but it is possible to |
| 54 | run them on Windows. To do so, add --enable-test-compare-images from | 40 | run them on Windows. To do so, add --enable-test-compare-images from |
| @@ -84,32 +70,28 @@ installers are provided, they might do that already by default. | @@ -84,32 +70,28 @@ installers are provided, they might do that already by default. | ||
| 84 | External Libraries | 70 | External Libraries |
| 85 | ================== | 71 | ================== |
| 86 | 72 | ||
| 87 | -In order to build qpdf, you must have a copy of zlib. The easy way to | ||
| 88 | -get it is to download it from the qpdf download area. There are | ||
| 89 | -packages called external-libs-bin.zip and external-libs-src.zip. If | ||
| 90 | -you are building with MSVC 2010 or MINGW, you can just extract the | 73 | +In order to build qpdf, you must have a copy of zlib and the jpeg |
| 74 | +library. The easy way to get it is to download the external libs from | ||
| 75 | +the qpdf download area. There are packages called | ||
| 76 | +external-libs-bin.zip and external-libs-src.zip. If you are building | ||
| 77 | +with MSVC 2015 or MINGW with MSYS2, you can just extract the | ||
| 91 | qpdf-external-libs-bin.zip zip file into the top-level qpdf source | 78 | qpdf-external-libs-bin.zip zip file into the top-level qpdf source |
| 92 | -tree. Note that you need the 2012-06-20 version (at least) to build | ||
| 93 | -qpdf 3.0 or greater since this includes 64-bit libraries. The | ||
| 94 | -2017-08-10 version includes libraries built with MSVC 2015 and | ||
| 95 | -contains only zlib. Older versions also contain pcre, which is no | ||
| 96 | -longer required as of qpdf 7.0.0. Extracting the zip will create a | ||
| 97 | -directory called external-libs which contains header files and | ||
| 98 | -precompiled libraries. Passing --enable-external-libs to ./configure | ||
| 99 | -(which is done automatically if you follow the instructions below) is | ||
| 100 | -sufficient to find them. | ||
| 101 | - | ||
| 102 | -You can also obtain zlib directly on your own and install it. If you | ||
| 103 | -are using mingw, you can just set CPPFLAGS, LDFLAGS, and LIBS when you | ||
| 104 | -run ./configure so that it can find the header files and libraries. If | ||
| 105 | -you are building with msvc and you want to do this, it probably won't | ||
| 106 | -work because ./configure doesn't know how to interpret LDFLAGS and | ||
| 107 | -LIBS properly for MSVC (though qpdf's own build system does). In this | ||
| 108 | -case, you can probably get away with cheating by passing | ||
| 109 | ---enable-external-libs to ./configure and then just editing CPPFLAGS, | ||
| 110 | -LDFLAGS, LIBS in the generated autoconf.mk file. Note that you should | ||
| 111 | -use UNIX-like syntax (-I, -L, -l) even though this is not what cl | ||
| 112 | -takes on the command line. qpdf's build rules will fix it. | 79 | +tree. Note that you need the 2017-08-21 version (at least) to build |
| 80 | +qpdf 7.0 or greater since this includes jpeg. Passing | ||
| 81 | +--enable-external-libs to ./configure (which is done automatically if | ||
| 82 | +you follow the instructions below) is sufficient to find them. | ||
| 83 | + | ||
| 84 | +You can also obtain zlib and jpeg directly on your own and install | ||
| 85 | +them. If you are using mingw, you can just set CPPFLAGS, LDFLAGS, and | ||
| 86 | +LIBS when you run ./configure so that it can find the header files and | ||
| 87 | +libraries. If you are building with msvc and you want to do this, it | ||
| 88 | +probably won't work because ./configure doesn't know how to interpret | ||
| 89 | +LDFLAGS and LIBS properly for MSVC (though qpdf's own build system | ||
| 90 | +does). In this case, you can probably get away with cheating by | ||
| 91 | +passing --enable-external-libs to ./configure and then just editing | ||
| 92 | +CPPFLAGS, LDFLAGS, LIBS in the generated autoconf.mk file. Note that | ||
| 93 | +you should use UNIX-like syntax (-I, -L, -l) even though this is not | ||
| 94 | +what cl takes on the command line. qpdf's build rules will fix it. | ||
| 113 | 95 | ||
| 114 | You can also download qpdf-external-libs-src.zip and follow the | 96 | You can also download qpdf-external-libs-src.zip and follow the |
| 115 | instructions in the README.txt there for how to build external libs. | 97 | instructions in the README.txt there for how to build external libs. |
| @@ -130,29 +112,22 @@ autofiles.zip that you can extract on top of a fresh checkout. | @@ -130,29 +112,22 @@ autofiles.zip that you can extract on top of a fresh checkout. | ||
| 130 | Building with MinGW | 112 | Building with MinGW |
| 131 | =================== | 113 | =================== |
| 132 | 114 | ||
| 133 | -QPDF is known to build and pass its test suite with mingw-w64 using | ||
| 134 | -the 32-bit and 64-bit compilers from that project (latest version | ||
| 135 | -tested: 5.3.0) and Microsoft Visual C++ 2015, both 32-bit and 64-bit | ||
| 136 | -versions. MSYS plus ActiveState Perl is required to build as well in | ||
| 137 | -order to get make and other related tools. While it is possible that | ||
| 138 | -Cygwin could be used to build native Windows versions of qpdf, this | ||
| 139 | -configuration has not been tested recently. | ||
| 140 | - | ||
| 141 | -From your MSYS prompt, run | ||
| 142 | - | ||
| 143 | - ./config-mingw32 | 115 | +QPDF is known to build and pass its test suite with MSYS2 using the |
| 116 | +32-bit and 64-bit compilers from that project and Microsoft Visual C++ | ||
| 117 | +2015, both 32-bit and 64-bit versions. MSYS2 is required to build as | ||
| 118 | +well in order to get make and other related tools. See common setup at | ||
| 119 | +the top of this file for installation and configuration of MSYS2. | ||
| 120 | +Then, from the suitable 32-bit or 64-bit environment, run | ||
| 144 | 121 | ||
| 145 | -or | ||
| 146 | - | ||
| 147 | - ./config-mingw64 | 122 | + ./config-mingw |
| 148 | 123 | ||
| 149 | and then | 124 | and then |
| 150 | 125 | ||
| 151 | make | 126 | make |
| 152 | 127 | ||
| 153 | -Note that ./config-mingw32 and ./configure-mingw64 just run | ||
| 154 | -./configure with specific arguments, so you can look at it, make | ||
| 155 | -adjustments, and manually run configure instead. | 128 | +Note that ./config-mingw just runs ./configure with specific |
| 129 | +arguments, so you can look at it, make adjustments, and manually run | ||
| 130 | +configure instead. | ||
| 156 | 131 | ||
| 157 | Add the absolute path to the libqpdf/build directory to your PATH. | 132 | Add the absolute path to the libqpdf/build directory to your PATH. |
| 158 | Make sure you can run the qpdf command by typing qpdf/build/qpdf and | 133 | Make sure you can run the qpdf command by typing qpdf/build/qpdf and |
| @@ -184,23 +159,12 @@ that does this. Make sure that you start a command line environment | @@ -184,23 +159,12 @@ that does this. Make sure that you start a command line environment | ||
| 184 | configured for whichever of 32-bit or 64-bit output that you intend to | 159 | configured for whichever of 32-bit or 64-bit output that you intend to |
| 185 | build for. | 160 | build for. |
| 186 | 161 | ||
| 187 | -From that cmd prompt, you can start your msys shell by just running | ||
| 188 | -manually whatever command is associated with your msys shell icon | ||
| 189 | -(such as C:\MinGW\msys\1.0\msys.bat). | 162 | +From that cmd prompt, you can start your MSYS2 shell with path |
| 163 | +inheritance as described above. | ||
| 190 | 164 | ||
| 191 | Configure as follows: | 165 | Configure as follows: |
| 192 | 166 | ||
| 193 | - ./config-msvc 32 | ||
| 194 | - | ||
| 195 | -or | ||
| 196 | - | ||
| 197 | - ./config-msvc 64 | ||
| 198 | - | ||
| 199 | -Note that you must pass the 32/64 option that matches your command | ||
| 200 | -line setup. The scripts do not presently figure this out. If you | ||
| 201 | -used the wrong argument, it would probably just build the size you | ||
| 202 | -have in your environment and then install the results in the wrong | ||
| 203 | -place. | 167 | + ./config-msvc |
| 204 | 168 | ||
| 205 | Once configured, run | 169 | Once configured, run |
| 206 | 170 |
TODO
| 1 | Before next release | 1 | Before next release |
| 2 | =================== | 2 | =================== |
| 3 | 3 | ||
| 4 | + | ||
| 5 | +msys2: | ||
| 6 | + | ||
| 7 | +* make_windows_releases: refactor to 32 and 64, add -j8 back to make | ||
| 8 | +* figure out how to get msvc to stay in path -- check msys2 docs | ||
| 9 | + To void this, either launch start shell command using start_shell.cmd | ||
| 10 | + -use-full-path or inside Windows directly, set an environment variable | ||
| 11 | + for your user with name MSYS2_PATH_TYPE and value inherit. | ||
| 12 | +* figure out test coverage | ||
| 13 | +* get test coverage to work | ||
| 14 | +* get jpeg | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 4 | ABI compatibility has most likely been broken. Retest and bump major | 20 | ABI compatibility has most likely been broken. Retest and bump major |
| 5 | version if needed. | 21 | version if needed. |
| 6 | 22 |
config-mingw
0 โ 100755
config-mingw32 deleted
| 1 | -#!/bin/sh | ||
| 2 | -./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=32 --with-buildrules=mingw \ | ||
| 3 | - CC=i686-w64-mingw32-gcc \ | ||
| 4 | - CXX=i686-w64-mingw32-g++ \ | ||
| 5 | - LD=i686-w64-mingw32-ld \ | ||
| 6 | - AR=i686-w64-mingw32-ar \ | ||
| 7 | - RANLIB=i686-w64-mingw32-ranlib \ | ||
| 8 | - DLLTOOL=$(dirname $(type -p i686-w64-mingw32-gcc))/dlltool \ | ||
| 9 | - STRIP=i686-w64-mingw32-strip \ | ||
| 10 | - OBJDUMP=$(dirname $(type -p i686-w64-mingw32-gcc))/objdump \ | ||
| 11 | - ${1+"$@"} |
config-mingw64 deleted
| 1 | -#!/bin/sh | ||
| 2 | -./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=64 --with-buildrules=mingw \ | ||
| 3 | - CC=x86_64-w64-mingw32-gcc \ | ||
| 4 | - CXX=x86_64-w64-mingw32-g++ \ | ||
| 5 | - LD=x86_64-w64-mingw32-ld \ | ||
| 6 | - AR=x86_64-w64-mingw32-ar \ | ||
| 7 | - RANLIB=x86_64-w64-mingw32-ranlib \ | ||
| 8 | - DLLTOOL=$(dirname $(type -p x86_64-w64-mingw32-gcc))/dlltool \ | ||
| 9 | - STRIP=x86_64-w64-mingw32-strip \ | ||
| 10 | - OBJDUMP=$(dirname $(type -p x86_64-w64-mingw32-gcc))/objdump \ | ||
| 11 | - ${1+"$@"} |
config-msvc
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | -wordsize=$1 | ||
| 3 | -if ! test "$wordsize" = "32" -o "$wordsize" = "64"; then | ||
| 4 | - echo "Usage: $0 {32,64}" | ||
| 5 | - exit 2 | ||
| 6 | -fi | ||
| 7 | -shift | ||
| 8 | -objdump= | ||
| 9 | -if test "$wordsize" = "64"; then | ||
| 10 | - objdump=$(dirname $(type -p x86_64-w64-mingw32-gcc))/objdump | 2 | +set -e |
| 3 | +set -x | ||
| 4 | +if echo $PATH | grep -q /mingw64; then | ||
| 5 | + wordsize=64 | ||
| 11 | else | 6 | else |
| 12 | - objdump=$(dirname $(type -p i686-w64-mingw32-gcc))/objdump | 7 | + wordsize=32 |
| 13 | fi | 8 | fi |
| 14 | -CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=$wordsize --with-buildrules=msvc OBJDUMP=$objdump ${1+"$@"} | 9 | +CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=$wordsize --with-buildrules=msvc ${1+"$@"} |
make_windows_releases
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | + | ||
| 2 | if [ ! -d external-libs ]; then | 3 | if [ ! -d external-libs ]; then |
| 3 | echo "Please extract qpdf-external-libs-bin.zip and try again" | 4 | echo "Please extract qpdf-external-libs-bin.zip and try again" |
| 4 | exit 2 | 5 | exit 2 |
| 5 | fi | 6 | fi |
| 6 | 7 | ||
| 8 | +if echo $PATH | grep -q /mingw64; then | ||
| 9 | + wordsize=64 | ||
| 10 | +else | ||
| 11 | + wordsize=32 | ||
| 12 | +fi | ||
| 13 | + | ||
| 7 | set -e | 14 | set -e |
| 8 | set -x | 15 | set -x |
| 9 | cwd=`pwd` | 16 | cwd=`pwd` |
| 10 | PATH=$cwd/libqpdf/build:$PATH | 17 | PATH=$cwd/libqpdf/build:$PATH |
| 11 | 18 | ||
| 12 | -rm -rf install-mingw* install-msvc* | 19 | +rm -rf install-mingw$wordsize install-msvc$wordsize |
| 13 | 20 | ||
| 14 | -./config-mingw64 | ||
| 15 | -make | 21 | +./config-mingw |
| 22 | +make -j8 | ||
| 16 | make check install | 23 | make check install |
| 17 | make distclean | 24 | make distclean |
| 18 | -./config-mingw32 | ||
| 19 | -make | 25 | + |
| 26 | +./config-msvc | ||
| 27 | +make -j8 | ||
| 20 | make check install | 28 | make check install |
| 21 | make distclean | 29 | make distclean |
| 22 | 30 | ||
| 23 | set +x | 31 | set +x |
| 24 | 32 | ||
| 25 | echo '' | 33 | echo '' |
| 26 | -echo 'Now run "./make_windows_releases-msvc 64" in a 64-bit MSVC environment' | ||
| 27 | -echo 'and "./make_windows_releases-msvc 32" in a 32-bit MSVC environment.' | 34 | +echo "Finished builds for $wordsize. If not done already, rerun this" |
| 35 | +echo "in a" `expr 64 - $wordsize` "environment." | ||
| 28 | echo 'Then run "./make_windows_releases-finish".' | 36 | echo 'Then run "./make_windows_releases-finish".' |
| 29 | echo '' | 37 | echo '' |
make_windows_releases-msvc deleted
| 1 | -#!/bin/sh | ||
| 2 | -if [ ! -d external-libs ]; then | ||
| 3 | - echo "Please extract qpdf-external-libs-bin.zip and try again" | ||
| 4 | - exit 2 | ||
| 5 | -fi | ||
| 6 | - | ||
| 7 | -w=$1 | ||
| 8 | - | ||
| 9 | -if [ "$w" = "" ]; then | ||
| 10 | - echo "Usage: $0 {32|64}" | ||
| 11 | - exit 2 | ||
| 12 | -fi | ||
| 13 | - | ||
| 14 | -set -e | ||
| 15 | -set -x | ||
| 16 | -cwd=`pwd` | ||
| 17 | -PATH=$cwd/libqpdf/build:$PATH | ||
| 18 | - | ||
| 19 | -./config-msvc $w | ||
| 20 | -make | ||
| 21 | -make check install | ||
| 22 | -make distclean |