Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Usr/bin/ld: cannot find -l<nameOfTheLibrary>

I'm attempting to compile my program and it returns this mistake :

usr/bin/ld: cannot find -l<nameOfTheLibrary>


in my makefile, I utilize the command g++ and link to my library which is an emblematic link to my library situated on another directory.

Is there a choice to add to make it work, please?
by

3 Answers

ninja01
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
kshitijrana14
When you compile your program you must supply the path to the library; in g++ use the -L option:
g++ myprogram.cc -o myprogram -lmylib -L/path/foo/bar
sandhya6gczb
On Debianish platforms, if libfoo is missing, you can frequently install it with something like

apt-get install libfoo-dev

The -dev version of the package is required for development work, even trivial development work such as compiling source code to link to the library.

Login / Signup to Answer the Question.