Difference between revisions of "MITK MinGW Compatibility"
SaschaZelzer (talk | contribs) |
SaschaZelzer (talk | contribs) |
||
Line 23: | Line 23: | ||
==== VTK ==== | ==== VTK ==== | ||
− | + | VTK 5.4.2 contains a buggy freetype library, so you have to compile it yourself first. You are advised to install [http://www.mingw.org/wiki/MSYS MSYS] (download [http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe 1.0.11]) for the compilation process (you will need it for MITK later on too). | |
− | * Select the " | + | * Get [http://mirrors.zerg.biz/nongnu/freetype/freetype-2.3.11.tar.gz freetype 2.3.11] or newer (only tested with 2.3.11) and unpack it in a temporary directory, for example c:\tmp |
+ | * Open a MSYS shell, and type: | ||
+ | |||
+ | <pre><nowiki> | ||
+ | cd /c/tmp/freetype-2.3.11 | ||
+ | ./configure | ||
+ | make -j4 | ||
+ | make install | ||
+ | </nowiki></pre> | ||
+ | |||
+ | |||
+ | Get VTK 5.4.2 and configure it with CMake: | ||
+ | |||
+ | * Select the "MSYS Makefiles" generator | ||
* Check BUILD_SHARED_LIBS | * Check BUILD_SHARED_LIBS | ||
* Set CMAKE_BUILD_TYPE to "Release" (or "Debug", if you want to debug VTK) | * Set CMAKE_BUILD_TYPE to "Release" (or "Debug", if you want to debug VTK) | ||
* Uncheck either CMAKE_USE_PTHREADS or CMAKE_USE_WIN32_THREADS (tested only with CMAKE_USE_WIN32_THREADS set to "ON") | * Uncheck either CMAKE_USE_PTHREADS or CMAKE_USE_WIN32_THREADS (tested only with CMAKE_USE_WIN32_THREADS set to "ON") | ||
* Check VTK_USE_PARALLEL and VTK_USE_GUISUPPORT | * Check VTK_USE_PARALLEL and VTK_USE_GUISUPPORT | ||
+ | * Check VTK_USE_SYSTEM_FREETYPE | ||
* Uncheck VTK_USE_VIDEO4WINDOWS (MinGW does not provide headers for it) | * Uncheck VTK_USE_VIDEO4WINDOWS (MinGW does not provide headers for it) | ||
* (optional) Uncheck VTK_USE_GEOVIS, VTK_USE_INFOVIS, and VTK_USE_VIEWS (not needed for MITK) | * (optional) Uncheck VTK_USE_GEOVIS, VTK_USE_INFOVIS, and VTK_USE_VIEWS (not needed for MITK) | ||
* Change other options as you see fit | * Change other options as you see fit | ||
− | Run configure, set the DESIRED_QT_VERSION variable to "4" | + | Run configure, set the DESIRED_QT_VERSION variable to "4" and configure freeetype: |
+ | |||
+ | * FREETYPE_INCLUDE_DIR_freetype2 = "C:/msys/1.0/local/include/freetype2" | ||
+ | * FREETYPE_INCLUDE_DIR_ft2build = "C:/msys/1.0/local/include" | ||
+ | * FREETYPE_LIBRARY = "C:/msys/1.0/local/bin/freetype-6.dll" | ||
+ | |||
+ | Run configure until there are no new variables and generate MSYS makefiles. You can now open a MSYS shell and cd into your VTK binary directory. Due to another "bug" in the VTK CMake scripts, you also need to hint gcc at the include directories for freetype: | ||
+ | |||
+ | |||
+ | <pre><nowiki> | ||
+ | cd /c/toolkits/vtk5.4.2/ | ||
+ | export CPLUS_INCLUDE_PATH=/usr/local/include:/usr/local/include/freetype2 | ||
+ | make -j4 | ||
+ | </nowiki></pre> | ||
+ | |||
==== MITK ==== | ==== MITK ==== | ||
− | Due to a buffer size limit of 8K for command line arguments in cmd.exe, MITK has to be build by using a build-system which uses a shell without this limitation. | + | Due to a buffer size limit of 8K for command line arguments in cmd.exe, MITK has to be build by using a build-system which uses a shell without this limitation. If you have not built VTK using MSYS, look above on how to obtain it. You don't need to put the bin folder of your MSYS installation into your PATH environment variable (this may have unwanted side-effects), just use the absolute path to MSYS make.exe if you are not inside a MSYS shell. |
* Select the "MSYS Makefiles" generator | * Select the "MSYS Makefiles" generator | ||
Line 46: | Line 74: | ||
* If you want to use the supplied application ([[ExtApp]]), enable specific bundles by checking any of the MITK_BUILD_org.mitk variables. | * If you want to use the supplied application ([[ExtApp]]), enable specific bundles by checking any of the MITK_BUILD_org.mitk variables. | ||
− | Run configure until there are no new variables and generate the MSYS makefiles. You can now open a MSYS shell, cd into your MITK binary directory and execute "make.exe -j4" (if you got 4 CPU cores). See below for Qt Creator integration. | + | Run configure until there are no new variables and generate the MSYS makefiles. You can now open a MSYS shell, cd into your MITK binary directory and execute "make.exe -j4" (if you got 4 CPU cores). In order to start ExtApp, you need to include the directories containing the ITK, VTK, freetype and openCherry OSGi libraries (.dll files) in your PATH environment variable. Inside a MSYS shell, you can type: |
+ | |||
+ | <pre><nowiki> | ||
+ | export PATH=$PATH:/<vtk-binary-tree>/bin:/<itk-binary-tree>/bin:/usr/local/bin:/<mitk-binary-tree>/bin/openCherry/org.opencherry.osgi/bin | ||
+ | </nowiki></pre> | ||
+ | |||
+ | |||
+ | See below for Qt Creator integration. | ||
==== MITK and Qt Creator ==== | ==== MITK and Qt Creator ==== | ||
Line 57: | Line 92: | ||
* Set-up your project by choosing the CMake configured binary tree as build directory, and use the absolute path to your MSYS make.exe as make command. | * Set-up your project by choosing the CMake configured binary tree as build directory, and use the absolute path to your MSYS make.exe as make command. | ||
* Add additional build configurations for special targets like "ExtApp". | * Add additional build configurations for special targets like "ExtApp". | ||
− | * Create a new run configuration and add the paths to the bin directories of ITK and | + | * Create a new run configuration and add the paths to the bin directories of ITK, VTK, and freetype (C:\msys\1.0\usr\local\bin) to the PATH variable of your run environment. You may also need to add the bin paths for Qt and <mitk-binary-dir>/bin/openCherry/org.opencherry.osgi/bin. |
This should enable you to develop MITK-based programs with Qt Creator. | This should enable you to develop MITK-based programs with Qt Creator. |
Revision as of 20:04, 18 December 2009
MITK MinGW Compatibility
Compiling MITK with MinGW on Windows
MITK now supports MinGW (gcc 4.4.0), which means you can use gcc under Windows to compile native libraries and executables. In order to use MinGW as a toolchain, all dependent libraries (Qt, ITK, and VTK) must be compiled with gcc too. Read Build Requirements for general information.
The easy way
To make your life simpler, you should install a Qt SDK based on Qt 4.6 (if you do not want to use Qt, see the not so easy way below). This gives you a MinGW compiled Qt 4.6, Qt Creator, and MinGW itself. For convenience, you should add the "bin" folder of the MinGW installation in your Qt directory to the PATH environment variable. Then build ITK and VTK.
ITK
Get ITK (tested for version 3.16) and configure it with CMake:
- Select the "MinGW Makefiles" generator
- Check BUILD_SHARED_LIBS
- Set CMAKE_BUILD_TYPE to "Release" (or "Debug", if you want to debug ITK)
- Uncheck either CMAKE_USE_PTHREADS or CMAKE_USE_WIN32_THREADS (tested only with CMAKE_USE_WIN32_THREADS set to "ON")
- Change other options as you see fit
Run configure and generate to generate MinGW makefiles. You can now open a command prompt, cd into your ITK binary directory and execute "mingw32-make.exe".
VTK
VTK 5.4.2 contains a buggy freetype library, so you have to compile it yourself first. You are advised to install MSYS (download 1.0.11) for the compilation process (you will need it for MITK later on too).
- Get freetype 2.3.11 or newer (only tested with 2.3.11) and unpack it in a temporary directory, for example c:\tmp
- Open a MSYS shell, and type:
cd /c/tmp/freetype-2.3.11 ./configure make -j4 make install
Get VTK 5.4.2 and configure it with CMake:
- Select the "MSYS Makefiles" generator
- Check BUILD_SHARED_LIBS
- Set CMAKE_BUILD_TYPE to "Release" (or "Debug", if you want to debug VTK)
- Uncheck either CMAKE_USE_PTHREADS or CMAKE_USE_WIN32_THREADS (tested only with CMAKE_USE_WIN32_THREADS set to "ON")
- Check VTK_USE_PARALLEL and VTK_USE_GUISUPPORT
- Check VTK_USE_SYSTEM_FREETYPE
- Uncheck VTK_USE_VIDEO4WINDOWS (MinGW does not provide headers for it)
- (optional) Uncheck VTK_USE_GEOVIS, VTK_USE_INFOVIS, and VTK_USE_VIEWS (not needed for MITK)
- Change other options as you see fit
Run configure, set the DESIRED_QT_VERSION variable to "4" and configure freeetype:
- FREETYPE_INCLUDE_DIR_freetype2 = "C:/msys/1.0/local/include/freetype2"
- FREETYPE_INCLUDE_DIR_ft2build = "C:/msys/1.0/local/include"
- FREETYPE_LIBRARY = "C:/msys/1.0/local/bin/freetype-6.dll"
Run configure until there are no new variables and generate MSYS makefiles. You can now open a MSYS shell and cd into your VTK binary directory. Due to another "bug" in the VTK CMake scripts, you also need to hint gcc at the include directories for freetype:
cd /c/toolkits/vtk5.4.2/ export CPLUS_INCLUDE_PATH=/usr/local/include:/usr/local/include/freetype2 make -j4
MITK
Due to a buffer size limit of 8K for command line arguments in cmd.exe, MITK has to be build by using a build-system which uses a shell without this limitation. If you have not built VTK using MSYS, look above on how to obtain it. You don't need to put the bin folder of your MSYS installation into your PATH environment variable (this may have unwanted side-effects), just use the absolute path to MSYS make.exe if you are not inside a MSYS shell.
- Select the "MSYS Makefiles" generator
- If Qt has not been found, enter the path to qmake.exe in QT_QMAKE_EXECUTABLE (if you use the Qt SDK, it is located in your installation directory under qt/bin/qmake.exe)
- Enter "Release" or "Debug" in CMAKE_BUILD_TYPE
- Enter the path to your binary ITK and VTK directory in ITK_DIR and VTK_DIR
- If you want to use the supplied application (ExtApp), enable specific bundles by checking any of the MITK_BUILD_org.mitk variables.
Run configure until there are no new variables and generate the MSYS makefiles. You can now open a MSYS shell, cd into your MITK binary directory and execute "make.exe -j4" (if you got 4 CPU cores). In order to start ExtApp, you need to include the directories containing the ITK, VTK, freetype and openCherry OSGi libraries (.dll files) in your PATH environment variable. Inside a MSYS shell, you can type:
export PATH=$PATH:/<vtk-binary-tree>/bin:/<itk-binary-tree>/bin:/usr/local/bin:/<mitk-binary-tree>/bin/openCherry/org.opencherry.osgi/bin
See below for Qt Creator integration.
MITK and Qt Creator
Qt Creator 1.3 does not yet support MSYS based CMake projects (watch this bug report for progress on this issue). Follow the points below to build MITK with Qt Creator.
If you want to develop your own project (bundle, shared library, etc.) which depends on MITK, you should place your source code outside of MITK (see for example How to create a new MITK Plug-in). You should be able to apply the steps below to your external project.
- Import your MITK source project by choosing "Import of Makefile-based Project" after clicking on "File -> New File or Project...".
- Set-up your project by choosing the CMake configured binary tree as build directory, and use the absolute path to your MSYS make.exe as make command.
- Add additional build configurations for special targets like "ExtApp".
- Create a new run configuration and add the paths to the bin directories of ITK, VTK, and freetype (C:\msys\1.0\usr\local\bin) to the PATH variable of your run environment. You may also need to add the bin paths for Qt and <mitk-binary-dir>/bin/openCherry/org.opencherry.osgi/bin.
This should enable you to develop MITK-based programs with Qt Creator.
The not so easy way
If you don't want to install the Qt SDK or don't want to use Qt at all, you have to install MinGW yourself. Create a new directory, for example C:\MinGW and unpack the following files from http://sourceforge.net/projects/mingw/files/ (or newer versions) into this directory:
- GCC current release (tested with ggc-4.4.0):
- Core bin and dll:
- gcc-core-4.4.0-mingw32-bin.tar.gz
- gcc-core-4.4.0-mingw32-dll.tar.gz
- Core bin and dll:
- C++ bin and dll:
- gcc-c++-4.4.0-mingw32-bin.tar.gz
- gcc-c++-4.4.0-mingw32-dll.tar.gz
- Gmp dll:
- gmp-4.2.4-mingw32-dll.tar.gz
- Mpfr dll:
- mpfr-2.4.1-mingw32-dll.tar.gz
- GNU Binutils current release bin
- binutils-2.19.1-mingw32-bin.tar.gz
- GNU Make current release bin
- mingw32-make-3.81-2.tar.gz
- MinGW API for MS-Windows current release
- w32api-3.13-mingw32-dev.tar.gz
- MinGW Runtime current release
- mingw-runtime-3.14.tar.gz
For convenience, you should add "C:\MinGW\bin" to your PATH environment variable. Now proceed with compiling ITK, VTK and MITK as explained above.
Some random information
- Qt 4.5.3 comes with a very old MinGW (gcc 3.4.2)
- Qt 4.6 is compiled with a recent gcc (4.4.0)
- The Qt SDK based on Qt 4.6 comes with MinGW, which can be used just fine
- The MinGW automated installer is not up-to-date (it installs gcc 3.4.5). However, this is still too new to use with Qt 4.5.3 (the installer will refuse to work with the MinGW version installed via the automated installer).
- ITK 3.14 and VTK 5.4.2 compile fine with MinGW from Qt 4.5.3
- ITK 3.16 and VTK 5.4.2 compile with MinGW (gcc 4.4) from Qt Creator 1.3 RC (update: and above)
- Poco does not compile with MinGW from Qt 4.5.3 (the win32api headers are too old)
- DCMTK 3.5.4 will not compile with MinGW (tested for gcc 4.4). You will need this patch Media:MinGW_Instructions$dcmtk-3.5.4-mingw.patch.
- The mitkCore does not link to ITK due to multiple definitions of the same symbol present in libITKCommon.dll and libitkvnl.a (for ITK 3.14)
- MITK links fine to ITK 3.16
- MinGW libraries and executables seem to contain some debugging info even in release mode. CPack has an option CPACK_STRIP_FILES which strips the information from the files during packaging. One can also manually set the CMake variables CMAKE_EXE_LINKER_FLAGS_RELEASE and CMAKE_SHARED_LINKER_FLAGS_RELEASE to "-s" for ITK, VTK and MITK to strip the files during linking.
- The CMake MinGW generator cannot be used on Windows for MITK. mingw32-make spawns calls to gcc via cmd.com which has a command line buffer limit of 8k. This buffer size is easily exceeded in MITK by supplying a lot of include paths to gcc.
- The only way right now to compile MITK with MinGW on Windows is to use MSYS and the MSYS make.exe. Use the CMake MSYS generator.
- Qt Creator does not support the CMake MSYS generator yet. The project must be imported as a Makefile Project and set up by hand.
- Calling ctest from within a MSYS shell leads to problems for openCherry tests. Usually, command line arguments are preceded by a "/" under Windows but for MSYS, it must be "//".
Cross-compiling MITK with MinGW on Fedora 11
- ITK needs to be patched because of the use of a generated executable in a custom cmake command (or make your Linux start .exe files automagically with wine). Further, linking to the ITK libraries will result in "multiple definitions" errors for symbols being found in static ITK utility libraries and the shared ITK libraries (to which the static libraries have been linked before for ITK 3.14, resolved in 3.16).
- VTK compiles fine when INFOVIS, GEOVIS, USE_VIEWS, etc. is disabled
- MITK compiles and links against Qt, VTK and ITK within SVN Head