nm and ld cannot find symbols in libblas.so and other files

Bug #993991 reported by Whiteknight
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
binutils (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

After the upgrade to 12.04, I am unable to link against the libblas.so (and friends), libatlas.so (and friends), libcblas.so, libopenblas.so, and other files. These are from different packages such as libblas-dev, libatlas-base-dev, libopenblas-dev, etc. I do not know if this is a problem with other libraries as well. I have been able to build and link most other software like normal, these are the only ones I find that are problematic.

When I type "nm /usr/lib/libblas.so" I get this error message: "nm: /usr/lib/libblas.so: no symbols"

However, when I type the command "objdump -T /usr/lib/libblas.so", I get a readout of several hundred exported symbols. Here's a sample of those (which are the few that I am trying to link against):

000000000000f860 g DF .text 0000000000000365 Base cblas_dgemm
000000000001cb20 g DF .text 000000000000033a Base cblas_zgemm

This suggests to me that the libraries are exporting symbols correctly, but that nm is not able to read them for some reason. Please correct me if this interpretation is incorrect.

Likewise, when I try to link against this library with gcc and ld, the linking happens with no errors, but I get this error at runtime:

"symbol lookup error: dynext/linalg_group.so: undefined symbol: cblas_dgemm"

ldd on my library doesn't even show that libblas.so is being linked, probably because ld couldn't find any symbols:

linux-vdso.so.1 => (0x00007fff551ff000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdb1e43a000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdb1ea2c000)

Notice that this same exact build and test sequence, with the same packages, does work perfectly on Ubuntu 11.10 and earlier (tests as far back as 10.04 seem to work in my VM).

Please let me know if I need to include any additional information.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: binutils 2.22-6ubuntu1
ProcVersionSignature: Ubuntu 3.2.0-24.37-generic 3.2.14
Uname: Linux 3.2.0-24-generic x86_64
ApportVersion: 2.0.1-0ubuntu6
Architecture: amd64
Date: Thu May 3 09:35:38 2012
InstallationMedia: Ubuntu 10.10 "Maverick Meerkat" - Release amd64 (20101007)
SourcePackage: binutils
UpgradeStatus: Upgraded to precise on 2012-04-27 (5 days ago)

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

please provide your example

Changed in binutils (Ubuntu):
status: New → Incomplete
Revision history for this message
Jaguar (bmarsh-r) wrote :

I've just has a similar problem. I could compile correctly on lucid, but the same command-line would not compile on precise.
After posting to Stack Overflow, the issue was that I had the -l options before the object files.

Changing the command-line from:
g++ -o installertest \
 -lsybdb \
 -lxmlrpc \
 -lxmlrpc_cpp \
 -lxmlrpc_xmlparse \
 -lxmlrpc_xmltok \
 -lxmlrpc_util \
 -lxmlrpc++ \
 -lxmlrpc_server_cgi \
 -lcrypto \
 -std=c++0x \
 ContractData.o installertest.o

to:
g++ -o installertest \
 ContractData.o installertest.o \
 -lsybdb \
 -lxmlrpc \
 -lxmlrpc_cpp \
 -lxmlrpc_xmlparse \
 -lxmlrpc_xmltok \
 -lxmlrpc_util \
 -lxmlrpc++ \
 -lxmlrpc_server_cgi \
 -lcrypto \
 -std=c++0x

Worked around the problem.

Apparently, this is some kind of implementation change between versions. Not sure if this is an Ubuntu-specific issue, or a general gcc issue.

Revision history for this message
Jaguar (bmarsh-r) wrote :

Side note: try "nm -D" to show the dynamic symbols.

Revision history for this message
Jaguar (bmarsh-r) wrote :

Here's the actual process.

It seems that gcc now send the linker flag --as-needed to ld.
This has the effect of discarding any specified libraries that do not have symbols that are required for linking.
In the first instance, all the libraries were being discarded be cause there were no unresolved symbols then in the linking phase, the symbols could not be found.
In the second instance, ld had collected the list of unresolved symbols and then found them in the specified libraries and therefore kept them when it came to the actual linking phase.

Upon reading the gcc manpage, this is not Ubuntu related.

Revision history for this message
Jaguar (bmarsh-r) wrote :

Changed status to Invalid as it has been found to be a nuance of gcc, not a bug in Ubuntu.

Changed in binutils (Ubuntu):
status: Incomplete → Invalid
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.