Skip to content
Advertisement

How can I compile GCC with a shared library?

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?

Advertisement

Answer

The line

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`pwd`"

works correctly.

Compile with:

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

Run with:

./main
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement