Skip to content

netcdf-C 4.6.1 build error on macOS 10.13: ocprint link fails #1095

@mathomp4

Description

@mathomp4

Environment Information

  • What platform are you using? (please provide specific distribution/version in summary)
    • Linux
    • Windows
    • OSX
    • Other
    • NA
  • 32 and/or 64 bit?
    • 32-bit
    • 64-bit
  • What build system are you using?
    • autotools (configure)
    • cmake
  • Can you provide a sample netCDF file or C code to recreate the issue?
    • Yes (please attach to this issue, thank you!)
    • No
    • Not at this time

Summary of Issue

My build of netcdf-C 4.6.1 on macOS 10.13.5 isn't quite working. I'm building with GCC 8.1.0 (built from source) and Open MPI 3.1.0. I built HDF5 with --enable-parallel so mpicc is my C compiler in this stage.

From my scan of the build log, libnetcdf.a is made, but when ocprint tries to link I get:

libtool: link: mpicc -o ocprint ocprint.o  ../liblib/.libs/libnetcdf.a -L/Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib /Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib/libhdf5_hl.a /Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib/libhdf5.a /Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib/libmfhdf.a /Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib/libdf.a /Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib/libsz.a /Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib/libjpeg.a /Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/lib/libcurl.a -lz -ldl -lm
Undefined symbols for architecture x86_64:
  "_ncrc_globalstate", referenced from:
      _createtempfile in libnetcdf.a(liboc_la-ocinternal.o)
      _ocset_curlproperties in libnetcdf.a(liboc_la-ocinternal.o)
      _NC_rcload in libnetcdf.a(libdispatch_la-drc.o)
      _NC_set_rcfile in libnetcdf.a(libdispatch_la-drc.o)
      _rccompile in libnetcdf.a(libdispatch_la-drc.o)
      _rclocate in libnetcdf.a(libdispatch_la-drc.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:1046: ocprint] Error 1
make[4]: *** Waiting for unfinished jobs....

As a test, I took netcdf-C 4.5.0 (which had worked before on this machine) and tried building it instead (feeding in the exact same libraries that went into the build above) and ocprint, etc all built just fine.

As a second test, I built with --disable-dap instead (see original configure line below) and it will build because ocprint is avoided. But, this netCDF build is for a model and one of the requirements for the netCDF built is that it have OpenDAP capability, thus I can't disable dap for production.

Any ideas on how to fix this with autotools? I thought I'd troll around the CMakeLists.txt files to see if ocprint was being built/linked with extra libraries perhaps with CMake. When I did so I see:

# Apparently fails under cmake
#set(ocprint_FILES ocprint.c )
#ADD_EXECUTABLE(ocprint ${ocprint_FILES})
#TARGET_LINK_LIBRARIES(ocprint oc2 ${ALL_TLL_LIBS})

(which is in the oc2/CMakeLists.txt, not the ncdump/CMakeLists.txt).

Huh. Indeed, the autotools build seems to build things that CMake doesn't (e.g., nc4print which doesn't seem to appear in any CMakeLists.txt file in the tarball...and isn't installed, just built?).

Is there a way to get autotools build to skip ocprint? I don't think I need it (I've never used it and I know of no one else who has), but it would at least let me get a (partially) DAP-enabled netCDF built. (NOTE: I had thought about using a CMake build, but I'd probably need more help with that. I don't really know how to translate all of that configure line to CMake, especially the --includedir line. I didn't see in the INSTALL.md on how to translate that flag.)

Steps to reproduce the behavior

My configure line is:

  $ ./configure --prefix=/Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin --includedir=/Users/mathomp4/Baselibs/ESMA-Baselibs-5.1.3-netCDF461/x86_64-apple-darwin17.7.0/gfortran/Darwin/include/netcdf --enable-hdf4 --enable-dap --enable-parallel-tests --disable-shared --disable-examples --enable-netcdf-4 CC=mpicc FC=mpifort CXX=mpic++ F77=mpifort

And, as I said before, I can build 4.5.0 just fine using all the same infrastructure, but 4.6.1 won't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions