[ET Trac] #2822: support full paths to libraries in LIBS variables
Roland Haas
trac-noreply at einsteintoolkit.org
Wed Sep 4 11:43:13 CDT 2024
#2822: support full paths to libraries in LIBS variables
Reporter: Roland Haas
Status: open
Milestone:
Version:
Type: bug
Priority: minor
Component:
Changes (by Roland Haas):
On macOS using Homebrew `pkg-config` for HDF5 returns full library paths instead of `-lLIBNAME` stanzas:
```
rhaas at gdd6l52n-ofc Cactus % pkg-config --libs-only-l --static hdf5
-lhdf5 -lm -ldl -l/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libz.tbd -l/opt/homebrew/lib/libsz.dylib
```
This happens only for static linking. This causes g\+\+ to fail at link time:
```
rhaas at gdd6l52n-ofc Cactus % g++-14 `pkg-config --libs-only-L hdf5` `pkg-config --libs-only-l --static hdf5` dummy.c
ld: library '/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libz.tbd' not found
collect2: error: ld returned 1 exit status
```
This seems like bug in the pkg-config file \(\`/opt/homebrew/Cellar/hdf5/1.14.3\_1/lib/pkgconfig/hdf5.pc\`\) supplied by HomeBrew:
```
rhaas at gdd6l52n-ofc Cactus % cat /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/pkgconfig/hdf5.pc
prefix=/opt/homebrew/Cellar/hdf5/1.14.3_1
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: hdf5
Description: HDF5 (Hierarchical Data Format 5) Software Library
Version: 1.14.3
Cflags: -I${includedir}
Libs: -L${libdir} -lhdf5
Requires:
Libs.private: -lhdf5 -lm -ldl -l/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libz.tbd -l/opt/homebrew/lib/libsz.dylib -l/opt/homebrew/lib/libsz.dylib
Requires.private:
```
Correct would be to not use `-l` with the full path \(at least it will link\):
```
g++-14 `pkg-config --libs-only-L hdf5` dummy.c /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libz.tbd
```
Right now we have no way of handling full paths in LIBS files though git hash [cb3a8731](https://bitbucket.org/cactuscode/cactus/commits/cb3a873135a3032230aa687ed6174081c66b90b1) "Cactus: New pseudo-flag `-file=`" of [cactus](https://bitbucket.org/cactuscode/cactus) proposes some \(partial\) solution. This would require changes in all ExternalLibraries though \(that may need to pass `LIBS` to their own `configure`\). Another solution might be \(in `bash_utils.sh`\) to detect full paths in `-l` entries and split into a `-L` and a `-l` entry. This assumes knowledge of the library prefix \(usually `lib`\) and extension \(`.a`, `.so`, `.dylib`, `.dll`\).
A workaround for HDF5 is to self-compile HDF5 using `HDF5_DIR=BUILD`.
--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2822/support-full-paths-to-libraries-in-libs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.einsteintoolkit.org/pipermail/trac/attachments/20240904/46c119f8/attachment.htm>
More information about the Trac
mailing list