3

I create shared library libpl.so.

I use this command to create connections:

ln -s libpl.so.1.0.1 libpl.so.1
ln -s libpl.so.1.0.1 libpl.so

And now I try to compile my program using:

gcc main.c -o main -L. -libpl

but I have errors:

/usr/bin/ld: cannot find -libpl
collect2: error: ld returned 1 exit status

What should I do to fix it? How can I compile it?

2
  • Close, but still doesn't work ./main: error while loading shared libraries: liblp.so.1: cannot open shared object file: No such file or directory Commented Apr 24, 2016 at 14:33
  • if running fails during runtime do the following - export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH Commented Apr 24, 2016 at 16:59

2 Answers 2

3

This line should help:

export LD_LIBRARY_PATH=/path/to/libpl.so:$LD_LIBRARY_PATH

You should follow this tutorial on shared libraries on Linux. This tutorial may answer to all your questions.

Sign up to request clarification or add additional context in comments.

Comments

1

The line

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`pwd`"

works correctly.

Compile with:

gcc main.c -o main -L. -lpl

Run with:

./main

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.