Building GEOtop on Windows 7

It’s possible to build GEOtop with static and shared linking method. However, it’s not possible to build the source code through Microsoft Visual Studio at the moment. So that, it’s necessary to install Cygwin as following described.

 

1. Cygwin installation

Download the executable from the Official Web Site on the basis of your machine (32-64bit)

1pic

Run the executable and click Next until arriving at Choose Download Site.

2pic
3pic
4pic
5pic
6pic
7pic

Now, choose a repository from which download the packages to install. Then click Next and you should see a window like the following

8pic

Expand the Archive Libs section and select the following packages

  • libbz2-devel

Expand the Devel section and select the following packages

  • autoconf2.5
  • cmake
  • cmake-gui
  • gcc-core
  • gcc-g++
  • git
  • make
  • patch

Now type proj in the Search area

proj1

Expand the section Libs

proj2

Click on Skip on each on of the three proj libraries:

  • libproj-devel
  • libproj1
  • proj

proj3

Then click on Next

proj4

Then click on Next again, in order to install all the required dependencies. At the end of the installation, you should find an icon on the Desktop and one on the Start Menu.

 

2. Bulding GEOtop: static linking

First of all, open the Cygwin terminal (a link should be available on the Desktop). Enter inside your user home typing:

$ cd /cygdrive/c/Users/<user>

where user is your username. Now create a folder where put the source codes, e.g. src, and enter into it.

Now you need the MeteoIO source code and then you have to build it. Unfortunately, in order to make it works with Cygwin you should apply a patch to the official version. I created the patched version od the MeteoIO 2.4.2 source code and then I uploaded it on GitHub, so you can easily clone and build it.

# download MeteoIO from the unofficial repo
$ git clone https://github.com/sidereus3/MeteoIO-2.4.2_patched.git
$ cd MeteoIO-2.4.2.patched

$ ccmake .
# type 'c' to configure, and if you get a warning message like
CMake Warning at /usr/share/cmake-3.3.2/Modules/Platform/CYGWIN.cmake:15 (message):
   CMake no longer defines WIN32 on Cygwin!

   (1) If you are just trying to build this project, ignore this warning or
   quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
   the CMake cache.  If later configuration or build errors occur then this
   project may have been written under the assumption that Cygwin is WIN32.
   In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.

   (2) If you are developing this project, add the line

     set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required

   at the top of your top-level CMakeLists.txt file or set the minimum
   required version of CMake to 2.8.4 or higher.  Then teach your project to
   build on Cygwin without WIN32.
 Call Stack (most recent call first):
   /usr/share/cmake-3.3.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
   CMakeLists.txt:5 (PROJECT)

# just type 'e' to exit

9pic

set the following flags

  • build_shared_libs to OFF
  • build_static_libs to ON

10pic

and the other one

  • PROJ4 to ON

11pic

# type 'c' to configure, 'c' to configure, 'g' to generate
$ make
$ make install

Now you have to build the Boost library. First of all, you can get tar.gz package from http://sourceforge.net/projects/boost/files/boost/1.58/, then move the package inside the src folder. Extract the source code and then enter into the folder

$ tar -xzvf boost_1_58_0_tar.gz
$ cd boost_1_58_0/

Now, to configure and then build and install the Boost library, type

$ ./bootstrap.sh --with-libraries=filesystem,system,iostreams,regex,program_options,test
$ ./bjam link=static install

Now, the last step is building GEOtop. You can clone it from the GitHub repository, inside the src directory

$ git clone https://github.com/geotopmodel/geotop.git

You might get the following Warning message:


CMake Warning at /usr/share/cmake-3.3.2/Modules/Platform/CYGWIN.cmake:15 (message):
   CMake no longer defines WIN32 on Cygwin!

   (1) If you are just trying to build this project, ignore this warning or
   quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
   the CMake cache.  If later configuration or build errors occur then this
   project may have been written under the assumption that Cygwin is WIN32.
   In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.

   (2) If you are developing this project, add the line

     set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required

   at the top of your top-level CMakeLists.txt file or set the minimum
   required version of CMake to 2.8.4 or higher.  Then teach your project to
   build on Cygwin without WIN32.
 Call Stack (most recent call first):
   /usr/share/cmake-3.3.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
   CMakeLists.txt:15 (project)



 Linking mode: SHARED

Just ignore it and press e to exit. Then switch the flag BUILD_STATIC to ON, then

# press 'c' to configure
# press 'e' after static linking mode has been shown
# press 'c' to configure
# press 'e' after static linking mode has been shown
# press 'g' to generate

at the end start building the source code

$ make
$ make install

To have the geotop.exe working from within each and every folder of your pc, you have to Add C:cygwinbin for 32bit pc or C:cygwin64bin for 64bit pc to the environmental variables.

geotopWinEnvironmentalVariables

Click on Start-> Computer-> System properties-> Advanced system settings-> Environment Variables, scroll down the System variables section looking for Path variable

geotopWinEnvironmentalVariables2

double click on it and add the first item if your operating system is 32bit, the second one if it is 64bit. Pay attention that the initial semicolon is not a mistake, it’s the separator with the previous value.

  • ;C:cygwinbin;C:cygwinusrlocalbin
  • ;C:cygwin64bin;C:cygwin64usrlocalbin

Then you can call the geotop.exe executable from within each folder in your system.

About Francesco Serafin

I am a PhD student at the Department of Civil, Environmental and Mechanical Engineering at the University of Trento. My two greatest loves: Computer Science and Water (take three with my Lenovo!:D). As a result, the aim of my life is to make both passions coexist. My gpg public key available at https://pgp.mit.edu

6 Replies to “Building GEOtop on Windows 7”

  1. Francesco,

    Later when I make ccmake .
    I got the following error:
    Do you know how to fix it?
    Thanks!

    Giacomo

    CMake no longer defines WIN32 on Cygwin!

    (1) If you are just trying to build this project, ignore this warning or
    quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
    the CMake cache. If later configuration or build errors occur then this
    project may have been written under the assumption that Cygwin is WIN32.
    In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.

    (2) If you are developing this project, add the line

    set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required

    at the top of your top-level CMakeLists.txt file or set the minimum
    required version of CMake to 2.8.4 or higher. Then teach your project to
    build on Cygwin without WIN32.
    Call Stack (most recent call first):
    /usr/share/cmake-3.3.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
    CMakeLists.txt:5 (PROJECT)

    CMake Error at /usr/share/cmake-3.3.2/Modules/CMakeTestCCompiler.cmake:61 (message):
    The C compiler “/usr/bin/cc” is not able to compile a simple test program.

    It fails with the following output:

    Change Dir: /home/GBertoldi/src/MeteoIO-2.4.2_patched/CMakeFiles/CMakeTmp

    Errors occurred during the last pass

    • Hi Giacomo,

      that one is just a Warning and nothing more. You can totally ignore it. In order to be clearer, I’m going to add the complete message on the guide.

      What version of WIN7 are you using? 32bit or 64bit?

      I tested the procedure on my own version of WIN7 32bit and it worked for me. If some steps are not clear enough, just let me know. Unfortunately, this guide is not so straightforward and it requires the solution of some small tricks to get to the end.

      Cheers,

      francesco

  2. Greetings Francesco, thanks for the very useful and clear guide. With some minor troubleshooting, I have made it all the way to the final step (“make” GeoTop) before encountering the following error. I am using the latest version of GeoTop (https://github.com/geotopmodel/geotop) on 64-bit Windows 10. I am a novice to C++ but based on my familiarity with Fortran it seems there may be some variables that are not correctly defined as related to the MeteoIO plugin. I tried reinstalling the patched plugin from the git repository, but that didn’t seem to fix the problem. Any advice would be much appreciated!

    [email protected] ~/src/geotop
    $ make
    [ 7%] Built target gt_utilities
    [ 26%] Built target geotopCommon
    [ 30%] Built target geotopPartSnow
    [ 31%] Building CXX object src/meteoio_plugin/CMakeFiles/meteoioplugin.dir/meteoioplugin.cc.o
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc: In function ‘void hnw_correction(Par*, std::vector&)’:
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:206:19: error: ‘PSUM’ is not a member of ‘mio::MeteoData’
    hnw = meteo[ii](MeteoData::PSUM);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:220:14: error: ‘PSUM’ is not a member of ‘mio::MeteoData’
    meteo[ii](MeteoData::PSUM) = par->raincorrfact * rain + par->snowcorrfact * snow;
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc: In function ‘void merge_meteo_data(mio::Date&, std::vector&)’:
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:244:30: error: ‘TAU_CLD’ is not a member of ‘mio::MeteoData’
    const size_t cloud_index = MeteoData::TAU_CLD;
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:256:33: error: ‘PSUM’ is not a member of ‘mio::MeteoData’
    (*it2)(hnw_matteo) = (*it)(MeteoData::PSUM);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:267:6: error: ‘class mio::IOManager’ has no member named ‘add_to_points_cache’
    io->add_to_points_cache(current, meteo);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc: In function ‘void meteoio_interpolate_cloudiness(Par*, const double&, GeoMatrix&, GeoVector&)’:
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:510:13: error: ‘TAU_CLD’ is not a member of ‘mio::MeteoData’
    meteo[i](MeteoData::TAU_CLD) = (tau_cloud_vec[i+1] == geotop::input::gDoubleNoValue ? IOUtils::nodata : tau_cloud_vec[i+1]);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:517:7: error: ‘class mio::IOManager’ has no member named ‘add_to_points_cache’
    io->add_to_points_cache(d1, meteo);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:541:30: error: ‘TAU_CLD’ is not a member of ‘mio::MeteoData’
    io->interpolate(d1, dem, MeteoData::TAU_CLD, pointsVec, resultCloud);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:553:31: error: ‘TAU_CLD’ is not a member of ‘mio::MeteoData’
    io->getMeteoData(d1, dem, MeteoData::TAU_CLD, cloudwgrid);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc: In function ‘void meteoio_interpolate(Par*, double, Meteo*, Water*)’:
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:624:39: error: ‘PSUM’ is not a member of ‘mio::MeteoData’
    io->getMeteoData(current_date, dem, MeteoData::PSUM, hnwgrid);
    ^
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc: In function ‘void meteoio_interpolate_pointwise(Par*, double, Meteo*, Water*)’:
    /cygdrive/c/Users/Sam/src/geotop/src/meteoio_plugin/meteoioplugin.cc:749:28: error: ‘PSUM’ is not a member of ‘mio::MeteoData’
    io->interpolate(d1, dem, MeteoData::PSUM, pointsVec, resultHnw);
    ^
    make[2]: *** [src/meteoio_plugin/CMakeFiles/meteoioplugin.dir/build.make:63: src/meteoio_plugin/CMakeFiles/meteoioplugin.dir/meteoioplugin.cc.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:807: src/meteoio_plugin/CMakeFiles/meteoioplugin.dir/all] Error 2
    make: *** [Makefile:161: all] Error 2

    • Hi Sam,

      thank you very much for commenting on my post. If I were you, instead of spending time in building GEOtop under Windows, I would go for the Dockerized version of GEOtop which is the future for modelling as well, in my personal opinion. I’m going to write a post as soon as possible on how this solution is easy, fast and maintainable.

      Please, take a look at the link above and if you encounter any problem, please let me know.

      Ciao,

      francesco

Leave a Reply

Your email address will not be published.

*