K-Jtan
K-Jtan

Reputation: 64

Specify path for shared library on Linux in a C++

I successfully compile my first Shared Library with the ld commannd. It is located in the following path.

/home/user/code/lib/libMy-lib.so

Although when I try to use it in a project I get the following error

/usr/bin/ld: cannot find -lMy-lib

This it my compile line

g++ SuperProject.cpp -o SuperProject -L/home/user/code/lib -lMy-lib -I/home/user/code/includes

I've been following these two tutorial and can't find what I'm doing wrong.

Upvotes: 0

Views: 369

Answers (1)

ferec
ferec

Reputation: 41

Set the path:

LD_LIBRARY_PATH=/home/user/code/lib

Upvotes: 1

Related Questions