Windows native port¶
The previous section explained how to cross-build OpenTURNS from Linux to target Windows. This section gives hints in order to compile OpenTURNS natively with Microsoft Windows tools. This port has started since OpenTURNS 1.4 and is still in an early stage, any help from developers who are familiar with Windows environment will be greatly appreciated.
These instructions have been tested with Visual Studio 2010 on Windows 32 and 64 bits, but they should work with more recent versions too. Visual Studio Express Edition does not ship 64 bits compilers, but they can be installed from Windows SDKs, instructions can be easily found online. No Fortran compiler is required.
First of all, CMake must be installed, as well as C/C++ compilers. We will describe below how to use CMake with Visual Studio and Microsoft compilers, but CMake can also be used with other build systems (like NMake, for instance) and other compilers, see CMake documentation for further details.
The following programs are required in order to build OpenTURNS on Windows:
The following programs are optional, and we will show how to embed them into OpenTURNS:
Precompiled binaries for all these programs are available on http://sourceforge.net/projects/openturns/files/openturns/openturns-x.y. If you want to recompile them from sources, you may also have to install
The following programs are optional, and are currently not used by this native Windows port:
Some OpenTURNS components will thus not be available. If R is installed
on your computer, you should edit
openturns.conf and set
R-executable-command resource in order to let OpenTURNS use it. On
the other hand, as OpenTURNS is built without Python bindings, Python
scripts cannot be used afterwards.
In this tutorial, OpenTURNS dependencies are installed by following the
layout shown in figure [fig:win-inst-layout]. Below the top-level
directory are four configurations (Debug and Release for Windows 32 bits
or 64 bits). Of course, if you are only interested by a single
configuration, there is no need to create others. Each configuration
contains subdirectories for Boost, hmat-oss, LibXML2, muParser, OpenBLAS
and TBB programs. Each project contains one or several directories:
bin for DLLs,
include for header files, and
lib for static
For convenience, all libraries will be compiled as static libraries, except OpenBLAS.
Build and install OpenBLAS and TBB¶
For different reasons, OpenBLAS and TBB cannot be compiled along with
other dependencies. As explained on their site, OpenBLAS is currently
only supported on Windows with Mingw compiler. But binaries can be used
with Visual Studio, this is what we will do. Thus go to
http://sourceforge.net/projects/openblas/files/ and download Windows
binaries, for instance
OpenBLAS-v0.2.13-Win32.zip for Windows 32 bits, or
OpenBLAS-v0.2.13-Win64-int32.zip for Windows 64 bits.
Unzip these archives, and copy files to our installation folder:
Note that DLLs have been compiled with Mingw, and require some Mingw runtime libraries. They can be found in http://sourceforge.net/projects/openblas/files/v0.2.12/mingw32_dll.zip and http://sourceforge.net/projects/openblas/files/v0.2.12/mingw64_dll.zip. They are:
TBB comes with its own Visual Studio 2010 configuration file, but we did not find how to integrate it into the build system described below. Thus the easiest solution is to:
Download TBB sources from https://www.threadingbuildingblocks.org/download
Debug-MT, unless you know what you are doing).
If you want to build a static library, edit Properties, tab Configuration Properties, General, Configuration Type, as shown in figure [fig:vs-tbb-static]
Copy resulting libraries into installation folder:
include\tbbfolder into installation folders:
Build and install OpenTURNS¶
OpenBLAS and TBB are low level libraries. Other libraries use STL, and
care must be taken to avoid mismatch between runtime libraries. To this
end, we decided to use a so called SuperBuild approach with CMake. We
defined a metaproject which drives compilation of those dependencies,
and also of OpenTURNS itself. Clone ot-superbuild git repository (or download an archive
from this URL), launch
cmake-gui program, and follow the following
cmake-gui, and select source and build directories
- Click on button. Select a generator (either Visual Studio 10 or Visual Studio 10 Win64) and compiler
- For Win64, CMake may give an error about missing 64-bit tools, as in snapshot below. Visual Studio Express Edition does not embed 64-bit compilers, and CMake thus checks whether we are using Express Edition or not.
- Click on button again, everything should work fine now, and output
window should display
- Now that CMake has checked that our compiler is working fine, we can
tell it where to find OpenBLAS and TBB. Set
TBB_LIBRARYvariables, as shown below:
- If everything went fine, click on button. This generates Visual
Studio solution files in the specified build directory, and you can
build64\ExternalProjects\Install\*directories into installation prefix (
If you want to modify settings, the simplest solution is to proceed as
in previous section, and modify Visual Studio settings afterwards.
Dependencies are downloaded, built and installed into an
ExternalProjects subdirectory of build directory, ie
build64\ExternalProjects in our example. This directory contains the
Build: contains generated Visual Studio projects, and files generated during builds
Download: contains project archives
Install: after build, each project installs resulting files (header files and libraries) there
Source: unpacked source files
Stamp: keeps track of already processed steps
Each directory in turn contains one directory per project. Thus if one
wants to modify some settings when compiling OpenTURNS, one has to go to
build64\ExternalProjects\Build\openturns\ directory and launch the
Visual Studio solution file found there, in this case
For instance, one can build OpenTURNS tests from this solution file.
Beware to always check that active configuration is the desired one.
Python bindings are not generated¶
After installing SWIG and Python binaries, we had been able to generate Python modules without trouble, but Python could not load those modules. It seems that the same version of Visual Studio must be used to compile Python and modules, but we could only find Python binaries built with Visual Studio 9. The solution is to build Python from sources, but this had not been tested yet.
Tests are not run¶
Tests can be compiled but not launched from Visual Studio, because they are run via shell commands, and also because tests executable are generated in a subdirectory. It is possible to work around those limitations and run tests, but this is currently not automated.
- It is possible to build multiple configurations with Visual Studio
solution files, but this is currently not supported by our
CMakeLists.txtfiles; thus one must launch
cmake-gui, adapt variables (for instance paths to OpenBLAS and TBB libraries must be modified for each configuration) and press and buttons.
- No OpenBLAS library in
Debugmode is provided, but the one from
Releasemode works also in
Debugmode. On the other hand, OpenTURNS and TBB configurations must match, it is not possible to link OpenTURNS in
Debugmode against TBB in
Releasemode, or vice-versa.
- Boost contains files with very long filenames, which causes trouble on NTFS. If you have already built Boost and want to build it again, Visual Studio may complain that it encountered an error when building it again. In that case, launch file explorer and remove Boost directory, then press again button of CMake (because some of its generated files had been removed too), it should now build fine.