rpath = $ ORIGIN没有期望的效果? [英] rpath=$ORIGIN not having desired effect?

查看:1566
本文介绍了rpath = $ ORIGIN没有期望的效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个二进制CeeloPartyServer,需要在运行时在FreeBSD机器上找到libFoundation.so。他们都在同一个目录中。我使用链接器标志-rpath = $ ORIGIN编译(在另一个平台上,使用交叉编译器)CeeloPartyServer。

 
> readelf -d CeeloPartyServer | grep -i rpath
0x0000000f(RPATH)库rpath:[$ ORIGIN]
> ls
CeeloPartyServer内容Foundation.framework libFoundation.so
./CeeloPartyServer
/libexec/ld-elf.so.1:未找到共享库libFoundation.so,需要CeeloPartyServer

为什么当我尝试运行它时找不到库?我的确切链接行是:-lm -lmysql -rpath = $ ORIGIN。我敢肯定,我不必逃避\ $或类似的东西,因为我的readelf分析确实显示库rpath被设置为$ ORIGIN。我错过了什么?

解决方案

我假定您使用的是gcc和binutils。



如果你这样做的话

  readelf -d CeeloPartyServer | grep ORIGIN 

你应该找回上面找到的RPATH行,但你也应该看到一些关于标志。

  0x000000000000000f(RPATH)库rpath:[$ ORIGIN /../ lib] 
0x000000000000001e(FLAGS)ORIGIN
0x000000006ffffffb(FLAGS_1)标志:ORIGIN

如果您没有看到某种FLAGS条目,您可能没有告诉链接器将该对象标记为需要源处理。有了binutils ld,你可以通过传递 -z origin 标志来实现。

gcc来驱动链接,所以在这种情况下,你需要通过编译器加入 -Wl,-z,origin 到你的gcc链接行来传递标志。


I've got a binary "CeeloPartyServer" that needs to find libFoundation.so at runtime, on a FreeBSD machine. They're both in the same directory. I compile (on another platform, using a cross compiler) CeeloPartyServer using linker flag "-rpath=$ORIGIN".

> readelf -d CeeloPartyServer |grep -i rpath
 0x0000000f (RPATH)                      Library rpath: [$ORIGIN]
> ls
CeeloPartyServer    Contents        Foundation.framework    libFoundation.so
> ./CeeloPartyServer 
/libexec/ld-elf.so.1: Shared object "libFoundation.so" not found, required by "CeeloPartyServer"

Why isn't it finding the library when I try to run it? My exact linker line is: -lm -lmysql -rpath=$ORIGIN. I am pretty sure I don't have to escape \$ or anything like that since my readelf analysis does in fact show that library rpath is set to $ORIGIN. What am I missing?

解决方案

I'm assuming you are using gcc and binutils.

If you do

readelf -d CeeloPartyServer | grep ORIGIN

You should get back the RPATH line you found above, but you should also see some entries about flags. The following is from a library that I built.

0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/../lib]
0x000000000000001e (FLAGS)              ORIGIN
0x000000006ffffffb (FLAGS_1)            Flags: ORIGIN

If you aren't seeing some sort of FLAGS entries, you probably haven't told the linker to mark the object as requiring origin processing. With binutils ld, you do this by passing the -z origin flag.

I'm guessing you are using gcc to drive the link though, so in that case you will need to pass flag through the compiler by adding -Wl,-z,origin to your gcc link line.

这篇关于rpath = $ ORIGIN没有期望的效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆