Project

General

Profile

Build with Cygwin, Windows10 and ECCode 2.13.1

Added by Martin Perry over 4 years ago

I am trying to build cdo (1.9.7.1) on Cygwin under Windows 10 (x64) and with new EcCodes 2.13.1 (I have build the library without any problem with:


mkdir eccodes-2.13.1-install

mkdir eccodes-2.13.1-build
cd eccodes-2.13.1-build 

cmake -DDISABLE_OS_CHECK="on" -DCMAKE_C_COMPILER="gcc" -DCMAKE_INSTALL_PREFIX="../eccodes-2.13.1-install" -DBUILD_SHARED_LIBS="both" -DENABLE_PNG="on" -DENABLE_FORTRAN="off" -DENABLE_PYTHON="off" ../eccodes-2.13.1-Source 

make
ctest
make install

I have downloaded hdf5 and netcdf devel versions to cygwin and finally run this command:

mkdir cdo-install

cd cdo-1.9.7.1

./configure --prefix="d:/cdo2/cdo-install/" \
    --with-netcdf=yes \
    --with-hdf5=yes \
    --with-eccodes="d:/cdo2/eccodes-2.13.1-install" \
    --enable-all-static

make
make check
make install

Configure ends without problem:

configure: CDO is configured with the following options:
{
  "build" : {
    "tools" : {
      "CXX"                : "g++",
      "CC"                 : "gcc",
      "CPP"                : "gcc -E",
      "CPPFLAGS"           : "-Id:/cdo2/eccodes-2.13.1-install/include -Id:/cdo2/eccodes-2.13.1-install/include ",
      "CXXFLAGS"           : "-g -O2 -fopenmp ",
      "CFLAGS"             : "-g -O2 -fopenmp  ",
      "F77"                : "",
      "FFLAGS"             : "",
      "LDFLAGS"            : "-Ld:/cdo2/eccodes-2.13.1-install/lib -Ld:/cdo2/eccodes-2.13.1-install/lib ",
      "LIBS"               : "-leccodes -lnetcdf  -leccodes -lnetcdf -lhdf5_hl -lhdf5  -lm ",
      "FCFLAGS"            : "@FCFLAGS@",
      "INCLUDES"           : "@INCLUDES@",
      "LD"                 : "/usr/x86_64-pc-cygwin/bin/ld.exe",
      "NM"                 : "/usr/bin/nm -B",
      "AR"                 : "ar",
      "AS"                 : "as",
      "DLLTOOL"            : "dlltool",
      "OBJDUMP"            : "objdump",
      "STRIP"              : "strip",
      "RANLIB"             : "ranlib",
      "INSTALL"            : "/usr/bin/install -c",
    },
    "libraries" : {
      "threads"    : {
        "lib"      : "",
        "include"  : "" 
      },
      "szlib"      : {
        "lib"      : "",
        "include"  : "" 
      },
      "hdf5"       : {
        "lib"      : " -lhdf5",
        "include"  : "" 
      },
      "netcdf"     : {
        "lib"      : " -lnetcdf",
        "include"  : "" 
      },
      "udunits2"   : {
        "lib"      : "",
        "include"  : "" 
      },
      "proj"       : {
        "lib"      : "",
        "include"  : "" 
      },
      "magics"       : {
        "lib"      : "",
        "include"  : "" 
      }
    },
    "platform" : {
      "SYSTEM_TYPE" : "x86_64-unknown-cygwin" 
    },
  },
  "features" : {
    "enable_cdi_lib" : false,
    "enable_data"    : true,
    "enable_fortran" : true,
    "fortran_works"  : "yes",
  }
}

However make fails with:

make[2]: Entering directory „/cygdrive/d/cdo2/cdo-1.9.7.1/libcdi/app“
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -g -O2  -all-static -Ld:/cdo2/eccodes-2.13.1-install/lib  -o cdi.exe cdi.o printinfo.o ../src/libcdi.la -leccodes -lhdf5 -lnetcdf  -lm  -luuid -leccodes -lhdf5 -lnetcdf  -lm  -luuid
libtool: link: gcc -g -O2 -static -o cdi.exe cdi.o printinfo.o  -Ld:/cdo2/eccodes-2.13.1-install/lib ../src/.libs/libcdi.a -leccodes -lhdf5 -lnetcdf -luuid
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lhdf5
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lnetcdf
collect2: error: ld returned 1 exit status

If I manually run ld -lhdf5, no problem occurs


Replies (4)

RE: Build with Cygwin, Windows10 and ECCode 2.13.1 - Added by Ralf Mueller over 4 years ago

Hi Martin!

here are my recommendations:

  1. don't use paths in windows style within cygwin: better use /cygdrive/d/cdo2/eccodes instead of d:/cdo2/eccodes. I am not 100% sure this works under all circumstances
  2. Unless you really NEED to build cdo yourself, use the pre-built binary for cygwin from the download area (plus the eccodes_share.tar.gz). Since you already have installed eccodes, the latter is not needed. But make sure it is located under /usr/local - then the pre-built CDO will find it.
  3. You used the --enable-all-static switch - this might not work on systems, where packages usually only come with shared libraries - not sure, if this is the case for cygwin, but this can lead to linking problems like this. I rarely see distros that install both static and shared libraries.

hth
ralf

RE: Build with Cygwin, Windows10 and ECCode 2.13.1 - Added by Ralf Mueller over 4 years ago

Ah, forgot to mention: Instead of using cygwin, you could make use of the built-in Linux system of Win10. AFAIK it's based on ubuntu 16 and comes with an older cdo package- might be totally sufficient for what you want to do.

RE: Build with Cygwin, Windows10 and ECCode 2.13.1 - Added by Martin Perry over 4 years ago

The prebuild cdo is "fighting" with my installed EcCodes, which is 2.13.1. I am using this version in another SW, and cannot change it. If I run prebuild cdo, I got:


No expression_get_name() in long
ecCodes assertion failed: `1==0' in /home/cimduser/tar/eccodes-2.9.0-Source/src/grib_expression.c:77
convert.sh: line 26: 18877 Aborted  (core dumped) cdo -O -f grb2 remap,${CDO_TARGET_GRID_DESCRIPTION},${CDO_WEIGHTS_FILE} ${in_file} ${out_file}

RE: Build with Cygwin, Windows10 and ECCode 2.13.1 - Added by Ralf Mueller over 4 years ago

yeah, you cannot really mix those versions I think. the pre-build version is 2.9.0. I use this for building CDO on my cygwin box:

       
        CDOLIBS="--with-netcdf \
                 --with-hdf5 \
                 --with-udunits2 \
                 --with-proj --with-eccodes=/usr/local" 
        ./configure $CDOLIBS \
                    LDFLAGS="-L/usr/local/lib /usr/local/lib/libeccodes.a -leccodes -lopenjpeg" \
                    CC=gcc CFLAGS="-g -Wall -O2 -DPIC -pie -mwindows -ftree-vectorize" \
                    CXX=g++ CXXFLAGS="-g -Wall -O2 -DPIC -pie -mwindows -ftree-vectorize" 

    (1-4/4)