Compiling-ICU-with-MinGW: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
==Compiling <span class="caps">ICU</span> with MinGW (for adding Unicode support)==
[[Category:Windows]]<br />[[Category:Qt5]]<br />[[Category:ICU]]


Qt 5 / QtWebkit requires <span class="caps">ICU</span>, which MinGW distributions do not ship.
== Compiling ICU with MinGW (for adding Unicode support) ==


==Pre-built packages==
Qt 5 / QtWebkit requires ICU, which MinGW distributions do not ship.


The [http://site.icu-project.org/download <span class="caps">ICU</span> Project site] ''[site.icu-project.org]'' provides pre-compiled libraries for both 32 and 64 bit. However, these depend on the Microsoft Visual C++ 2010 runtime being installed.
== Pre-built packages ==


[http://download.qt.io/development_releases/prebuilt/icu/prebuilt/mingw/ download.qt.io] ''[download.qt.io]'' also hosts packages for the MinGW toolchains Qt ships.
The &quot;ICU Project site&amp;quot;:http://site.icu-project.org/download provides pre-compiled libraries for both 32 and 64 bit. However, these depend on the Microsoft Visual C++ 2010 runtime being installed.


Inside MSYS2 shell, a pre-built <span class="caps">ICU</span> can be obtained. MSYS2 also contains pre-built dynamic Qt &amp; QtCreator (and static Qt) with <span class="caps">ICU</span> &amp; OpenSSL support.
&quot;download.qt.io&amp;quot;:http://download.qt.io/development_releases/prebuilt/icu/prebuilt/mingw/ also hosts packages for the MinGW toolchains Qt ships.


==Compiling on your own==
Inside MSYS2 shell, a pre-built ICU can be obtained. MSYS2 also contains pre-built dynamic Qt &amp; QtCreator (and static Qt) with ICU &amp; OpenSSL support.


===Requirements===
== Compiling on your own ==


* Either use <span class="caps">MSYS</span> or use [[MSYS2]].
=== Requirements ===
** <span class="caps">MSYS</span> shell command prompt (an sh shell + some <span class="caps">UNIX</span> tools, get it from http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download?use_mirror=garr. It’s also an (optional) part of mingw.org installer.)
 
** [[MSYS2]] shell command prompt, (similar to <span class="caps">MSYS</span>), it can be obtained from https://msys2.github.io/
* Either use MSYS or use [[MSYS2]].  
** MSYS shell command prompt (an sh shell + some UNIX tools, get it from http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/msys-1.0.11/MSYS-1.0.11.exe/download?use_mirror=garr. It's also an (optional) part of mingw.org installer.)
** [[MSYS2]] shell command prompt, (similar to MSYS), it can be obtained from https://msys2.github.io/  
* Working MinGW, or MinGW-w64 toolchain.
* Working MinGW, or MinGW-w64 toolchain.
** Load MinGW or MinGW-w64 toolchains.
** Load MinGW or MinGW-w64 toolchains.
** <span class="caps">NOTE</span>: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, targeted for same platform/OS. If you are using MinGW-w64 toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for building main project &amp; all of its sub-components, use same MSYS2 toolchains. If you are using MinGW toolchain, then for building all of your sub-components &amp; main project, use same MinGW toolchain. If you are using MinGW-w64 toolchains from “MinGW-builds”, then for building all sub-components &amp; main project, use same MinGW-builds toolchains.
** NOTE: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, targeted for same platform/OS. If you are using MinGW-w64 toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for building main project &amp; all of its sub-components, use same MSYS2 toolchains. If you are using MinGW toolchain, then for building all of your sub-components &amp; main project, use same MinGW toolchain. If you are using MinGW-w64 toolchains from &quot;MinGW-builds&amp;quot;, then for building all sub-components &amp; main project, use same MinGW-builds toolchains.


===How to build===
=== How to build ===


* Download latest ICU4C source code from http://site.icu-project.org/download (e.g. icu4c-52_1-src.zip), unzip
* Download latest ICU4C source code from http://site.icu-project.org/download (e.g. icu4c-52_1-src.zip), unzip
* Either start <span class="caps">MSYS</span>-shell, or start MSYS2-shell:
* Either start MSYS-shell, or start MSYS2-shell:
** Start a <span class="caps">MSYS</span> shell command prompt (C:\msys\1.0\msys.bat)
** Start a MSYS shell command prompt (C:.0\msys.bat)
** Or, start MSYS2 shell command prompt (C:\msys2\msys2_shell.bat)
** Or, start MSYS2 shell command prompt (C:2\msys2_shell.bat)
*** See in [[MSYS2]] page, how to prepare MSYS2-shell with build/compile related tools &amp; dependencies &amp; toolchains
*** See in [[MSYS2]] page, how to prepare MSYS2-shell with build/compile related tools &amp; dependencies &amp; toolchains  
 
* Inside <span class="caps">MSYS</span> or MSYS2 shell, run/execute below command:<br />
 
* Check that gcc is in <span class="caps">PATH</span>, otherwise add it:
** If using <span class="caps">MSYS</span> shell, and if MinGW (32bit) is installed inside /c/mingw32 (C:\mingw32\) directory, then execute this:<br />
** If using MSYS2 shell, execute this, if you are building for 32bit:<br />
** If using MSYS2 shell, execute this, if you are building for 64bit:<br />


* Run configure &amp;&amp; build:<br /> This will generate a release shared build that you can use in both a debug and release build of Qt.
* Inside MSYS or MSYS2 shell, run/execute below command:<br /><code><br />&amp;#36; cd icu/source<br /></code>


* To link <span class="caps">ICU</span> statically (e.g. for a static release build of Qt), you have to append ‘—enable-static —disable-shared’ :<br />
* Check that gcc is in PATH, otherwise add it:
** If using MSYS shell, and if MinGW (32bit) is installed inside /c/mingw32 (C:32 directory, then execute this:<br /><code><br />&amp;#36; export PATH=&quot;/c/mingw32/bin:&amp;#36;PATH&amp;quot;<br /></code>
** If using MSYS2 shell, execute this, if you are building for 32bit:<br /><code><br />&amp;#36; export PATH=&quot;/c/msys2/mingw32/bin:&amp;#36;PATH&amp;quot;<br /></code>
** If using MSYS2 shell, execute this, if you are building for 64bit:<br /><code><br />$ export PATH=&quot;/c/msys2/mingw64/bin:&amp;#36;PATH&amp;quot;<br /></code>


* To link <span class="caps">ICU</span> 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:<br />
* Run configure &amp;&amp; build:<br /><code><br />&amp;#36; ./runConfigureICU MinGW —prefix=&amp;#36;PWD/../dist<br /></code><br /> This will generate a release shared build that you can use in both a debug and release build of Qt.


* Finally, run make &amp;&amp; make install<br />
* To link ICU statically (e.g. for a static release build of Qt), you have to append ‘—enable-static —disable-shared’ :<br /><code><br />&amp;#36; ./runConfigureICU MinGW —prefix=&amp;#36;PWD/../dist —enable-static —disable-shared<br /></code>


==Using it==
* 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:<br /><code><br />&amp;#36; ./runConfigureICU —enable-debug —disable-release MinGW —prefix=&amp;#36;PWD/../dist —enable-static —disable-shared<br /></code>


* Add the include, lib folders to your compilation environment, e.g. for cmd.exe (Cmd-shell) :<br />
* Finally, run make &amp;&amp; make install<br /><code><br />&amp;#36; make &amp;&amp; make install<br /></code>
* Add the include, lib folders to your compilation environment, e.g. for MSYS2-shell (or for <span class="caps">MSYS</span>-shell) :<br />


When you now run Qt’s configure.exe <span class="caps">ICU</span> should be detected, and Qt links against the libraries.
== Using it ==


===Categories:===
* Add the include, lib folders to your compilation environment, e.g. for cmd.exe (Cmd-shell) :<br /><code><br />C:gt; set PATH=&amp;#37;PATH&amp;amp;#37;;C:C:gt; set INCLUDE=&amp;#37;INCLUDE&amp;amp;#37;;C:C:gt; set LIB=&amp;#37;LIB&amp;amp;#37;;C:</code>
* Add the include, lib folders to your compilation environment, e.g. for MSYS2-shell (or for MSYS-shell) :<br /><code><br />&amp;#36; export PATH=&quot;&amp;#36;PATH:/c/icu/dist/lib&amp;quot;<br />&amp;#36; export INCLUDE=&quot;&amp;#36;INCLUDE:/c/icu/dist/include&amp;quot;<br />&amp;#36; export LIB=&quot;&amp;#36;LIB:/c/icu/dist/lib&amp;quot;<br /></code>


* [[:Category:ICU|ICU]]
When you now run Qt’s configure.exe ICU should be detected, and Qt links against the libraries.
* [[:Category:MinGW|MinGW]]
* [[:Category:Qt5|Qt5]]
* [[:Category:Windows|Windows]]

Revision as of 10:42, 23 February 2015



Compiling ICU with MinGW (for adding Unicode support)

Qt 5 / QtWebkit requires ICU, which MinGW distributions do not ship.

Pre-built packages

The "ICU Project site&quot;:http://site.icu-project.org/download provides pre-compiled libraries for both 32 and 64 bit. However, these depend on the Microsoft Visual C++ 2010 runtime being installed.

"download.qt.io&quot;:http://download.qt.io/development_releases/prebuilt/icu/prebuilt/mingw/ also hosts packages for the MinGW toolchains Qt ships.

Inside MSYS2 shell, a pre-built ICU can be obtained. MSYS2 also contains pre-built dynamic Qt & QtCreator (and static Qt) with ICU & OpenSSL support.

Compiling on your own

Requirements

  • Either use MSYS or use MSYS2.
  • Working MinGW, or MinGW-w64 toolchain.
    • Load MinGW or MinGW-w64 toolchains.
    • NOTE: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, targeted for same platform/OS. If you are using MinGW-w64 toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for building main project & all of its sub-components, use same MSYS2 toolchains. If you are using MinGW toolchain, then for building all of your sub-components & main project, use same MinGW toolchain. If you are using MinGW-w64 toolchains from "MinGW-builds&quot;, then for building all sub-components & main project, use same MinGW-builds toolchains.

How to build

  • Download latest ICU4C source code from http://site.icu-project.org/download (e.g. icu4c-52_1-src.zip), unzip
  • Either start MSYS-shell, or start MSYS2-shell:
    • Start a MSYS shell command prompt (C:.0\msys.bat)
    • Or, start MSYS2 shell command prompt (C:2\msys2_shell.bat)
      • See in MSYS2 page, how to prepare MSYS2-shell with build/compile related tools & dependencies & toolchains
  • Inside MSYS or MSYS2 shell, run/execute below command:
    <br />&amp;#36; cd icu/source<br />
    
  • Check that gcc is in PATH, otherwise add it:
    • If using MSYS shell, and if MinGW (32bit) is installed inside /c/mingw32 (C:32 directory, then execute this:
      <br />&amp;#36; export PATH=&quot;/c/mingw32/bin:&amp;#36;PATH&amp;quot;<br />
      
    • If using MSYS2 shell, execute this, if you are building for 32bit:
      <br />&amp;#36; export PATH=&quot;/c/msys2/mingw32/bin:&amp;#36;PATH&amp;quot;<br />
      
    • If using MSYS2 shell, execute this, if you are building for 64bit:
      <br />$ export PATH=&quot;/c/msys2/mingw64/bin:&amp;#36;PATH&amp;quot;<br />
      
  • Run configure && build:
    <br />&amp;#36; ./runConfigureICU MinGW prefix=&amp;#36;PWD/../dist<br />
    

    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’ :
    <br />&amp;#36; ./runConfigureICU MinGW prefix=&amp;#36;PWD/../dist enable-static disable-shared<br />
    
  • 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:
    <br />&amp;#36; ./runConfigureICU enable-debug disable-release MinGW prefix=&amp;#36;PWD/../dist enable-static disable-shared<br />
    
  • Finally, run make && make install
    <br />&amp;#36; make &amp;&amp; make install<br />
    

Using it

  • Add the include, lib folders to your compilation environment, e.g. for cmd.exe (Cmd-shell) :
    <br />C:gt; set PATH=&amp;#37;PATH&amp;amp;#37;;C:C:gt; set INCLUDE=&amp;#37;INCLUDE&amp;amp;#37;;C:C:gt; set LIB=&amp;#37;LIB&amp;amp;#37;;C:
    
  • Add the include, lib folders to your compilation environment, e.g. for MSYS2-shell (or for MSYS-shell) :
    <br />&amp;#36; export PATH=&quot;&amp;#36;PATH:/c/icu/dist/lib&amp;quot;<br />&amp;#36; export INCLUDE=&quot;&amp;#36;INCLUDE:/c/icu/dist/include&amp;quot;<br />&amp;#36; export LIB=&quot;&amp;#36;LIB:/c/icu/dist/lib&amp;quot;<br />
    

When you now run Qt’s configure.exe ICU should be detected, and Qt links against the libraries.