【问题标题】:Gcc not linking after operating system distribution upgrade操作系统发行版升级后 Gcc 未链接
【发布时间】:2011-10-19 07:53:44
【问题描述】:

现在我无法在 ubuntu 11.10 中将我正在处理的项目与 gcc4.6 链接起来。在发行版升级之前,一切链接都很好,它仍然可以在其他开发人员机器上编译/链接。如果它是相关的,我不会尝试交叉编译。

目前编译成功,然后链接失败,如下所示:

/usr/bin/ld: error: cannot open crt1.o: No such file or directory
/usr/bin/ld: error: cannot open crti.o: No such file or directory
/usr/bin/ld: error: cannot open crtn.o: No such file or directory
collect2: ld returned 1 exit status
make: *** [mc] Error 1

这里有一些关于我正在使用的信息:

$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) 

$ ldd --version
ldd (Ubuntu EGLIBC 2.13-20ubuntu5) 2.13
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

$ find /usr -name "crt1.o"
/usr/arm-linux-gnueabi/lib/crt1.o
/usr/lib32/crt1.o
/usr/lib/x86_64-linux-gnu/crt1.o
/usr/lib/debug/usr/lib32/crt1.o
/usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o
/usr/arm-linux-gnueabihf/lib/crt1.o

有没有办法将 ld 指向 crt1.o 文件的方向?

很高兴根据需要发布任何其他信息!

【问题讨论】:

标签: gcc ubuntu ld


【解决方案1】:

我很久以前就解决了这个问题,但希望发布这个可以帮助别人。 所有必需的 .o 文件都已安装,但我安装的 gcc 4.6 的 ppa 版本在错误的位置寻找它们。重新安装来自官方 repo 的所有包解决了这个问题。

然后确保您可以访问正确的存储库:

sudo apt-get update
sudo apt-get install --reinstall binutils
sudo apt-get install --reinstall build-essential
sudo apt-get install --reinstall libc6-dev
sudo apt-get install --reinstall gcc-4.6

【讨论】:

    猜你喜欢
    • 2021-12-07
    • 2012-02-05
    • 2012-07-30
    • 2020-08-27
    • 1970-01-01
    • 2010-10-27
    • 2015-02-03
    • 2015-01-14
    • 1970-01-01
    相关资源
    最近更新 更多