Can't compile C++ code: "undefined reference to:"

Bug #888495 reported by Ángel Fernández
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
armadillo (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When I try to compile code that did work in previous Kubuntu release, where libarmadillo0 was the package, now I cannot.
Using Ubuntu Oneiric 11.10, and fulfilling the dependences here suggested. Somehow, there may be some missing links.
Packages: libarmadillo2 2.0.1+dfsg-1 0; libarmadillo-dev 2.0.1+dfsg-1 0

This is a g++ compiler output example (I add the flag -larmadillo):

/tmp/ccI9Nbay.o: In function `void arma::lapack::syev<double>(char*, char*, int*, double*, int*, double*, double*, int*, int*)':
program.cpp:(.text._ZN4arma6lapack4syevIdEEvPcS2_PiPT_S3_S5_S5_S3_S3_[void arma::lapack::syev<double>(char*, char*, int*, double*, int*, double*, double*, int*, int*)]+0x45): undefined reference to `dsyev_'

Revision history for this message
Julian Taylor (jtaylor) wrote :

this is most likely due to the toolchain transition done in oneiric:
https://wiki.kubuntu.org/NattyNarwhal/ToolchainTransition

read the part about --as-needed

Changed in armadillo (Ubuntu):
status: New → Incomplete
Revision history for this message
nobody (conradsand) wrote :

I've confirmed this bug. Indeed it is due to the toolchain transition.

The fix is available in the updated version: Armadillo 2.4.2

I strongly recommend updating the package in Ubuntu.

Upstream:
http://arma.sourceforge.net/download.html

Debian package:
http://packages.debian.org/hu/source/sid/armadillo

Changed in armadillo (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Julian Taylor (jtaylor) wrote :

in what way was it solved in the new version? I can't find a changelog or release notes for it.
to me it looks like an --no-add-needed issue which can only be solved by using e.g. pkg-config which also the new upstream version does not have.

Revision history for this message
Julian Taylor (jtaylor) wrote :

ok apparently it is really solved in the new version which should land in precise in a few days.
They probably moved all external function definitions out of the headers.

Revision history for this message
Matthias Klose (doko) wrote :

please attach a build log (verbose)

Changed in armadillo (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
nobody (conradsand) wrote :

There is no associated build log, as prior to version 2.4.x, Armadillo was a pure C++ template library. The examples provided in the archive are not built by default, hence it is impossible to detect the problem at build time.

In versions prior to 2.4.x, Armadillo relied on a linking trick that no longer works due to the toolchain update. In version 2.4.x, this trick is no longer used.

The associated Armadillo packages in Debian have been fixed and are in the "testing" stream.

Specifically, the fix is in:
"libarmadillo-dev (1:2.4.2+dfsg-2)"
and
"libarmadillo2 (1:2.4.2+dfsg-2)"

http://packages.debian.org/testing/libarmadillo-dev
http://packages.debian.org/testing/libarmadillo2

As such, the armadillo package can now be updated in Ubuntu.

Changed in armadillo (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Julian Taylor (jtaylor) wrote :

do we need a fix for this?
the difference is a bit too large for an easy SRU.

the fix is quite simple, link with some blas providing library.

Julian Taylor (jtaylor)
Changed in armadillo (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Tomas P (em67673) wrote :

Let me put here my workaround (steps 2&3 bellow) for people who could not find any working solution for kubuntu 11.10:

1. apt-get install libarmadillo2 libblas3gf liblapack3gf libarmadillo-dev
2. sudo ln -s /usr/lib/libblas.so.3gf /usr/lib/libblas.so
3. sudo ln -s /usr/lib/liblapack.so.3gf /usr/lib/liblapack.so

then
  g++ test.cpp -larmadillo -lblas -llapack
works. Indeed, the other way
  g++ -larmadillo -lblas -llapack test.cpp
it doesn't (which means in netbeans you need: project properties -> Build -> Linker -> Libraries -> Other Option.)

Revision history for this message
Julian Taylor (jtaylor) wrote :

the symlinking should not be necessary, they should be created by blas providing packages via the alternatives mechanism
the second line is wrong in any program, libraries always go behind objects needing their symbols.

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.