NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[netcdfgroup] NETCDF and NETCDFF cross compiling using mingw-w64

Hello

I finally managed to get NetCDFF (Fortran) working on Windows using
cross-compilation from Linux using the mingw-w64 suite. I've been using
netcdf-4.3.2 and netcdf-fortran-4.4.0.

On Linux I do:
C:
#!/bin/bash
netcdf_ver=4.3.2
host=i686-w64-mingw32
prefix=$HOME/mingw32-w64/i686
host=x86_64-w64-mingw32
prefix=$HOME/mingw32-w64/x86_64
CC=$host-gcc
module purge
cc_ver=`$CC -dumpversion`
make distclean
./configure  --prefix=$prefix --host=$host --disable-netcdf-4 --disable-dap
--enable-dll

Fortran:
#!/bin/bash
netcdf_ver=4.3.2
netcdff_ver=4.4.0
host=i686-w64-mingw32
prefix=$HOME/mingw32-w64/i686
host=x86_64-w64-mingw32
prefix=$HOME/mingw32-w64/x86_64
CC=$host-gcc
FC=$host-gfortran
module purge
fc_ver=`$FC -dumpversion`
make distclean
FCFLAGS=-ffree-line-length-none CPPFLAGS=-I$prefix/include ./configure
 --prefix
=$prefix --host=$host --enable-dll
make && make install

That could be tidied up a bit - I know.

I copy $prefix/{include,lib} to the Windows machine and add configuration
about NETCDF include dir and NETCDF libraries to my projects
CMakeLists.txt. Do a configuration and generation of Mingw make files and
compile - and it works :-).

Karsten

PS: The only issue I realize is that I have to comment out lines 8-24
in fortran/netcdf_overloads.f90 for Mingw to compile. Funny enough I don't
have the same problem using native gcc and gfortran (also version 4.9).
I've added FCFLAGS=-ffree-line-length-none - but it does not really help.
If I remove a couple of lines from each of the interfaces it also works -
which got me on the line length track.
  • 2014 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: