Re: [netcdfgroup] Linking failure with 4.0.1 on Debian sid

On Wed, Sep 23, 2009 at 06:07:19PM +0200, Francesco P. Lovergine wrote:
> On Wed, Sep 23, 2009 at 05:36:10PM +0200, Francesco Paolo Lovergine wrote:
> > Hi all
> > 
> > I'm currently trying to move forward Debian support of netcdf from 3.6.3 
> > to 4.0.1 (and possibly 4.1beta ASAP). Of course, I'm using gfortran 4.3.3
> > (and possibly 4.4 for next release). Things go ok, but for Fortran check,
> > which fails miserably due to linking problems. Note that I added -DgFortran 
> > explicitly at configure time. I'm not a Fortran guy, but I noted that
> > all named functions are tagged as undefined in the named solibs: it seems
> > they are linked as external instead of being wrapped to C functions.
> > Any hints?
> > 
> 

Ok, I finally managed to fix the problem with GNU Fortran and --enable-netcdf-4.
The following patch is required, because gfortran nowi (>= 4.3?) adds a final _ 
to all
symbols by default. The patch is required also with cfortran.h 4.4. 
Another problem is due to an oddity in fortran/Makefile.am
which requires a mandatory --with-hdf5=<path> among other options (in my case
path=/usr). That could be easily fixed also in the automake file. That
fix seems appropriate to me, because HDF5 support is required but a
path specification is not mandatory. The final result without this
patch is a lot of UNDEF symbols and a broken Fortran support.



Index: netcdf-4.0.1/fortran/ncfortran.h
===================================================================
--- netcdf-4.0.1.orig/fortran/ncfortran.h   2009-02-19 13:50:25.000000000 +0100
+++ netcdf-4.0.1/fortran/ncfortran.h    2009-09-24 21:10:08.000000000 +0200
@@ -660,7 +660,7 @@
  * The following is for f2c-support only.
  */
 
-#if defined(f2cFortran) && !defined(pgiFortran)
+#if defined(f2cFortran) && !defined(pgiFortran) && !defined(gFortran)

 /*
  * The f2c(1) utility on BSD/OS and Linux systems adds an additional
Index: netcdf-4.0.1/nf_test/fortlib.c
===================================================================
--- netcdf-4.0.1.orig/nf_test/fortlib.c 2009-09-24 21:11:12.000000000 +0200
+++ netcdf-4.0.1/nf_test/fortlib.c  2009-09-24 21:11:36.000000000 +0200
@@ -14,7 +14,7 @@
 #include "../fortran/ncfortran.h"


-#if defined(f2cFortran) && !defined(pgiFortran)
+#if defined(f2cFortran) && !defined(pgiFortran) && !defined(gFortran)
 /*
  * The f2c(1) utility on BSD/OS and Linux systems adds an additional
  * underscore suffix (besides the usual one) to global names that have
Index: netcdf-4.0.1/fortran/Makefile.am
===================================================================
--- netcdf-4.0.1.orig/fortran/Makefile.am    2009-09-24 21:30:25.000000000 +0200
+++ netcdf-4.0.1/fortran/Makefile.am  2009-09-24 21:30:50.000000000 +0200
@@ -92,8 +92,8 @@
 if USE_HDF5_DIR
 AM_CPPFLAGS += -I@HDF5DIR@/include
 AM_LDFLAGS = -L@HDF5DIR@/lib
-libnetcdff_la_SOURCES += fort-nc4.c
 endif
+libnetcdff_la_SOURCES += fort-nc4.c
 
 else # not USE_NETCDF4



-- 
Francesco P. Lovergine



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: