Menu

#50 static dl linking on command line causes link errors

1d FEM
open
nobody
None
2014-07-17
2014-07-17
No

During linking of the binary, I'm getting:

/home/js9/xolotl/install/hdf5par/lib/libhdf5.a(H5PL.o): In function 'H5PL_load':
H5PL.c:(.text+0x454): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking`
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libdl.a(dlopen.o): In function 'dlopen':
(.text+0x5): undefined reference to '__dlopen'

(and other undefined refs which should be resolved by dlopen)

The issue appears to be that the -ldl calls are in static link sections (sandwiched between -Bstatic and -Bdynamic). I get that HDF5 seems to only build parallel versions into static libraries, but I haven't quite figured out why, since it's pulling in libhdf5.a explicitly, it then forces static linking for libz and libdl. If I simply remove the -ldl calls from the static linking at put it outside those sections on the link line, it appears to proceed without error.

This is on Ubuntu 12.04, with gcc-4.7 installed from ppa:ubuntu-toolchain-r, so it could very well be that this is a platform-specific problem. I built hdf5 1.8.13, all sources which came from repositories checked out fresh on July 17 2014.

Full link line:

mpic++ -std=c++0x -O3 -DNDEBUG CMakeFiles/xolotl.dir/main.cpp.o -o xolotl -rdynamic xolotlCore/reactants/libxolotlReactants.a xolotlSolver/libxolotlSolver.a xolotlCore/io/libxolotlIO.a xolotlPerf/libxolotlPerf.a xolotlViz/libxolotlViz.a xolotlCore/commandline/libxolotlCL.a /home/js9/xolotl/install/petsc-latest_mpich-311/lib/libpetsc.so /home/js9/xolotl/install/hdf5par/lib/libhdf5.a -Wl,-Bstatic -lz -lm xolotlCore/reactants/libxolotlReactants.a xolotlCore/io/libxolotlIO.a -Wl,-Bdynamic /home/js9/xolotl/install/hdf5par/lib/libhdf5.a -Wl,-Bstatic -lz -ldl -lm xolotlPerf/libxolotlPerf.a -Wl,-Bdynamic /home/js9/xolotl/install/EAVL/lib/libeavl.a /home/js9/xolotl/install/Mesa-7.5.2/lib/libOSMesa.a -Wl,-rpath,/home/js9/xolotl/install/petsc-latest_mpich-311/lib -ldl

Discussion


Log in to post a comment.