crt1.o 在 linux x64 上没有这样的文件 c++ 编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10783429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 06:32:57  来源:igfitidea点击:

crt1.o no such file c++ compilation error on linux x64

c++linuxlinker

提问by fishfood

I'm making my first steps on the linux platform. I've installed Centos x64. I'm attempting to build a small program with a couple of functions and a couple of unit tests.

我正在 linux 平台上迈出第一步。我已经安装了 Centos x64。我正在尝试构建一个包含几个函数和几个单元测试的小程序。

I'm using Netbeans 7.1.2 as the development environment.

我使用 Netbeans 7.1.2 作为开发环境。

Here is the output from the build process:

这是构建过程的输出:

CLEAN SUCCESSFUL (total time: 671ms)

"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/john/Dev/GoatsCheese'
"/usr/bin/gmake"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/goatscheese
gmake[2]: Entering directory `/home/john/Dev/GoatsCheese'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -m32   -c -g -I/usr/include/cppunit -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -m32    -o dist/Debug/GNU-Linux-x86/goatscheese build/Debug/GNU-Linux-x86/main.o  
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status

The compiler is set to create a 32-bit executable, but I shouldn't think that would be a problem (32 bit executables can be created on an x64 platform on Windows - the platform I'm familiar with).

编译器设置为创建 32 位可执行文件,但我不应该认为这会成为问题(32 位可执行文件可以在 Windows 的 x64 平台上创建 - 我熟悉的平台)。

Locate finds the crt1.o file in the following places:

Locate 在以下位置找到 crt1.o 文件:

locate crt1.o
/usr/lib64/Mcrt1.o
/usr/lib64/Scrt1.o
/usr/lib64/crt1.o
/usr/lib64/gcrt1.o

I'm not sure if I'm missing a package or if I should create a symlink.

我不确定我是否缺少一个包或者我是否应该创建一个符号链接。

采纳答案by Some programmer dude

You need to install the 32-bit standard C library development package. It's probably named something like libc6-dev-i386.

您需要安装 32 位标准 C 库开发包。它的名字可能类似于libc6-dev-i386.

回答by Daniel Baktiar

The problem you can't find the crt1.o is probably because you are missing one of the library specifier options. I am not familiar with Netbeans, but you should add the /usr/lib64. Somewhere in the g++ command line it should look like: "-L /usr/lib64".

您找不到 crt1.o 的问题可能是因为您缺少库说明符选项之一。我不熟悉 Netbeans,但您应该添加 /usr/lib64。在 g++ 命令行的某个地方,它应该看起来像:“-L /usr/lib64”。

NB: It's a thinking flaw to assume that because it works on Windows that way, other platforms with same CPU will behave the same way. This doesn't sound right.

注意:假设因为它在 Windows 上以这种方式工作,具有相同 CPU 的其他平台将以相同的方式运行,这是一个思维缺陷。这听起来不对。

I would suggest you build in 32bit binaries with 32bit library, and build 64bit binaries linked to 64bit library.

我建议您使用 32 位库构建 32 位二进制文​​件,并构建链接到 64 位库的 64 位二进制文​​件。

回答by Sebastian Vettel

I think ld was looking for 32-bit crt1.o but you only have 64-bit version.

我认为 ld 正在寻找 32 位 crt1.o 但您只有 64 位版本。