将.o文件路径添加到ld default(crtbeginS.o,而不是.so文件)

时间:2015-05-21 22:58:38

标签: gcc g++ ld binutils

当使用GCC编译大部分内容时,我收到此错误:

/..//bin/ld: cannot find crtbeginS.o: No such file or directory

crtbeginS.o存在于/usr/local/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/crtbeginS.o(从GCC主干安装,6.0.0-trunk)

我将该目录添加到ldconfig并运行ldconfig,但它没有获取任何其他目录。 (我在想,因为它是.o而不是.so)

作为临时修复,我尝试为/usr/local/lib64/crtbeginS.o制作一个符号链接 - 但这会产生同样的错误。

我该怎么办,所以总是会查看/usr/local/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/目录以查找库?

如果我运行gcc -print-search-dirs|grep "/usr/local/lib/gcc/x86_64-unknown-linux-gnu/6.0.0",它会显示库:= / usr / local / lib / gcc / x86_64-unknown-linux-gnu / 6.0.0 /:...但是,这当然是gcc not LD

如果我运行ld --verbose | grep SEARCH_DIR,我会看到/usr/local/lib/gcc_x86_64-unknown-linux-gnu/6.0.0未包含在内。

我真的很想将此作为系统范围的默认设置,因此我不必为所有内容提供-L。如果有必要的话,我很好地从源头构建bintools。

1 个答案:

答案 0 :(得分:-1)

我该怎么办,所以 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/目录始终是 看着找到图书馆?

您必须更改 ld配置

根据您的系统,可以使用/ etc /中的文件(也可以使用'/etc/ld.so.conf.d或/etc/ld.so.d)下的文件来配置ld.so。 ld.soldconfig的手册页是开始阅读如何更改 ld 的配置的好地方。