Unidata / netcdf-c

Official GitHub repository for netCDF-C libraries and utilities.
BSD 3-Clause "New" or "Revised" License
509 stars 262 forks source link

netcdf-c has c++ dependency when linking and library built with --disable-libxml2 --disable-shared #2851

Open phildurbin opened 7 months ago

phildurbin commented 7 months ago

Then trying to compile the netcdf-fortran (or anything down stream) requires -lstdc++; eg gcc -o conftest -I/tis/releases/ac/zlib/1.2.11-1/include -I/tis/releases/ac/hdf4/4.2.16-3/include -I/tis/releases/ac/hdf5/1.14.3-5/include -I/tis/releases/ac/szip/2.1.1-3/include -I/tis/releases/ac/jpeg/9.1-1/include -I/scratch/pdurbin/tmp2/netcdf-c/include -L/tis/releases/ac/zlib/1.2.11-1/lib -L/tis/releases/ac/hdf4/4.2.16-3/lib -L/tis/releases/ac/hdf5/1.14.3-5/lib -L/tis/releases/ac/szip/2.1.1-3/lib -L/tis/releases/ac/jpeg/9.1-1/lib -L/scratch/pdurbin/tmp2/netcdf-c/lib ~/tmp.c -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lm -lz -ldl -lcurl -lsz -ljpeg usr/bin/ld: /scratch/pdurbin/tmp2/netcdf-c/lib/libnetcdf.a(ncxml_tinyxml2.o): in function ncxml_parse': /scratch/pdurbin/netcdf-c-4.9.2/libncxml/ncxml_tinyxml2.cpp:35: undefined reference tooperator new(unsigned long)' /usr/bin/ld: /scratch/pdurbin/netcdf-c-4.9.2/libncxml/ncxml_tinyxml2.cpp:35: undefined reference to operator delete(void*)' /usr/bin/ld: /scratch/pdurbin/tmp2/netcdf-c/lib/libnetcdf.a(ncxml_tinyxml2.o):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to__gxx_personality_v0' /usr/bin/ld: /scratch/pdurbin/tmp2/netcdf-c/lib/libnetcdf.a(tinyxml2.o): in function tinyxml2::DynArray<char, 20>::EnsureCapacity(int)': /scratch/pdurbin/netcdf-c-4.9.2/libncxml/tinyxml2.h:308: undefined reference tooperator new[](unsigned long)' /usr/bin/ld: /scratch/pdurbin/netcdf-c-4.9.2/libncxml/tinyxml2.h:312: undefined reference to operator delete[](void*)' /usr/bin/ld: /scratch/pdurbin/netcdf-c-4.9.2/libncxml/tinyxml2.h:308: undefined reference tooperator new[](unsigned long)' ... tmp.c is attached as tmp.c.txt which came from configure in netcdf-fortan tmp.c.txt

DennisHeimbigner commented 7 months ago

Not sure what can be done about this. DAP4 requires an XML parser: either tinyxml (built-in) or libxml2.

WardF commented 1 month ago

@DennisHeimbigner would turning off dap4 and nczarr remove the requirement for compiling tinyxml in the absense of libxml2? e.g., if DAP4 and nczarr are disabled, do we need an xml parser at all? I don't think we do, and I can gate it off if need be.

DennisHeimbigner commented 1 month ago

So as far as I can tell, C++ is needed for these files: ./libncxml/tinyxml2.cpp ./libncxml/ncxml_tinyxml2.cpp ./nczarr_test/tst_pure_awssdk.cpp ./libdispatch/ncs3sdk_aws.cpp ./libnczarr/zs3sdk.cpp

So yes, turning off DAP4 and NCZARR should disable the need for any xml library. As for tinyxml vs libxml2, if libxml2 is available, then the tinyxml2 code in libncxml should not need to be compiled.

WardF commented 1 month ago

If don't have libxml2 available, and we don't enable nczarr or DAP4, it seems like we can avoid compiling tinyxml2 and retain libnetcdf as a pure C library.

DennisHeimbigner commented 1 month ago

I think that is correct.