Hello everyone,
I am trying to compile ROMS on Linux sever with pgi. The error message I got is like this:
'''
ROMS/Utility/checkdefs.F warning: extra tokens at end of #ifdef directive
ar: creating /home/ywang/roms/Projects/Upwelling/Build/libUTIL.a
ar: creating /home/ywang/roms/Projects/Upwelling/Build/libNLM.a
ar: creating /home/ywang/roms/Projects/Upwelling/Build/libNLM_bio.a
ar: creating /home/ywang/roms/Projects/Upwelling/Build/libNLM_sed.a
ar: creating /home/ywang/roms/Projects/Upwelling/Build/libANA.a
ar: creating /home/ywang/roms/Projects/Upwelling/Build/libMODS.a
/usr/bin/ld: cannot find -lnetcdff
make: *** [/home/ywang/roms/Projects/Upwelling/oceanG] Error 2
'''
I have set the LD_LIBRARY_PATH to the netcdf lib folder where I have the file libnetcdff.a. Also in the build.bash, I set USE_NETCDF=on open to let the "nf-config --flibs" work.
The output of 'nf-config --flibs' is:
'''
-L/proj/pgi/linux86-64/2016/netcdf/netcdf-fortran-4.4.2/lib -lnetcdff -O -tp p7 \
-L/proj/pgi/linux86-64/2016/netcdf/netcdf-4.3.3.1/lib -R/proj/pgi/linux86-64/2016/netcdf/netcdf-4.3.3.1/lib -lnetcdf -lnetcdf
'''
When I type ld -lnetcdff --verbose, I got message:
'''
attempt to open /usr/x86_64-redhat-linux/lib64/libnetcdff.so failed
attempt to open /usr/x86_64-redhat-linux/lib64/libnetcdff.a failed
attempt to open /usr/local/lib64/libnetcdff.so failed
attempt to open /usr/local/lib64/libnetcdff.a failed
attempt to open /lib64/libnetcdff.so failed
attempt to open /lib64/libnetcdff.a failed
attempt to open /usr/lib64/libnetcdff.so failed
attempt to open /usr/lib64/libnetcdff.a failed
attempt to open /usr/x86_64-redhat-linux/lib/libnetcdff.so failed
attempt to open /usr/x86_64-redhat-linux/lib/libnetcdff.a failed
attempt to open /usr/lib64/libnetcdff.so failed
attempt to open /usr/lib64/libnetcdff.a failed
attempt to open /usr/local/lib/libnetcdff.so failed
attempt to open /usr/local/lib/libnetcdff.a failed
attempt to open /lib/libnetcdff.so failed
attempt to open /lib/libnetcdff.a failed
attempt to open /usr/lib/libnetcdff.so failed
attempt to open /usr/lib/libnetcdff.a failed
ld: cannot find -lnetcdff
'''
It seems ld tried to search -lnetcdff through some default folder, instead of what I set up through LD_LIBRARY_PATH or nf-config --flibs.
It would be appreciated to have your advice!
Best regards
Yifan
compiling ROMS problem--ld: cannot find -lnetcdff
Re: compiling ROMS problem--ld: cannot find -lnetcdff
There are a couple oddities about your 'nf-config --flibs' output. First, "-O" and "-tp p7" are compiling flags, not linking flags. That would suggest that perhaps NetCDF wasn't configured/compiled quite right. Second, why is -R (I believe being treated as -rpath in this case) used for the C library? I have never seen this from a NetCDF install before. Was this done on purpose? You need to get your NetCDF build sorted out before attempting to compile ROMS.
From you 'nf-config --flib' output it's clear that you have not enabled NetCDF4, what that intentional?
Regarding your 'ld -lnetcdff --verbose' output: ld does not take LD_LIBRARY_PATH into account. That is only used at run time. LIBRARY_PATH is used by most linkers at link time. That said, using LIBRARY_PATH to get things working is really just a hack/kludge.
What revision number of ROMS are you using?
In your build.bash file, did you mean that you have set "USE_NETCDF4=on"? If you have also turned on "USE_MY_LIBS" then you are setting the NF_CONFIG environment variable and overriding the "nf-config" that is in your path. This would mean that locations to your NetCDF libs are being set incorrectly but we can't really determine what is happening without seeing your build.bash and the actual link line. The compiling output you posted looks like it's just the stderr output and not the stdout. Are you redirecting in your build line (i.e. ./build.bash > build.log)? If so we also need the contents of "build.log" to see what information is being passed to the linker. The line I'm interested in will look something like this:
From you 'nf-config --flib' output it's clear that you have not enabled NetCDF4, what that intentional?
Regarding your 'ld -lnetcdff --verbose' output: ld does not take LD_LIBRARY_PATH into account. That is only used at run time. LIBRARY_PATH is used by most linkers at link time. That said, using LIBRARY_PATH to get things working is really just a hack/kludge.
What revision number of ROMS are you using?
In your build.bash file, did you mean that you have set "USE_NETCDF4=on"? If you have also turned on "USE_MY_LIBS" then you are setting the NF_CONFIG environment variable and overriding the "nf-config" that is in your path. This would mean that locations to your NetCDF libs are being set incorrectly but we can't really determine what is happening without seeing your build.bash and the actual link line. The compiling output you posted looks like it's just the stderr output and not the stdout. Are you redirecting in your build line (i.e. ./build.bash > build.log)? If so we also need the contents of "build.log" to see what information is being passed to the linker. The line I'm interested in will look something like this:
Code: Select all
/opt/sw/apps/intel-18.0.1/openmpi/3.1.2/bin/mpif90 -fp-model precise -heap-arrays -g -check all -check bounds -traceback -check uninit -warn interfaces,nouncalled -gen-interfaces -fp-model precise -heap-arrays -g -check all -check bounds -traceback -check uninit -warn interfaces,nouncalled -gen-interfaces /tmp/Build_romsG/roms_import.o /tmp/Build_romsG/propagator.o /tmp/Build_romsG/master.o /tmp/Build_romsG/roms_export.o /tmp/Build_romsG/coupler.o /tmp/Build_romsG/esmf_roms.o /tmp/Build_romsG/ocean_control.o -o /tmp/romsG /tmp/Build_romsG/libUTIL.a /tmp/Build_romsG/libNLM.a /tmp/Build_romsG/libNLM_bio.a /tmp/Build_romsG/libNLM_sed.a /tmp/Build_romsG/libANA.a /tmp/Build_romsG/libUTIL.a /tmp/Build_romsG/libMODS.a -L/opt/sw/apps/intel-18.0.1/netcdf/4.6.1/lib -lnetcdff -L/opt/sw/apps/intel-18.0.1/netcdf/4.6.1/lib -L/opt/sw/apps/intel-18.0.1/hdf5/1.8.20/lib -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lm -lz -lcurl -ldl
Re: compiling ROMS problem--ld: cannot find -lnetcdff
robertson wrote:There are a couple oddities about your 'nf-config --flibs' output. First, "-O" and "-tp p7" are compiling flags, not linking flags. That would suggest that perhaps NetCDF wasn't configured/compiled quite right. Second, why is -R (I believe being treated as -rpath in this case) used for the C library? I have never seen this from a NetCDF install before. Was this done on purpose? You need to get your NetCDF build sorted out before attempting to compile ROMS.
From you 'nf-config --flib' output it's clear that you have not enabled NetCDF4, what that intentional?
Regarding your 'ld -lnetcdff --verbose' output: ld does not take LD_LIBRARY_PATH into account. That is only used at run time. LIBRARY_PATH is used by most linkers at link time. That said, using LIBRARY_PATH to get things working is really just a hack/kludge.
What revision number of ROMS are you using?
In your build.bash file, did you mean that you have set "USE_NETCDF4=on"? If you have also turned on "USE_MY_LIBS" then you are setting the NF_CONFIG environment variable and overriding the "nf-config" that is in your path. This would mean that locations to your NetCDF libs are being set incorrectly but we can't really determine what is happening without seeing your build.bash and the actual link line. The compiling output you posted looks like it's just the stderr output and not the stdout. Are you redirecting in your build line (i.e. ./build.bash > build.log)? If so we also need the contents of "build.log" to see what information is being passed to the linker. The line I'm interested in will look something like this:
Code: Select all
/opt/sw/apps/intel-18.0.1/openmpi/3.1.2/bin/mpif90 -fp-model precise -heap-arrays -g -check all -check bounds -traceback -check uninit -warn interfaces,nouncalled -gen-interfaces -fp-model precise -heap-arrays -g -check all -check bounds -traceback -check uninit -warn interfaces,nouncalled -gen-interfaces /tmp/Build_romsG/roms_import.o /tmp/Build_romsG/propagator.o /tmp/Build_romsG/master.o /tmp/Build_romsG/roms_export.o /tmp/Build_romsG/coupler.o /tmp/Build_romsG/esmf_roms.o /tmp/Build_romsG/ocean_control.o -o /tmp/romsG /tmp/Build_romsG/libUTIL.a /tmp/Build_romsG/libNLM.a /tmp/Build_romsG/libNLM_bio.a /tmp/Build_romsG/libNLM_sed.a /tmp/Build_romsG/libANA.a /tmp/Build_romsG/libUTIL.a /tmp/Build_romsG/libMODS.a -L/opt/sw/apps/intel-18.0.1/netcdf/4.6.1/lib -lnetcdff -L/opt/sw/apps/intel-18.0.1/netcdf/4.6.1/lib -L/opt/sw/apps/intel-18.0.1/hdf5/1.8.20/lib -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lm -lz -lcurl -ldl
Hi Robertson,
Thanks for your reply!
The ROMS version should be 891 (as build.bash shown at the begining. is this the right place to get the version?), updated on 2018-02-11. Yes, you are right. I created a log file (compile.log) when compiling ROMS. The attached compile.log file and build.bash file may be useful. The example information in that log like this:
Code: Select all
ROMS/Bin/cpp_clean /home/ywang/roms/Projects/Upwelling/Build/master.f90
cd /home/ywang/roms/Projects/Upwelling/Build; /opt/pgi_with_netcdf/linux86-64/16.10/bin/pgf90 -c -Kieee -g -C master.f90
/opt/pgi_with_netcdf/linux86-64/16.10/bin/pgf90 -Kieee -g -C /home/ywang/roms/Projects/Upwelling/Build/coupler.o /home/ywang/roms/Projects/Upwelling/Build/esmf_roms.o /home/ywang/roms/Projects/Upwelling/Build/master.o /home/ywang/roms/Projects/Upwelling/Build/ocean_control.o /home/ywang/roms/Projects/Upwelling/Build/propagator.o /home/ywang/roms/Projects/Upwelling/Build/roms_export.o /home/ywang/roms/Projects/Upwelling/Build/roms_import.o -o /home/ywang/roms/Projects/Upwelling/oceanG /home/ywang/roms/Projects/Upwelling/Build/libUTIL.a /home/ywang/roms/Projects/Upwelling/Build/libNLM.a /home/ywang/roms/Projects/Upwelling/Build/libNLM_bio.a /home/ywang/roms/Projects/Upwelling/Build/libNLM_sed.a /home/ywang/roms/Projects/Upwelling/Build/libANA.a /home/ywang/roms/Projects/Upwelling/Build/libUTIL.a /home/ywang/roms/Projects/Upwelling/Build/libMODS.a -L/proj/pgi/linux86-64/2016/netcdf/netcdf-fortran-4.4.2/lib -lnetcdff -O -tp p7 -L/proj/pgi/linux86-64/2016/netcdf/netcdf-4.3.3.1/lib -R/proj/pgi/linux86-64/2016/netcdf/netcdf-4.3.3.1/lib -lnetcdf -lnetcdf
- libnetcdf.a
libnetcdf_c++4.a
libnetcdf_c++4.la
libnetcdf_c++4.so
libnetcdf_c++4.so.1
libnetcdf_c++4.so.1.0.2
libnetcdff.a
libnetcdff.la
libnetcdff.so
libnetcdff.so.6
libnetcdff.so.6.0.1
libnetcdf.la
libnetcdf.settings
libnetcdf.so
libnetcdf.so.7
libnetcdf.so.7.2.0
Thanks for your help!
Best regards
Yifan
- Attachments
-
- build.bash
- (18.21 KiB) Downloaded 361 times
-
- compile.log
- (248.88 KiB) Downloaded 346 times
Re: compiling ROMS problem--ld: cannot find -lnetcdff
The directory you listed looks to have all the libraries you need in the same directory. Is the nf-config you're using associated with that lib directory you listed? I would guess not since the output of "nf-config --flibs" has different directories for libnetcdff and libnetcdf.