#201 libcppunit.so is not linked against libdl

open
nobody
5
2010-11-30
2010-11-30
bl4sph3my
No

x86_64-pc-linux-gnu-g++ -shared -nostdlib /usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.1/crtbeginS.o .libs/Additiona
lMessage.o .libs/Asserter.o .libs/BeOsDynamicLibraryManager.o .libs/BriefTestProgressListener.o .libs/CompilerOutputter.o .libs/DefaultProtector.o .libs/DynamicLibraryManager.o
.libs/DynamicLibraryManagerException.o .libs/Exception.o .libs/Message.o .libs/RepeatedTest.o .libs/PlugInManager.o .libs/PlugInParameters.o .libs/Protector.o .libs/ProtectorCha
in.o .libs/SourceLine.o .libs/StringTools.o .libs/SynchronizedObject.o .libs/Test.o .libs/TestAssert.o .libs/TestCase.o .libs/TestCaseDecorator.o .libs/TestComposite.o .libs/Tes
tDecorator.o .libs/TestFactoryRegistry.o .libs/TestFailure.o .libs/TestLeaf.o .libs/TestNamer.o .libs/TestPath.o .libs/TestPlugInDefaultImpl.o .libs/TestResult.o .libs/TestResul
tCollector.o .libs/TestRunner.o .libs/TestSetUp.o .libs/TestSuccessListener.o .libs/TestSuite.o .libs/TestSuiteBuilderContext.o .libs/TextOutputter.o .libs/TextTestProgressListe
ner.o .libs/TextTestResult.o .libs/TextTestRunner.o .libs/TypeInfoHelper.o .libs/UnixDynamicLibraryManager.o .libs/ShlDynamicLibraryManager.o .libs/XmlDocument.o .libs/XmlElemen
t.o .libs/XmlOutputter.o .libs/XmlOutputterHook.o .libs/Win32DynamicLibraryManager.o -Wl,--rpath -Wl,/usr/lib64/../lib64 -Wl,--rpath -Wl,/usr/lib64/../lib64 -L/usr/lib64/gcc/x8
6_64-pc-linux-gnu/4.5.1 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.1/../../../../x
86_64-pc-linux-gnu/lib -L/usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.1/../../.. /usr/lib64/../lib64/libstdc++.so -lm -lc -lgcc_s /usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.1/crtendS.o /u
sr/lib64/gcc/x86_64-pc-linux-gnu/4.5.1/../../../../lib64/crtn.o -march=native -Wl,-soname -Wl,libcppunit-1.12.so.1 -o .libs/libcppunit-1.12.so.1.0.0

missing -ldl leads to

/usr/lib64/libcppunit.so: undefined reference to `dlsym'
/usr/lib64/libcppunit.so: undefined reference to `dlopen'
/usr/lib64/libcppunit.so: undefined reference to `dlclose'
collect2: ld returned 1 exit status

Discussion

  • src/cppunit/Makefile.am needs something like:
    libcppunit_la_LIBADD= $(LIBADD_DL)

    Also not, that this has gone unnoticed because of wrong LDFLAGS:
    It must be "-Wl,-no-undefined" not just "-no-undefined"

     
  • Sumit Sengupta
    Sumit Sengupta
    2011-12-08

    you can also set LDFLAGS env variable before the build:
    export LDFLAGS="-Wl,-rpath,/usr/lib -ldl"