如何使用相对 rpath 编译 OpenSSL [英] How to compile OpenSSL with relative rpath
问题描述
我一直在尝试使用以下 rpath 编译 openssl 1.0.0g:
I have been trying to compile openssl 1.0.0g with the following rpath:
$ORIGIN/../lib64
每次我 readelf -d apps/openssl
,我都会得到如下结果,具体取决于我尝试的转义变化:
Everytime I readelf -d apps/openssl
, I am getting results like the following depending on what escaping variation I tried:
RIGIN/../lib64
RIGIN/../lib64
ORIGIN/../lib64
我想在不使用像 chrpath 这样的外部工具的情况下设置我的 rpath.有可能吗?我基本上会接受任何不涉及使用像 chrpath 这样的外部工具的东西(尽管我已经完成了).
I want to setup my rpath without using external tools like chrpath. Is it at all possible? I will basically accept anything that does not involve using external tools like chrpath (though I would already be done with that).
理想情况下,我想通过在命令行上传递选项来实现(任何形式的 -Wl,-rpath,$ORIGIN/../lib64
).
Ideally, I would like to do it by passing options on the command line (any form of -Wl,-rpath,$ORIGIN/../lib64
).
我不介意编辑生成的 Makefile,这是我上次尝试的.如果我能让它打印一个愚蠢的美元符号就好了!!!我尝试在 BUILDENV= 块下修改 LIBRPATH,但没有成功.我目前最好的成绩:
I don't mind editing the generated Makefile, which is what I have been trying last. If only I could get it to print a stupid dollar sign!!! I tried modifying LIBRPATH under the BUILDENV= block with no luck. My best results so far:
LIBRPATH=$$'ORIGIN/../lib64 # result: /../lib64
LIBRPATH=$$$$'ORIGIN/../lib64 # result: 12345<pid>/../lib64
我已经阅读了各种与 rpath 相关的问题并尝试了各种转义和引用技巧,但到目前为止没有任何效果!
I have read various rpath related questions and tried various escaping and quoting tricks but nothing worked so far!
推荐答案
在你的 makefile 中尝试:
In your makefile try:
-Wl,-rpath,${ORIGIN}/../lib64
我假设 ORIGIN 是一个 shell 变量.
I am assuming that the ORIGIN is a shell variable.
编辑
我刚刚找到了您问题的答案(迟到总比没有好):您需要防止 make 插入变量,为此您需要使用 $$(双美元符号):
I have just found an answer to your question (better late then never): You need to prevent make from interpolating variables, to do that you need to use $$ (double dolar sign):
-Wl,-rpath,'$$ORIGIN/../lib64'
我知道它有效,因为我已经用我自己的应用程序测试过它,享受:)
I know that it works because I have tested it with my own application, enjoy :)
这篇关于如何使用相对 rpath 编译 OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!