linux ld 链接.o文件,Linux:控制`ld`搜索.o目标文件的位置?

好吧,情况就是这样:我正在尝试使用一些较旧的软件:在Ubuntu Lucid上工作正常,在Natty上失败.

所以,我徘徊了一下,事实证明这个软件调用ld,并且ld最终失败了:

.../ld: crt1.o: No such file: No such file or directory

…是的,旧的crti.o file missing错误:)但是,我想用更一般的术语提问…

问题是,这是’独立'(较旧)ld在这里,当我跑… / ld -verbose |少,我得到:

...

SEARCH_DIR("/usr/local/lib");

SEARCH_DIR("/lib");

SEARCH_DIR("/usr/lib");

...

现在,问题在于:

>在Lucid上,crt1.o位于/usr/lib/crt1.o中

>在Natty上,crt1.o位于/usr/lib/i386-linux-gnu/crt1.o

…所以毫不奇怪为什么crt1.o无法找到,我想.看来,我所要做的就是告诉ld在/usr/lib / i386-linux-gnu中寻找crt1.o,但我该怎么做?

我以为我可以使用-L选项,但是男人ld说:

to link a file "hello.o":

ld -o /lib/crt0.o hello.o -lc

This tells ld to produce a file called output as the result of linking

the file "/lib/crt0.o" with "hello.o" and the library "libc.a", which

will come from the standard search directories.

...

-L searchdir

--library-path=searchdir

Add path searchdir to the list of paths that ld will search for

archive libraries and ld control scripts.

…意思是,’-L’会影响我们寻找“libc.a”的位置(在人的例子中) – 但不会影响目标文件.

我实际上更喜欢这个环境变量,但是我尝试了LD_PRELOAD_PATH和LD_LIBRARY_PATH都没有用(我猜,那些与“共享对象”有关,而这些.o文件不是其中之一).

有没有人知道是否有一个环境变量(最好是 – 或者如果没有,ld的命令行选项)可以控制ld搜索.o目标文件的位置?

作为一个注释,我想我可以在/usr/lib /中使用symlink /usr/lib/i386-linux-gnu/crt1.o,但我宁愿使用环境变量,如果它存在…如果没有,有没有其他可能的解决方案?

提前感谢您的任何答案,

干杯!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值