如何编译与共享库的gcc? [英] How to compile gcc with shared library?
本文介绍了如何编译与共享库的gcc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建共享库 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 erros:
/usr/bin/ld: cannot find -libpl
collect2: error: ld returned 1 exit status
我该如何解决它?如何编译它?
What should I do to fix it ? How compile it ?
推荐答案
This line:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`pwd`"
正常工作。
编译:
Compiling with:
gcc main.c -o main -L. -lpl
运行:
Runing with:
./main
这篇关于如何编译与共享库的gcc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文