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

[netCDF #FZX-680847]: "undefined reference to" problem



Hello,

It appears that when compiling ARWpost you are linking against the C library 
(libnetcdf) but not the Fortran interface (libnetcdff).  You will need to 
specify the fortran library when linking; this should resolve the 'undefined 
reference' errors you are seeing.  

I hope this helps, have a great day,

-Ward

> Dear NetCDF support,
> 
> I compiled successfully the latest netcdf-c netcdf-fortran releases on my
> fedora 22 with the gcc (GCC) 5.1.1 compiler (i.e. make check had no
> problems). Installation folder is /usr/local. In particular output of
> /usr/local/bin/nf-config --all is
> 
> 
> *This netCDF-Fortran 4.4.2 has been built with the following features:
> --cc        -> gcc  --cflags    ->  -I/usr/local/include
> -I/usr/local/include  --fc        -> gfortran  --fflags    ->
> -I/usr/local/include  --flibs     -> -L/usr/local/lib -lnetcdff
> -L/usr/local/lib -lnetcdf -lnetcdf   --has-f90   -> no  --has-f03   -> yes
> --has-nc2   -> yes  --has-nc4   -> yes  --prefix    -> /usr/local
> --includedir-> /usr/local/include  --version   -> netCDF-Fortran 4.4.2*
> 
> But when I try to compile ARWpost (an utility for the WRF model) with the
> same compiler (gfortran) I get this error:
> 
> 
> ***** Compiling ARWpost **** gfortran -cpp -ffree-form -O
> -fno-second-underscore -fconvert=big-endian -frecord-marker=4   -o
> ARWpost.exe module_model_basics.o constants_module.o gridinfo_module.o
> ARWpost.o input_module.o output_module.o module_map_utils.o
> misc_definitions_module.o module_date_pack.o module_debug.o
> process_domain_module.o module_get_file_names.o module_interp.o
> module_basic_arrays.o module_diagnostics.o module_arrays.o
> module_pressure.o module_calc_height.o module_calc_pressure.o
> module_calc_theta.o module_calc_tk.o module_calc_tc.o module_calc_td.o
> module_calc_td2.o module_calc_rh.o module_calc_rh2.o module_calc_uvmet.o
> module_calc_slp.o module_calc_dbz.o module_calc_cape.o module_calc_wdir.o
> module_calc_wspd.o module_calc_clfr.o  \    -L/usr/local/lib
> -I/usr/local/include  -lnetcdf input_module.o: In function
> `__input_module_MOD_arw_get_next_time':input_module.f:(.text+0x3e):
> undefined reference to `nf_inq_varid_'input_module.f:(.text+0x74):
> undefined reference to `nf_inq_var_'input_module.f:(.text+0x12f): undefined
> reference to `nf_get_vara_text_'input_module.o: In function
> `__input_module_MOD_input_close':input_module.f:(.text+0x1af): undefined
> reference to `nf_close_'input_module.o: In function
> `__input_module_MOD_read_global_attrs':input_module.f:(.text+0x275):
> undefined reference to `nf_get_att_text_'input_module.f:(.text+0x551):
> undefined reference to `nf_get_att_int_'input_module.f:(.text+0x57c):
> undefined reference to `nf_get_att_int_'input_module.f:(.text+0x5a7):
> undefined reference to `nf_get_att_int_'input_module.f:(.text+0x5f5):
> undefined reference to `nf_get_att_text_'input_module.f:(.text+0x619):
> undefined reference to `nf_get_att_int_'input_module.f:(.text+0x63d):
> undefined reference to `nf_get_att_real_'input_module.f:(.text+0x661):
> undefined reference to `nf_get_att_real_'input_module.f:(.text+0x685):
> undefined reference to `nf_get_att_real_'input_module.f:(.text+0x6a9):
> undefined reference to `nf_get_att_real_'input_module.f:(.text+0x6cd):
> undefined reference to
> `nf_get_att_real_'input_module.o:input_module.f:(.text+0x6f1): more
> undefined references to `nf_get_att_real_' followinput_module.o: In
> function
> `__input_module_MOD_read_global_attrs':input_module.f:(.text+0x880):
> undefined reference to `nf_inq_attname_'input_module.f:(.text+0x8b2):
> undefined reference to `nf_inq_att_'input_module.f:(.text+0x94c): undefined
> reference to `nf_get_att_text_'input_module.f:(.text+0xa54): undefined
> reference to `nf_get_att_int_'*
> 
> *etcetcetc......*
> 
> From previous emails in the support-netcdf  mailing list I figured out that
> the problem could be related to some "double underscore __" when linking
> C/C++ programs with gfortran,
> Any suggestions?
> Thanks for your help, Valerio Capecchi
> 
> --
> Valerio Capecchi
> LaMMA/CNR
> https://github.com/valcap
> Maps: 43.818948 N, 11.201912 E
> Tel.: +39 055 4483 066
> 
> 


Ticket Details
===================
Ticket ID: FZX-680847
Department: Support netCDF
Priority: Normal
Status: Closed