This page is incomplete and needs more work. Please refer to new updated wiki page for setting up OTB development on Windows
MinGW provides a nice installer which mimics the old Debian Package Manager a.k.a Synaptic Package Manager that makes our life easier to setup the GNU GCC build chain on windows. We used MinGW32 build chain for GCC 4.8.1 through out this tutorial. The version of all libraries mentioned in this page were used at the time of writing this tutorial.
We assume that you dont have any previous MinGW installation available in your system
- Download the latest installer from their sourceforge page here
- Open MinGW installer.
- Please refer to Getting Started page before starts installing MinGW.
- Select install location. Default is C:\MinGW. Remember you need to add MinGW\bin later to environment variables.
Install CMake, CMake Gui
- Download cmake 2.8 or higher.
You need Mercurial version control tools as you are going to clone OTB and its relative repositories (OTB-Data, Ice, Monteverdi2). I used TortoiseHg available for windows. If you insist on clone dependencies used by OTB you probably need other version control tools (almost all other types) subversion (GDAL, OSSIM, GEOS), Git (ITK). All these have a windows Gui interface like TortoiseHg. Please refer to download page for more download options.
You can download Eclipse with CDT plugin from eclipse.org. Eclipse IDE is used as an alternative to Visual Studio IDE. Eclipse is not mandatory in building OTB but as CMake provide a specific generator for MinGW CDT4 Eclipse but we choose this for the tutorial.
Common Build instructions
- Open MSYS shell. Its installed in C:\MinGW\msys\1.0\bin\msys.bat. MinGW installer does not create a shortcut for msys on desktop. So at this point you may need to create one as we are going to open this shell a lot.
- Go to C:\sources\ from msys shell.
[ Note: /c/sources/ instead of C:\sources\ To know more about this please refer to Getting Started ]
We also use internal libtiff and geotiff for gdal and use the same geotiff sources when building ossim.
$ cd gdal-1.10.1 $ ./configure $ make
Note: Latest stable release of GDAL 1.10.1 has a bug when compiling on MinGW. This was related to freeaddrinfo. A patch has been provided in the gdal bug tracker. For more details see the corresponding ticket You need to apply this patch with GDAL =< 1.10.1.
$ make install
After this you will have gdal installed in C:\MinGW\msys\1.0\local\
- Open cmake-gui.exe
- Select source directory. I have c:\sources\Insight-Toolkit-4.5.1
- Select build directory. I created c:\build\itk-mingw32
- Click Configure
- For generators, choose Eclipse CDT4 MinGW Makefiles
- Select Specify native compilers
- Update C and C++ compilers with gcc.exe and g++.exe respectively from C:\MinGW\bin\
After first configure finishes I updated some cmake settings.
check BUILD_SHARED_LIBS uncheck BUILD_EXAMPLES uncheck BUILD_TESTING Set CMAKE_ECLIPSE_EXECUTABLE C:\eclipse\eclipse.exe Update CMAKE_INSTALL_PREFIX C:\install\ITK
- click configure again!
- click Generate.
At here you have an eclipse project file ready in your build directory. So you can open you eclipse editor
- File -> Import -> Existing Projects into Workspace
- Browse to c:\build\itk-mingw32 as the root directory.
- Leave all other settings to default
Note: If you have any doubt regarding import of projects into eclipse. You can find tons of tutorials on web.
After the import is finished. You can start building itk by right click on the project. Choose Make Targets -> Build. Scroll down to bottom and select all. After build is finished you can repeat the above procedure and select install and you will itk libraries and headers installed in C:\install\ITK
OSSIM depends on GEOS and OpenThreads. If you want to use internal ossim available with OTB. You can skip this section and its subsection. This is because internal OTB doesnot require GEOS and for OpenThreads it has an internal version. You can use internal version by turning ON some CMake Flags
Building GEOS is pretty straight forward. You want to follow the same procedure as GDAL.
- Open MSYS shell
cd to /c/sources/geos-3.4.2 configure make make install
After this you will have geos installed in C:\MinGW\msys\1.0\local\
OpenThreads source code is available from its sourceforget page. But this seems to be highly outdated to use in any project. OpenSceneGraph library maintains this library now actively. Hence source code has been downloaded from OpenSceneGraph svn
- Checkout source code from the above svn link. I used TorotiseSVN for this purpose.
- Open CMake-gui
- Select source directory: C:\sources\OpenThreads-3.2
- Select build directory: C:\build\OpenThreds-3.2
- Set CMAKE_INSTALL_PREFIX C:\install\OpenThreds
- Click Configure and Generate
Note: If you had selected Eclipse CDT MinGW Makefile as mentioned in ITK build steps, At this point will have an eclipse project ready to be imported. Even if you specify Eclipse CDT MinGW generator at Cmake gui, You are not restricted from using command prompt on Windows. So I will build this library from windows command prompt. (Note: MinGW Make files are not very happy when you ask them to work from MSYS shell. So here you need to use mingw32-make instead of make which you used in case of GDAL and GEOS.
Open cmd.exe cd C:\build\OpenThreads-3.2 mingw32-make mingw32-make install
You need to follow the same procedure from ITK build for building OSSIM library using CMake.
- Open cmake-gui
- Select source directory: C:\sources\ossim_trunk\ossim
- Select build directory: C:\build\ossim
- Turn on shared libs: BUILD_SHARED_LIBS
- Add a new Cmake variable CMAKE_MODULE_PATH. This is a FilePath variable. Set its value to "C:\sources\ossim_trunk\ossim\ossim_package_support\cmake\CMakeModules"
- Turn off MPI support: BUILD_OSSIM_MPI_SUPPORT OFF
- If configure gives error for OpenThreads and or GEOS.
- Point he include, lib dirs to their install location --revisit this--
- As you are using internal geotiff from gdal. You need to use the same for building OSSIM.
- So for GEOTIFF_INCLUDE_DIR, Browse to c:\sources\gdal-1.10.1\frmts\gtiff --revisit this--
- and for GEOTIFF_LIBRARY, Browse to c:\MinGW\msys\1.0\local\bin\libgdal.so --revisit this--
- Click Configure and select Eclipse CDT MinGW Makefiles for generator
- Click Generate
- Import the project into Eclipse
- Build inside Eclipse
- Project -> Make Targets -> all
- Install from Eclipse
- Project -> Make Targets -> install
As of writing this wiki page. Some of the dependencies in OTB/Utilities are outdated hence we use an external version of them. Outdated libs are:- ITK, OpenThreads, expat, OSSIM.
Below is a cmake script which can be used as intial cache: cmake.exe -C OTB-MingW.cmake Another cmake script for dashboard submission can be found in Dev-Utils repository ctest-script
MXE Cross Compilation
OTB binaries can be created even without using Windows OS!. This is achieved via MXE cross compilation. Those who wish can give it a spin with the help of scripts in DevUtils repository. A Nightly submission is setup for Fedora linux on dashboard