/usr/bin/ld in Linux: Can't find -lxxx What should I do?

  
                

When compiling in the Linux environment, sometimes "ld/;/usr/bin/ld:cannot find -lxxx” error prompt, what does this prompt mean? How to deal with it? The following small series teaches you how to deal with this situation.

often following error message appears in the source code linux environment to compile the application or lib:

code is as follows:

/usr /bin /ld : cannot find -lxxx

These messages will have different results when compiling different types of source code. For example:

The code is as follows:

/usr/bin/Ld: cannot find -lc

/usr/bin/ld: cannot find -lltdl

/usr/bin/ld: cannot find -lXtst

where xxx means The name of the library file, as in the above example: libc.so, libltdl.so, libXtst.so.

The naming convention is: lib+ library name (ie xxx) +.so.

There are three reasons for this:

1 The system does not have the corresponding lib

2 The corresponding lib version is incorrect

3 lib (.so file) symbolic link is incorrect, not linked to the correct library file (.so)

Solution:

(1) first judged in /usr/Is the corresponding symbolic file (.so)'s symbolic link under lib correct?

If you incorrectly change to the correct link target, you can solve the problem.

(2) If it is not caused by the problem of symbolic link, but the system lacks the corresponding lib installation lib can be solved.

(3) How to install the missing lib:

Take the above three error messages as an example:

The code is as follows:

Error 1 is missing libc LIB

Error 2 missing libltdl's LIB

Error 3 missing libXtst's LIB

Take Ubuntu as an example:

Search for the corresponding LIB first The installed jobs are as follows:

The code is as follows:

apt-cache search libc-dev

apt-cache search libltdl-dev

apt-cache search libXtst-dev

Instance:

The following error message appears during the compilation of the source code gcin's Source Code:

The code is as follows:

/Usr/bin/ld: cannot find -lXtst

After checking, it is found:

The symbolic link of lib (.so file) is incorrect

The solution is as follows: Br>

The code is as follows:

cd /usr/lib

ln -s libXtst.so.6 libXtst.so

If in /usr/lib directory If the libXtst.so file is not found, then it means No library libXtst installation.

The solution is as follows:

The code is as follows:

apt-get install libxtst-dev

The above is /usr/bin/ld under Linux: The method of find -lxxx error is introduced. If you have this situation when compiling, you can try the above method to solve it.

Copyright © Windows knowledge All Rights Reserved