Cppunit wont link without -Wl,--no-as-needed

Bug #985841 reported by Richard Eames
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cppunit (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I may be doing something stupid here, but I think it's a bug with the package in precise, since it used to work before I upgraded.

I definitely have libcppunit and -dev installed:
$ apt-cache policy libcppunit-dev
libcppunit-dev:
  Installed: 1.12.1-4
  Candidate: 1.12.1-4
  Version table:
 *** 1.12.1-4 0
        500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status

$ apt-cache policy libcppunit-1.12-1
libcppunit-1.12-1:
  Installed: 1.12.1-4
  Candidate: 1.12.1-4
  Version table:
 *** 1.12.1-4 0
        500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status
$ ls /usr/lib/ | grep cppunit
libcppunit-1.12.so.1
libcppunit-1.12.so.1.0.0
libcppunit.a
libcppunit.la
libcppunit.so

$ sudo ldconfig -p |grep cppunit
 libcppunit-1.12.so.1 (libc6,x86-64) => /usr/lib/libcppunit-1.12.so.1

But if I try to link with the attached sample program I get linker errors:

$ g++ -lcppunit -o test.bin test.cpp
/tmp/ccoQDuGC.o: In function `main':
test.cpp:(.text+0x36): undefined reference to `CppUnit::TestFactoryRegistry::getRegistry(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
test.cpp:(.text+0x75): undefined reference to `CppUnit::TextTestRunner::TextTestRunner(CppUnit::Outputter*)'
test.cpp:(.text+0x8b): undefined reference to `CppUnit::TestRunner::addTest(CppUnit::Test*)'
test.cpp:(.text+0x9a): undefined reference to `CppUnit::TextTestRunner::result() const'
test.cpp:(.text+0xe2): undefined reference to `CppUnit::CompilerOutputter::CompilerOutputter(CppUnit::TestResultCollector*, std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
test.cpp:(.text+0xf4): undefined reference to `CppUnit::TextTestRunner::setOutputter(CppUnit::Outputter*)'
test.cpp:(.text+0x150): undefined reference to `CppUnit::TextTestRunner::run(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool)'
test.cpp:(.text+0x189): undefined reference to `CppUnit::TextTestRunner::~TextTestRunner()'
test.cpp:(.text+0x227): undefined reference to `CppUnit::TextTestRunner::~TextTestRunner()'
collect2: ld returned 1 exit status

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: libcppunit-1.12-1 1.12.1-4
ProcVersionSignature: Ubuntu 3.2.0-23.36-generic 3.2.14
Uname: Linux 3.2.0-23-generic x86_64
ApportVersion: 2.0.1-0ubuntu5
Architecture: amd64
Date: Thu Apr 19 13:21:45 2012
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
ProcEnviron:
 LANGUAGE=en_CA:en
 TERM=xterm
 PATH=(custom, no user)
 LANG=en_CA.UTF-8
 SHELL=/bin/bash
SourcePackage: cppunit
UpgradeStatus: Upgraded to precise on 2012-04-02 (17 days ago)

Revision history for this message
Richard Eames (naddiseo) wrote :
Revision history for this message
Richard Eames (naddiseo) wrote :

Current work around is to add "-Wl,--no-as-needed" before "-lcppunit". So this leads me to believe the package might not have been built properly.

summary: - Cannot link to cppunit even though it's installed.
+ Cppunit wont link without -Wl,--no-as-needed
Revision history for this message
Björn Michaelsen (bjoern-michaelsen) wrote :
Revision history for this message
Mattia Rizzolo (mapreri) wrote :

currently, with cppunit 1.15.1, this works flawleslly, and I also doubt this had been a problem for long since --as-need has been default gcc behaviour in ubuntu for years already.

Changed in cppunit (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.