[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #HUZ-904606]: library linking problem



> 
> Hi Folk (s),
> 
> I'm having problems linking a fortran code to the netCDF library.
> 
> I downloaded the netCDF binary 3.6.0 (I couldn't get 3.6.1 to work)
> onto my Mac Book Pro.  Got the proper directories ... and
> ncdump -h appears to be fine.

What was wrong with 3.6.1?

> 
> Then I went to compile a program with the following make
> file
> 
> ++++++++++++++++++++++++++++++++++++++++++
> 
> ################################################################
> ## Edit these three to indicate the path for the netcdf include
> ## file 'netcdf.h', the name of the netcdf library file, and the
> ## path to that library file.
> ################################################################
> NETCDFINCDIR = /pru/netcdf-3.6.0-p1/include
> NETCDFLIB    = -llibnetcdf.a
> NETCDFLIBDIR = /pru/netcdf-3.6.0-p1/lib
> 
> INCDIRS = -I$(NETCDFINCDIR)
> LIBDIRS = -L$(NETCDFLIBDIR)
> LIBS    = $(NETCDFLIB)
> 
> ################################################################
> ## If you want to use another compiler instead of the
> ## the GNU g77 fortran compiler, change value for compile in the
> ## following line.
> ################################################################
> FC = g77
> 
> ####################
> ## Can add a -g here
> ####################
> #OTHERFLAGS = -g
> 
> ################################################################
> ## You should not have to edit anything below this line        #
> ################################################################
> 
> MODELOBJS = biome4main.o biome4setup.o biome4driver.o biome4.o
> 
> FFLAGS = $(OTHERFLAGS) -fno-silent -Wall $(INCDIRS)
> 
> ################################################################
> 
> all:: model
> 
> model:        $(MODELOBJS)
> $(FC) -o biome4 $(MODELOBJS) $(INCDIRS) $(LIBDIRS) $(LIBS)
> 
> clean::
> -rm *.o
> 
> 
> 
> 
> 
> 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> I get the following error
> 
> make
> g77 -o biome4 biome4main.o biome4setup.o biome4driver.o biome4.o
> -I/pru/netcdf-3.6.0-p1/include -L/pru/netcdf-3.6.0-p1/lib -llibnetcdf.a
> /usr/bin/ld: can't locate file for: -llibnetcdf.a
> collect2: ld returned 1 exit status
> make: *** [model] Error 1
> 
> 
> I've tried mucking with the linking to no end, but no luck.

You're linker is saying that it cannot find -llibnetcdf.a. You should be using 
-lnetcdf instead.

Thanks,

Ed

Ticket Details
===================
Ticket ID: HUZ-904606
Department: Support netCDF
Priority: Normal
Status: Closed