[英]Linking a special shared library
I need to link a shared library (LuaSocket) I'm compiling against another special shared library, liblua5.1
, that isn't in one of the normal locations. 我需要链接一个共享库(LuaSocket),我正在编译另一个特殊的共享库liblua5.1
,它不在一个普通的位置。 To do this I'm modifying the Makefile. 为此,我正在修改Makefile。
I cannot figure out what I'm doing wrong, but this particular step that I modified fails: 我无法弄清楚我做错了什么,但是我修改过的这个特殊步骤失败了:
LIBRARY_PATH=/media/sda2/crank/lib gcc -O -shared -fpic -l liblua5.1 -o socket.so.2.0.2 [...]
(where [...]
is a list of .o
files that just got built). (其中[...]
是刚建成的.o
文件列表)。 When I build, I get the error 当我构建时,我得到了错误
/usr/lib/gcc/arm-poky-linux-gnueabi/4.8.1/../../../../arm-poky-linux-gnueabi/bin/ld: cannot find -lliblua5.1
collect2: error: ld returned 1 exit status
make: *** [socket.so.2.0.2] Error 1
Inspection of the LIBRARY_PATH
confirms that the needed library is there: 检查LIBRARY_PATH
确认所需的库在那里:
# ls /media/sda2/crank/lib/
lgre.so libgre.so libgreio.a liblua.so liblua5.1.so libsbexternal.so
What am I doing wrong? 我究竟做错了什么?
Change -l liblua5.1
to -llua5.1
. 将-l liblua5.1
更改为-llua5.1
。
Also, instead of setting LIBRARY_PATH
, why not use the -L
option? 另外,为什么不使用-L
选项而不是设置LIBRARY_PATH
? Example: -L/media/sda2/crank/lib
. 示例: -L/media/sda2/crank/lib
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.