Prefer #include <...> for system headers.
[libiconv.git] / INSTALL.windows
blob5912bb884f31aab5639707cbbd120348b5c0e4c8
1 Installation on Microsoft Windows:
3 There are three ways to create binaries of this package for Microsoft Windows:
4 1) Native binaries, built using the mingw tool chain.
5 2) Native binaries, built using the MS Visual C/C++ tool chain.
6 3) Binaries for the Cygwin environment.
8 ===============================================================================
9 1) Native binaries, built using the mingw tool chain.
11    I recommend to use the Cygwin environment as the development environment (*)
12    and mingw only as the target (runtime, deployment) environment.
13    For this, you need to install
14      * Cygwin (from https://cygwin.com/),
15      * some packages available from the Cygwin package installer:
16          make
17      * the mingw cross-compilation tools and runtime package, available from
18        the Cygwin package installer (setup-x86_64.exe):
19        - for creating 32-bit binaries: packages
20            mingw64-i686-gcc-core,
21            mingw64-i686-headers,
22            mingw64-i686-runtime
23        - for creating 64-bit binaries: packages
24            mingw64-x86_64-gcc-core,
25            mingw64-x86_64-headers,
26            mingw64-x86_64-runtime
28    Building 32-bit binaries for mingw is achieved through the following
29    preparation, configure, and build commands:
31       PATH=/usr/local/mingw32/bin:$PATH
32       export PATH
33       ./configure --host=i686-w64-mingw32 --prefix=/usr/local/mingw32 \
34             CC=i686-w64-mingw32-gcc \
35             CPPFLAGS="-I/usr/local/mingw32/include -Wall" \
36             LDFLAGS="-L/usr/local/mingw32/lib"
37       make
38       make check
40    Building 64-bit binaries for mingw is achieved through the following
41    preparation, configure, and build commands:
43       PATH=/usr/local/mingw64/bin:$PATH
44       export PATH
45       ./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/mingw64 \
46             CC=x86_64-w64-mingw32-gcc \
47             CPPFLAGS="-I/usr/local/mingw64/include -Wall" \
48             LDFLAGS="-L/usr/local/mingw64/lib"
49       make
50       make check
52    Installation:
54       make install
56    (*) Note: The MSYS2 environment as a development environment is *not*
57        supported.  This environment contains an ignoble and ignominious hack:
58        In a program invocation, the program *by default* receives different
59        arguments than the ones that the caller has passed.  See
60        <https://www.msys2.org/wiki/Porting/#filesystem-namespaces>.
61        All program invocations in this environment are therefore unreliable.
63 ===============================================================================
64 2) Native binaries, built using the MS Visual C/C++ tool chain.
66    Note that binaries created with MSVC have a distribution constraint: They
67    depend on a closed-source library ('msvcr90.dll' for MSVC 9.0,
68    'vcruntime140.dll' for MSVC 14.0, and so on) which is not normally part of
69    a Windows installation.
70    You cannot distribute 'vcruntime*.dll' with the binaries - this would be a
71    violation of the GPL and of the Microsoft EULA.
72    You can distribute the binaries without including 'vcruntime*.dll'. Users
73    who don't have this library on their system will require to pull some files
74    (api-ms-win*.dll) through the Windows Update mechanism, see
75    https://support.microsoft.com/en-us/kb/2999226 .
77    This recipe requires MS Visual C/C++ 9.0 or newer.
78    You don't need the Visual Studio IDE, just the C/C++ tool chain.
79    As of 2016, you can install the MS Visual C/C++ 14.0 tool chain from
80    http://landinghub.visualstudio.com/visual-cpp-build-tools (it's the file
81    visualcppbuildtools_full.exe).
83    This recipe requires also a Cygwin environment (with 'bash', the common POSIX
84    commands, and 'make') as a build environment. Building with 'nmake' is not
85    supported.
86    For this, you need to install
87      * Cygwin (from https://cygwin.com/),
88      * some packages available from the Cygwin package installer:
89          make
90      * the mingw cross-compilation tool named 'windres', available from the
91        Cygwin package installer (setup-x86_64.exe):
92        - for creating 32-bit binaries: packages
93            mingw64-i686-binutils,
94            mingw64-i686-gcc-core
95        - for creating 64-bit binaries: packages
96            mingw64-x86_64-binutils,
97            mingw64-x86_64-gcc-core
99    You also need the scripts 'ar-lib' and 'compile' from
100      https://git.savannah.gnu.org/gitweb/?p=automake.git;a=blob_plain;f=lib/ar-lib;hb=HEAD
101      https://git.savannah.gnu.org/gitweb/?p=automake.git;a=blob_plain;f=lib/compile;hb=HEAD
102    respectively.
103    They may also be included in this package, in directory 'build-aux/'.
104    Save them; the instructions below assume that you stored them in $HOME/msvc/.
105    Make them executable:
106       chmod a+x ar-lib compile
108    Start a bash (from Cygwin).
110    Make sure that the MSVC tools ("cl" etc.) are found in PATH and the
111    environment variables INCLUDE and LIB are set appropriately.
112    In a typical MSVC 9.0 installation, it can be achieved by running
113      C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat
114    In a typical MSVC 14.0 installation on Windows 10, it can be achieved
115    - for creating 32-bit binaries: through the following bash commands:
117       # Set environment variables for using MSVC 14,
118       # for creating native 32-bit Windows executables.
120       # Windows C library headers and libraries.
121       WindowsCrtIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt'
122       WindowsCrtLibDir='C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\'
123       INCLUDE="${WindowsCrtIncludeDir};$INCLUDE"
124       LIB="${WindowsCrtLibDir}x86;$LIB"
126       # Windows API headers and libraries.
127       WindowsSdkIncludeDir='C:\Program Files (x86)\Windows Kits\8.1\Include\'
128       WindowsSdkLibDir='C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\'
129       INCLUDE="${WindowsSdkIncludeDir}um;${WindowsSdkIncludeDir}shared;$INCLUDE"
130       LIB="${WindowsSdkLibDir}x86;$LIB"
132       # Visual C++ tools, headers and libraries.
133       VSINSTALLDIR='C:\Program Files (x86)\Microsoft Visual Studio 14.0'
134       VCINSTALLDIR="${VSINSTALLDIR}"'\VC'
135       PATH=`cygpath -u "${VCINSTALLDIR}"`/bin:"$PATH"
136       INCLUDE="${VCINSTALLDIR}"'\include;'"${INCLUDE}"
137       LIB="${VCINSTALLDIR}"'\lib;'"${LIB}"
139       export INCLUDE LIB
141    - for creating 64-bit binaries: through the following bash commands:
143      # Set environment variables for using MSVC 14,
144      # for creating native 64-bit Windows executables.
146      # Windows C library headers and libraries.
147      WindowsCrtIncludeDir='C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt'
148      WindowsCrtLibDir='C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\'
149      INCLUDE="${WindowsCrtIncludeDir};$INCLUDE"
150      LIB="${WindowsCrtLibDir}x64;$LIB"
152      # Windows API headers and libraries.
153      WindowsSdkIncludeDir='C:\Program Files (x86)\Windows Kits\8.1\Include\'
154      WindowsSdkLibDir='C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\'
155      INCLUDE="${WindowsSdkIncludeDir}um;${WindowsSdkIncludeDir}shared;$INCLUDE"
156      LIB="${WindowsSdkLibDir}x64;$LIB"
158      # Visual C++ tools, headers and libraries.
159      VSINSTALLDIR='C:\Program Files (x86)\Microsoft Visual Studio 14.0'
160      VCINSTALLDIR="${VSINSTALLDIR}"'\VC'
161      PATH=`cygpath -u "${VCINSTALLDIR}"`/bin/amd64:"$PATH"
162      INCLUDE="${VCINSTALLDIR}"'\include;'"${INCLUDE}"
163      LIB="${VCINSTALLDIR}"'\lib\amd64;'"${LIB}"
165      export INCLUDE LIB
167    Building 32-bit binaries with MSVC is achieved through the following
168    preparation, configure, and build commands:
170       PATH=/usr/local/msvc32/bin:$PATH
171       export PATH
173       win32_target=_WIN32_WINNT_WINXP   # for MSVC 9.0
174       win32_target=_WIN32_WINNT_VISTA   # possibly for MSVC >= 10.0
175       win32_target=_WIN32_WINNT_WIN7    # possibly for MSVC >= 10.0
176       win32_target=_WIN32_WINNT_WIN8    # possibly for MSVC >= 10.0
178       ./configure --host=i686-w64-mingw32 --prefix=/usr/local/msvc32 \
179             CC="$HOME/msvc/compile cl -nologo" \
180             CFLAGS="-MD" \
181             CXX="$HOME/msvc/compile cl -nologo" \
182             CXXFLAGS="-MD" \
183             CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc32/include" \
184             LDFLAGS="-L/usr/local/msvc32/lib" \
185             LD="link" \
186             NM="dumpbin -symbols" \
187             STRIP=":" \
188             AR="$HOME/msvc/ar-lib lib" \
189             RANLIB=":"
190       make
191       make check
193    Building 64-bit binaries with MSVC is achieved through the following
194    preparation, configure, and build commands:
196       PATH=/usr/local/msvc64/bin:$PATH
197       export PATH
199       win32_target=_WIN32_WINNT_WINXP   # for MSVC 9.0
200       win32_target=_WIN32_WINNT_VISTA   # possibly for MSVC >= 10.0
201       win32_target=_WIN32_WINNT_WIN7    # possibly for MSVC >= 10.0
202       win32_target=_WIN32_WINNT_WIN8    # possibly for MSVC >= 10.0
204       ./configure --host=x86_64-w64-mingw32 --prefix=/usr/local/msvc64 \
205             CC="$HOME/msvc/compile cl -nologo" \
206             CFLAGS="-MD" \
207             CXX="$HOME/msvc/compile cl -nologo" \
208             CXXFLAGS="-MD" \
209             CPPFLAGS="-D_WIN32_WINNT=$win32_target -I/usr/local/msvc64/include" \
210             LDFLAGS="-L/usr/local/msvc64/lib" \
211             LD="link" \
212             NM="dumpbin -symbols" \
213             STRIP=":" \
214             AR="$HOME/msvc/ar-lib lib" \
215             RANLIB=":"
216       make
217       make check
219    Installation:
221       make install
223 ===============================================================================
224 3) Binaries for the Cygwin environment.
226    The generic instructions in the INSTALL file apply. But here are more
227    specific ones.
229    You need to install
230      * Cygwin (from https://cygwin.com/),
231      * some packages available from the Cygwin package installer:
232          make
233      * the Cygwin [cross-]compilation tools package, available from
234        the Cygwin package installer (setup-x86_64.exe):
235        - for creating 32-bit binaries: packages
236            cygwin32-gcc-core,
237            cygwin32
238        - for creating 64-bit binaries: packages
239            gcc-core
241    Building 32-bit binaries for Cygwin must be done in a directory *outside*
242    the Cygwin /home and /usr hierarchies. It is achieved through the following
243    preparation, configure, and build commands:
245       PATH=/usr/local/cygwin32/bin:/usr/i686-pc-cygwin/sys-root/usr/bin:$PATH
246       export PATH
247       ./configure --host=i686-pc-cygwin --prefix=/usr/local/cygwin32 \
248             CC=i686-pc-cygwin-gcc \
249             CPPFLAGS="-I/usr/local/cygwin32/include -Wall" \
250             LDFLAGS="-L/usr/local/cygwin32/lib"
251       make
252       make check
254    Building 64-bit binaries for Cygwin is achieved through the following
255    preparation, configure, and build commands:
257       PATH=/usr/local/cygwin64/bin:$PATH
258       export PATH
259       ./configure --host=x86_64-pc-cygwin --prefix=/usr/local/cygwin64 \
260             CC=x86_64-pc-cygwin-gcc \
261             CPPFLAGS="-I/usr/local/cygwin64/include -Wall" \
262             LDFLAGS="-L/usr/local/cygwin64/lib"
263       make
264       make check
266    Installation:
268       make install
270 ===============================================================================