This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Phil, > Hope you don't mind. I have some questions about the NetCDF-C++ library. > > Why do the instructions mention that the interface requires the > additional flag "--enable-netcdf-4" to be used, yet the example uses > the flag "--enable-cxx-4". I used neither, and everything seems to work > correctly. I can compile and run at least one of the examples. I think Google has probably pointed you to an old install document, e.g. https://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Configure.html that was intended for building netCDF-4 when the C++ and Fortran libraries were bundled with the netCDF-C library. That's no longer the case, they are now separate distributions and the netcdf-cxx4 library depends on the netcdf-c library that must be installed first. The closest thing to current instructions for installing netcdf-cxx4 would be to use the up-to-date instructions for installing netCDF-Fortran, but substituting C++ for Fortran and ignoring parts that don't apply to C++ http://www.unidata.ucar.edu/software/netcdf/docs/building_netcdf_fortran.html > ... However, > this is only possible if I link to the static (*.a) libraries. I am > finding that any attempt to use the dynamic (*.so) library produces the > following error: > > error while loading shared libraries: libnetcdf_c++4.so.1: > cannot open shared object file: No such file or directory I think that's probably because you need to either set LD_LIBRARY_PATH to include the directory where you installed libnetcdf_c++4 or follow these instructions that "make install" should have printed oput at then end of a successful install: 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 is despite the fact that both the static and dynamic libraries are > available in same directory. Right, it's a security thing that using shared libraries is not as straightforward as static libraries, but there are other advantages. > In addition to the above, I found (after a few hours of confusion) > that the order of linking is critical. Compilation has to link to > libhdf5_hl.a *before* libhdf5.a. Otherwise, compilation fails. > > Is there any more substantial documentation available anywhere? Sorry we don't have any C++ installation documentation available yet. It's sort of on the back burner, and currently lacks assigned resources. --Russ > UNEP-WCMC - serving the biodiversity community for 30 years > > ** Confidentiality Statement and Disclaimer ** > This e-mail, together with any attachments, may contain confidential info > rmation and/or copyright material. Any views or opinions presented are > sole ly those of the author and do not necessarily represent those of > UNEP-WCMC. It is intended only for the person named above. Any copying, > distribution, dissemination, disclosure or use of this message or its > contents unless authorised by us is strictly prohibited. If you have > received this message in error, please notify us immediately. > > You should understand and accept that email communication with UNEP-WCMC > is not a totally secure communications medium. Although we have taken > steps to ensure that this e-mail and attachments are free from any virus, > we cannot guarantee that they are virus free. We do not, to the extent > permitted by law, accept any liability (whether in contract, negligence > or otherwise) for any virus infection and/or external compromise of > security and/or breach of confidentiality in relation to transmissions > sent by e-mail. > > Thank you. > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: IDL-671230 Department: Support netCDF Priority: Normal Status: Closed