Beata, > After I had set LD_LIBRARY_PATH I could run the model. I got some error > messages in connection with the code. > After I fixed the errors and ran the model I again get error: error while > loading shared libraries: > âlibnetcdff.so.6: cannot open shared object file: Not such file or > directoryâ in spite the fact that LD_LIBRARY_PATH is set. > Could you please write me how I can fix this problem? Setting LD_LIBRARY_PATH only works while you are running commands in the same shell in which that environment variable was set. Logging out and then logging in again won't preserve environment variables across logins. Similarly, running a different shell within the shell you in which you set LD_LIBRARY_PATH won't inherit the LD_LIBRARY_PATH setting, unless you explicitly export the shell environment variable, with a command such as $ export LD_LIBRARY_PATH One way to make environment variables persist across logins is to set them and "export" them from your shell startup file, which probably has a name such as ~/.bash_profile, ~/.bash_login, or ~/.profile. If you use a different shell than bash, you will have to check its documentation to find out what it expects to read when you login. If you start another interactive shell without logging in again, the shell executes commands from .bashrc, or a similar file with a different name for other shells. Interactive shells inherit environment variables that were explicitly exported from the parent shell, but not variables that weren't inherited. (Also a shell run by root won't inherit LD_LIBRARY_PATH or other linker flags even if they are exported, to avoid a security problem.) If you start a shell non-interactively, to run a shell script, for example, you can specify a different file to be run, as detailed in the bash documentation. If you have a model that you just want to always find the necessary libraries without setting LD_LIBRARY_PATH in every session, a better way is to store the locations of the libraries the model needs in the model executable. You can do this by following the instructions output at the end of the netCDF "make install": ---------------------------------------------------------------------- Libraries have been installed in: [wherever you specified, for example LIBDIR] If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,-rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- This may seem complicated, but using shared libraries also has many benefits, if you can get the linking right. --Russ > 2015.02.16. 17:37 keltezÃssel, Unidata netCDF Support Ãrta: > > Hi Beata, > > > > Before linking your application, you need to tell your dynamic linker, > > ld.so, > > where to look for the shared libraries to use. One way to do this is by > > setting the LD_LIBRARY_PATH environment variable, as in: > > > > $ export LD_LIBRARY_PATH=${NCPATH}/lib:${LD_LIBRARY_PATH} > > > > See the man page for ld.so for other ways to do the same thing, including > > use of LD_RUN_PATH during linking, or use of the `-Wl,-rpath -Wl,LIBDIR' > > linker flags. > > > > --Russ > > > >> I would like to run a model is written Fortran90 under Ubuntu 14.04. I use > >> gfortran 95 compiler (gfortran 4:4.8.2-1ubuntu6). The required netCDF > >> libraries (netCDF-4.3.2 and NetCDF-Fortran 4.4.1) are installed as > >> suggested in: http://www.unidata.ucar.edu/software/netcdf/docs/. The > >> netcdf is built as shared library so libnetcdf.so and libnetcff.so files > >> there are in the library directory. The libgfortran3 4.8.2-19ubuntu1 is > >> installed for GNU fortran application linked against the shared library. > >> The LDFLAGS is set in the compiler_options.inc file by the following way: > >> INCDF=-I$(NCPATH)/include > >> LNCDF=-L$(NCPATH)/lib -lnetcdff > >> LDFLAGS=$(INCDF) $(LNCDF) > >> > >> When I run the model I get the following error message: > >> error while loading shared libraries: libnetcdff.so.6: cannot open shared > >> object fÃjl: Not such fÃjl or directory. > >> > >> I launched the ldd command on my executable and the file command on my > >> shared libraries. I found the following results: > >> address@hidden:~/Downloads/kid_a_setup/bin$ ldd > >> ./KiD_SC_2D.exe > >> linux-vdso.so.1 => (0x00007fff44ffe000) > >> libnetcdff.so.6 => not found > >> libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 > >> (0x00007f4bfcda7000) > >> libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4bfcaa0000) > >> libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4bfc88a000) > >> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4bfc4c4000) > >> libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 > >> (0x00007f4bfc287000) > >> /lib64/ld-linux-x86-64.so.2 (0x00007f4bfd0d8000) > >> > >> > >> address@hidden:~/netcdf/lib$ file libnetcdff.so.6 > >> > >> libnetcdff.so.6: symbolic link to `libnetcdff.so.6.0.1' > >> > >> address@hidden:~/netcdf/lib$ file libnetcdff.so.6.0.1 > >> > >> libnetcdff.so.6.0.1: ELF 64-bit LSB shared object, x86-64, version 1 > >> (SYSV), dynamically linked, > >> BuildID[sha1]=a44c6985c1c90ef8b2c89631ad029d155ec441fb, not stripped > >> > >> The version of libnetcdff and system are both 64-bit. > >> > >> I do not know how I can solve this matter? > >> > >> I wondered if you could give me a suggestion. > >> > >> Thank you for your help in advance! > >> > >> Kind regards, > >> Beata > >> > >> > >> Dr. Beata Szabo-Takacs > >> Global Change Research Centre AS CR, v.v.i. > >> B?lidla 986/4a > >> 60300 Brno > >> Czech Republic > >> > >> > > Russ Rew UCAR Unidata Program > > address@hidden http://www.unidata.ucar.edu > > > > > > > > Ticket Details > > =================== > > Ticket ID: QCT-533073 > > Department: Support netCDF > > Priority: Normal > > Status: Closed > > > > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: QCT-533073 Department: Support netCDF Priority: Normal Status: Closed
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.