Skip to content

For static build, libraries are listed in wrong order #3120

@gsjaardema

Description

@gsjaardema

netCDF-c version 4.9.3
OS -- macos and linux were only ones tested

When I build netCDF-c as a static only library, the generated dependent libraries in nc-config and libnetcdf.settings list the hdf5-related libraries in the wrong order and result in missing symbols in the link.

Here is the nc-config --static output:

-L/Users/me/src/project-static/lib -lnetcdf -lHDF5::HDF5 -lhdf5::hdf5_hl -lm -lz -ldl -lzstd -lbz2 -lxml2

And here is the corresponding line in the libnetcdf.settings

Shared Library:		no
Static Library:		yes
Extra libraries:	-lHDF5::HDF5 -lhdf5::hdf5_hl -lm -lz -ldl -lzstd -lbz2 -lxml2

The hdf5_hl library needs to come before the hdf5 library in order to resolve all symbols.
This also happens in the netCDFTargets.cmake CMake configuration file.

Metadata

Metadata

Assignees

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