[Qt] Compiling ICU with MSVC (Microsoft Visual Studio)
Link to original article: http://qt-project.org/wiki/Compiling-ICU-with-MSVC
Text highlighted and notes added
Compiling ICU with MSVC (Microsoft Visual Studio)
Qt 5 / QtWebkit requires ICU.
Pre-built packages
The ICU Project site [site.icu-project.org] provides pre-built packages for MSVC 2010, which should work with compilers too. Anyhow, you have to compile your own version if you want to avoid the MSVC 2010 runtime dependency (because you’re using another MSVC version), or want to tailor the ICU configuration.
Compiling on your own
Requirements
- MSVC toolchain
How to build
- Download latest ICU4C source code from http://site.icu-project.org/download (e.g.icu4c-53_1-src.zip), unzip
- Make sure you’ve e.g. ‘make’ installed for Cygwin
- Start cmd.exe and put Cygwin in PATH, convert line endings
- C:\icu\source> set PATH=C:\cygwin\bin;%PATH%
- C:\icu\source> dos2unix *
- C:\icu\source> dos2unix -f configure
NOTE: for PostgreSQL plugin I added it to configure as
-I "C:\Program Files (x86)\PostgreSQL\9.1\include" -L "C:\Program Files (x86)\PostgreSQL\9.1\lib" -l libpq
I tried to add icu library in the same way but it seems like these options are directly passed on to the compiler and configure script doesn’t consider them. So we need these set commands.
Check whether you have e.g. the MSVC compiler (cl.exe) in PATH. If not, set it up by calling e.g.
- C:\icu\source> "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
Run configure && build:
- C:\icu\source> bash runConfigureICU Cygwin/MSVC --prefix=/cygdrive/c/icu/dist
This will generate a release shared build that you can use in both a debug and release build of Qt.
To link ICU statically (e.g. for a static release build of Qt), you have to append ‘—enable-static —disable-shared’ :
- C:\icu\source> bash runConfigureICU Cygwin/MSVC --prefix=/cygdrive/c/icu/dist --enable-static --disable-shared
To link ICU statically and build it in debug mode (e.g. for a static debug build of Qt), you have to prepend ‘—enable-debug —disable-release’ to the arguments:
- C:\icu\source> bash runConfigureICU --enable-debug --disable-release Cygwin/MSVC --prefix=/cygdrive/c/icu/dist --enable-static --disable-shared
Finally, run make && make install
- C:\icu\source> make && make install
Usage
Add the include, lib folders to your compilation environment, e.g. for cmd.exe :
- C:\icu\source> set PATH=%PATH%;C:\icu\dist\lib
- C:\icu\source> set INCLUDE=%INCLUDE%;C:\icu\dist\include
- C:\icu\source> set LIB=%LIB%;C:\icu\dist\lib
When you now run Qt’s configure.exe ICU should be detected, and Qt links against the libraries.
Comments
Post a Comment