meteoio

Compiling-MeteoIO

Table of Content

How to compile MeteoIO from source code

Introduction

Once you have the source code of MeteoIO on your computer (either from downloading a source package or from performing an svn checkout, see Getting-MeteoIO), you can compile it.

Compiling on Linux/Unix

You need to have the following tools on your system:

  • cmake (it is highly recommended to also install cmake-curses or cmake-gui);
  • a c++ compiler, for example g++;
  • if you want to generate the documentation, doxygen;
  • if you have latex, this is a plus since it will be able to render some equations in the documentation.

Then, you are ready to compile MeteoIO:

  • open a terminal and change into the trunk folder of meteoio
  • "ccmake ." (or "cmake-gui .")
  • Press [c] to configure, it will then populate the screen with configurable options
  • choose the relevant options (toggle ON/OFF by pressing Enter)
  • Press [c] to configure
  • Do not forget to configure the install path (either system wide if you have access to system rights or in a local directory where you have write permission)
  • Press [g] to generate and exit the interface (you might have to press [c] a few times for it to have everything finally setup)
  • "make"

Once MeteoIO has been compiled, you can install it. As previously mentioned, there are two options: you install in a system directory (and you need system rights, either through sudo or as root) or you don't:

  • system wide install
    • "sudo make install"
    • "sudo ldconfig" (if your install path is already listed in /etc/ld.so.conf. If not, add it to this list before running ldconfig). If your location is too exotic, other softwares won't be able to find MeteoIO by themselves. In such a case also set LD_LIBRARY_PATH as laid out here below so other softwares will be able to find it automatically (by expanding LD_LIBRARY_PATH)
  • local install
    • "make install"
    • export LD_LIBRARY_PATH={your install prefix path}/lib:$LD_LIBRARY_PATH (for bash shell). This can be put into your $HOME/.bashrc or $HOME/.profile in order to become permanent for your account. By default, MeteoIO will be searched for in ${HOME}/usr so this could be a good location to install it.

Afterward, the examples can be compiled (see below).

Compiling on Android

Please note that this is still experimental at this point. You need to install the following components:

Unpack these three packages, and following along these lines, set a few environment variables (it seems that setting ANDROID_NKD to point to the root of your ndk is enough for cmake-android to find what it needs, without relying on ANDROID_NDK_... and ANDTOOLCHAIN that were not working with ndk version 7).

Then, compile with "android-cmake" (you can then use "ccmake" to change options in a more user-friendly way, after you used android-cmake the first time) and "make".

Compiling and Downloading on Windows

You need to have the following tools on your system:

  • cmake;
  • a c++ compiler, among others, you can use Code::Blocks, MinGW, Visual C++. See links and detailed instructions below.
  • if you want to generate the documentation, doxygen;
  • if you have latex, this is a plus since it will be able to render some equations in the documentation.

Then, you are ready to compile MeteoIO:

  • Start CMake and set the source path to your local MeteoIO trunk and set the trunk directory as build directory. Click on "Configure" and select the appropriate compiler according to what you have. If you want to build the documentation (see at the bottom of this page), you need to have installed doxygen before running cmake (or you have to run it again once doxygen has been installed).
  • For Code::Blocks:
    • It can be downloaded free at www.codeblocks.org. We highly recommend to download the full package (ie: the one containing MinGW)
    • when installing Code::Blocks, the MinGW installation might have to be tweaked as explained below in the MinGW section (if the package has not been fixed)
    • In CMake, select "Code::Blocks - MinGW Makefiles" as the generator
    • Click on "Generate"
    • Open the project file (ending in .cbp) with Code::Blocks and compile it
  • For MinGW:
    • It can be downloaded free at MinGW
    • IMPORTANT: When installing MinGW make sure that you install MinGW together with MinGW make and add the MinGW bin directory to your PATH environment variable
    • create a shortcut (or simply a copy) named make.exe in the MinGW bin directory pointing to mingw-make.exe in the same directory
    • In CMake, select "MinGW Makefiles"
    • in CMake, click on "Generate"
    • Run cmd.exe, change into the build directory as specified for CMake (e.g. trunk) and run "mingw32-make"
  • For Visual C++
    • It can be downloaded free at Microsoft, after registration (this is not open source software!)
    • In CMake, select "Visual Studio XX" where XX is your version
    • in CMake, click on "Generate"
    • open the project file (ending in .sln) with Visual C++ and compile

If the compilation makes errors in soap related code, you can either attempt to hack the code yourself or simply turn the GSN plugin off in cmake (the soap code is generated by gsoap and regularly makes trouble on windows). Afterward, the examples can be compiled (see below).

Compiling on OSX

You need to have the following tools on your system:

  • cmake. It is highly recommended to check the box to install both the GUI and the command line tools and to click on "yes" to have it in your path (if this is not done automatically, you will have to add it to your path manually, see below);
  • a c++ compiler, usually XCode (you can get a version for free after registering at http://connect.apple.com) or Clang (available through macports);
  • for Xcode:
    • Run it once and select "install" in Preferences > Downloads > Components > Command Line Tools;
  • for Clang:
    • open a terminal and type the following commands;
    • install clang: sudo port install clang;
    • set mac ports clang as clang compiler: sudo port select --set clang mp-clang-5.0 (you can get a list of all installed versions by typing: sudo port select --list clang);
    • check that the right clang is found: clang --version and clang++ --version (the output should start with clang version XXX and not with Apple LLVM version XXX. If it doesn't work, try run "export PATH=/opt/local/bin:/opt/local/sbin:$PATH". You can add it to ~.bash_profile to have it permanently);
    • set it as default compiler: export CC=clang and export CXX=clang++ (You can add it to ~.bash_profile to have it permanently);
    • If you've already compiled the project with XCode, run "rm -r CMakeFiles CMakeCache.txt" from the trunk directory;
  • if you want to compile some plugins like netcdf, png, etc it is recommended to install the required dependencies through macport
  • if you want to generate the documentation, doxygen. In such a case, you need to create a symlink to the doxygen binary in /usr/bin or add it to your path (see below);
  • if you have latex, this is a plus since it will be able to render some equations in the documentation.

Then, you are ready to compile MeteoIO:

  • open a terminal and change into the trunk folder of meteoio
  • "ccmake ." (or "cmake-gui .")
  • Press [c] to configure, it will then populate the screen with configurable options
  • choose the relevant options (toggle ON/OFF by pressing Enter)
  • Press [c] to configure
  • Do not forget to configure the install path (either system wide if you have access to system rights or in a local directory where you have write permission)
  • Press [g] to generate and exit the interface (you might have to press [c] a few times for it to have everything finally setup)
  • "make"
  • export DYLD_FALLBACK_LIBRARY_PATH={your install prefix path}/lib:$DYLD_FALLBACK_LIBRARY_PATH (for bash shell). This can be put into your $HOME/.bash_profile in order to become permanent for your account (this file might have to be created, see tech-recipes.com). If cmake or doxygen were not automatically added to your path, do the same with the PATH variable.

Afterward, the examples can be compiled (see below).

Compiling on FreeBSD

Follow the documentation for Linux (although the compiler is clang).

Compiling on ReactOS

Follow the documentation for Windows.

Compiling on Haiku

Follow the documentation for Linux.

Generating the documentation

In order to be able to generate the documentation, you need to install doxygen on your system. You also need to re-run cmake after doxygen has been installed, so doxygen support will be enabled. Then, simply type "make doc" in a terminal window (from MeteoIO's root directory) and doxygen will prepare the online documentation that will be accessible through doc/MeteoIO_doc.html

Compiling and running the examples

A few simple examples are provided in doc/examples and are useful to learn how to use MeteoIO in your own code. These examples shown various usage of MeteoIO and yet are very simple and short, so feel free to open their source code!

Compiling the examples

The examples are compiled in a way very similar to MeteoIO itself, by running cmake and then compiling the project (same as explained above for compiling MeteoIO).

  • on Linux:
    • the MeteoIO library must habe been installed (with "make install") to a system path or LD_LIBRARY_PATH set to the path where the library is located;
    • in a terminal, go into the doc/examples directory;
    • run "ccmake ." (nothing needs to be configured);
    • compile with "make".
  • On Windows:
    • manually copy lib/libmeteoio.dll in doc/examples;
    • run cmake and give it the path to the examples;
    • compile the generated project;
  • On OsX:
    • make sure that DYLD_FALLBACK_LIBRARY_PATH has been set to the path where the MeteoIO library is located (see above);
    • in a terminal, go into the doc/examples directory;
    • run "ccmake ." (or "cmake-gui ."), nothing needs to be configured;
    • compile with "make".

Running the examples

Every example shows a different aspect of MeteoIO, therefore they all take different arguments. But a generic io.ini file is provided alongside input data that works for all the provided examples. The meteo data covers the range 2008-12-01 to 2009-01-31.

  • in a terminal, go to the examples directory;
  • run the chosen example with its required arguments, for example:
    • on Linux, "./meteo_reading 2008-12-15T12:30";
    • on Windows, "meteo_reading.exe 2008-12-15T12:30"
    • on OsX, "./meteo_reading 2008-12-15T12:30".

The meteo_reading example prints on the screen the metadata for each station as well as all the available, filtered and re-interpolated meteorological data for the date and time specified as argument. Of course, the other examples do other things!