Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
phildurbin opened this issue Jan 31, 2024 · 5 comments

Comments

@phildurbin
Copy link

  • version 4.9.2
  • ubuntu 20.04
  • netcdf-c has a c++ dependency when linking using a library built with --disable-libxml2 --disable-shared via configure . when the libxml2 library is is disabled it uses the c++ code tinynxml. The problem is that when trying to build a static binary not all the symbols are resolved and the resulting library has a dependency on stdc++ library when linking applications. Hence is no longer a c library.
    configure options:
    ./configure --disable-libxml2 --disable-parallel4 --disable-shared --disable-dap-remote-tests --prefix=${CI_PROJECT_DIR}/netcdf-c

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 to operator 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 to operator 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 to operator new[](unsigned long)'
...
tmp.c is attached as tmp.c.txt which came from configure in netcdf-fortan
tmp.c.txt

@DennisHeimbigner
Copy link
Collaborator

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

@WardF
Copy link
Member

WardF commented Aug 19, 2024

@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
Copy link
Collaborator

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
Copy link
Member

WardF commented Aug 19, 2024

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
Copy link
Collaborator

I think that is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants