Get Rid of "Gcc - /Usr/Bin/Ld: Warning Lib Not Found"

Get rid of gcc - /usr/bin/ld: warning lib not found

You need to add the dynamic library equivalent of -L:

-Wl,-rpath-link,/path/to/lib

This will cause the linker to look for shared libraries in non-standard places, but only for the purpose of verifying the link is correct.

If you want the program to find the library at that location at run-time, then there's a similar option to do that:

-Wl,-rpath,/path/to/lib

But, if your program runs fine without this then you don't need it.

Gcc/ld warning liba needed by libb , not found, yet part of rpath

Older versions of ld from binutils ignores $ORIGIN in RPATH:

  • $ORIGIN in shared library's rpath not used to find library dependencies at link time
  • DSO1 needed by DSO2 linked into executable not found without -rpath-link, even though DT_RPATH and -rpath would find it

This functionality was added to binutils 2.28.

usr/bin/ld: cannot find -l nameOfTheLibrary

If your library name is say libxyz.so and it is located on path say:

/home/user/myDir

then to link it to your program:

g++ -L/home/user/myDir -lxyz myprog.cpp -o myprog

how to get rid of this linking error?

It's likely eclipse is using a different working directory so your rpath-link has a different meaning:

-Wl,-rpath-link=../../production-Alginterface/Shared/libs
^^^^^^

Try using an absolute path instead.


Why do you need to do this if you already specified -L on gcc's command line? From ld(1) I am guessing a separate path is searched for shared libraries required by other shared libraries of yours.

In this case you require libaprutil-1.so because you link with -laprutil-1. It is libaprutil that wants libexpat.so.0 and rpath-link is the path searched by ld.

linux library problem

Try adding:

-L/usr/java/lib

To your linker command, since that's the library your linker is not being able to find: I_GetCreatedJavaVMs@SUNWprivate_1.1.

A little piece of advice: it's not a good idea to mess with LD_LIBRARY_PATH. Just fix your linker command.

XCode Compiler Error: ld: library not found for -loauth

Continuing to What Robin suggested You also need to set the Library Search Path. Right Click the Target File and Choose -- Get Info else you can also get the same by choosing Edit Actice Target Under the Project Tab in XCode. Look for Library Search Path and add this "$(SRCROOT)/Twitter+OAuth/SAOAuthTwitterEngine" Where Twitter+OAuth/SAOAuthTwitterEngine is the directory path for Twitter Library in project folder.
I hope this will fix the problem.


Sample Image

gcc dialog library not linking

(Answer for the wiki sake, in case someone comes by here later)

You have to put the libraries you want to link at the end of the gcc command, like this:

gcc dialog_test.c -ldialog -lncurses

The reason is explained here: The way the linker looks up symbols it has to first see the reference, and then the library prodiving the symbol

Additionally, the dialog library might have other dependencies than ncurses. There is explanation how to find out what to include and what to link here, in short: dialog-config should tell you about it.
In this specific case, what worked for me (ubuntu 20.04) was linking ncursesw instead of ncurses.

After that, I was left with an

undefined reference to `sqrt'

linker error, which can be solved by linking the match library using -lm.

So, in total, this command works:

gcc dialog_test.c -ldialog -lncursesw -lm


Related Topics



Leave a reply



Submit