views:

424

answers:

4

I'm trying to compile/link a very old piece of software on a linux system and I can't for some reason link with a shared library that's installed on my system.

I get the following error from the linker:

/usr/bin/ld: cannot find -lXaw

However, the lib itself is installed. If I run

ldconfig -v | grep libXaw

I get (among other things) this hit:

libXaw.so.7 -> libXaw7.so.7.0.0

The library and the links to it are in /usr/lib btw. So nothing special.

So the library is there and ldconfig finds it. What could ld cause ld from not finding the library during link-time? As you may have already guessed I'm quite new to the shared library stuff.

Any ideas?

+3  A: 

The linker may be looking, literally, for "libXaw.so". Is that in /usr/lib? If not, you could try adding it as another soft link from libXaw7.so.7.0.0.

ejgottl
Thanks, that link fixed it. Do you have any idea why it's nessesary at the first place? Other libs with similar naming schemes work without problems.
Nils Pipenbrinck
Usually the .so symlink is provided in the development package in most distributions (e.g., libxaw-dev). Could this be your case?
Chris Jester-Young
Can you give a concrete example? As in: I link fine with -lfoo, but there is no libfoo.so or libfoo.a on my system, only a libfoo.so.1.0.
ejgottl
A: 

To link it, you need the .a file, NOT the .so file, which is the runtime library. The shared object is only useful to a program already linked against the non-shared parts of a library. This is typically distributed in a ".a" file.

MarkR
Um, this may be true on Windows, but on Linux you typically link against the shared library itself.
JesperE
the confusion probably stems from the fact that `.lib` is used to denote both static and import libraries (the latter, as I understand, are link-time "proxies" for shared libraries).
just somebody
A: 

Are the -L library directories being overridden, and it's not looking in /usr/lib?

HUAGHAGUAH
+2  A: 

The reason for the symlink btw is to select the default version to link against in the case of multiple versions, keep in mind the name of the library is integrated into the binary. (which you can see with ldd).

Marco van de Voort