English 中文(简体)
ld linkage problems: /usr/bin/ld: cannot find [libraryname]
原标题:

Im using Qmake to build a shared library on Ubuntu 9.10

This shared library (A) has a dependency on another shared library (B).

project B has been successfully built.

in the .pro file for project A, my LIBS variable looks like this:

LIBS += -L../datelib/bin -llibdatelib_release.so.1.0.0

(I used the full shlib name because the library versions are different.)

In any case, when I attempt to build project A, it breaks at the linkage stage, and prints the error message:

/usr/bin/ld: cannot find -llibdatelib_release.so.1.0.0
collect2: ld returned 1 exit status
make[1]: ***[bin/libprojecta_release.so.6.0.0] Error 1
make ***[release] Error 2
Exited with code 2

From the error message, I thought ld was complaining that it could not locate the libdatelib file, so I manually copied it to /usr/lib/

however, that did not solve the problem, and I am getting the same error message.

Anyone knows how to fix this?

[Edit]

I m quite new to building using gcc. I know how to create symbolic links, but which paths do I use for the lnk command?. The file I want to link to is in /home/username/work/cppdev/datelib/bin.

Also the build system I use (qmake), automatically creates symbolic links as part of the build, so I already have the following files in my /home/username/work/cppdev/datelib/bin folder:

  • libdatelib_release.so (sym link)
  • libdatelib_release.so.1 (sym link)
  • libdatelib_release.so.1.0 (sym link)
  • libdatelib_release.so.1.0.0 (shared lib)

I may have to ask another question to explain why there are so many symlinks (whats the point?), and why I cant just link directly to a shared lib, but have to go through a symbolic link. I ve read some online docs, but what I ve seen so far seems more like dictum/tradition rather than actual technical reasons WHY this level of abstraction is required when linking on Linux.

问题回答

You can t use -l that way. -l can only find things with names like libFOO.so, via -lFOO. You need a symbolic link without the version number if you want to specify it like this in the build.

Something like:

ln -s /the/path/to/the/libthing.so.1.0.0 /the/path/to/the/libthing.so

Now -lthing will work.

The prefix lib is automatically added to the library name - use:

LIBS += -L../datelib/bin -ldatelib_release.so.1.0.0

You may provide full path. i.e.

LIBS += ../datelib/bin/libdatelib_release.so.1.0.0

However I would recommend you to do what bmargulies suggested: create symolic link and add -ldatelib_release





相关问题
Add a changing icon to Ubuntu Panel

What would be the most simple way of adding and changing an icon in the Ubuntu (Gnome) Panel? I m looking for something as simple as shell scripting, but I m not restricted to that. Will write a ...

Configuring kernel

After create a new system call, how to update the kernel? I tried these lines, make-kpkg clean fakeroot make-kpkg -initrd -append-to-version=-custom kernel_image kernel_headers But Ubuntu asked me ...

save Exceptions to file in python

I want to save all following Exceptions in a file. The reason why I need this is because the IDLE for python 3.1.1 in Ubuntu raises an Exception at calltipps, but close to fast, that it isn t readble. ...

How can i monitor system statistics in kubuntu using Java?

i am doing a project related to configuration and memory analyzer for kubuntu. i want to display the system statistics information like CPU usage, RAM usage and proceses etc. graphically using an ...

How to pass "--external-locking" for mysqld in Ubuntu

I would like to start my mysql server with the --external-locking option. As mysqld is run by the /etc/init.d/mysql script ubuntu (karmic), I guess that s where I should set this "--external-locking" ...

"g++" and "c++" compiler

I just found on my Ubuntu, there are two different C++ compilers: /usr/bin/g++ and /usr/bin/c++. I am not familiar with the latter, but man c++ just jumps to the manpage of gcc. I wonder what is their ...

热门标签