开发者

why does gcc linker choose older version of shared lib?

I'm puzzled. I have 2 versions of libssl.so in /lib: /lib/libssl.so.4 and /lib/libssl.so.6

Here is a stripped down minimal example -- I'm linking "nothing" with libssl -- the result being that it links to libssl.so.4. What determines this?

 $ g++ -o foo.so -shared -lssl

 $ ldd foo.so |grep ssl
 libssl.so.4 => /lib/开发者_StackOverflowlibssl.so.4 (0xf7f04000)


The option -lssl instructs the linker to look for the file named libssl.so or libssl.a. If all you have are libssl.so.4 and libssl.so.6, then you would have a linker error.

Look for a symlink called "libssl.so" somewhere in your library directories, likely in /lib.


Option -lssl looks for linker library name, in that case it is libssl.so. Typically libssl.so would be a symlink pointing to soname library or real name library whith which actual linking is done. You should repoint libssl.so symlink to correct version of using lib.

More about shared labrary naming you can read here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜