/usr/bin/ld: i386 architecture of input file `ReadWrite_c.o' is incompatible with i386:x86-64 output collect2: error: ld returned 1 exit status能不能改成64的
时间: 2023-07-11 12:44:37 浏览: 48
这个错误是由于编译时使用了 32 位的选项,而当前系统是 64 位的,所以链接器无法将 32 位的目标文件与 64 位的库文件进行链接导致的。
要解决这个错误,首先需要确定你的系统架构是否为 64 位。可以执行以下命令检查:
```
uname -m
```
如果输出结果是 `x86_64`,则表示你的系统是 64 位的。
接下来,你需要重新编译代码,并使用 64 位的选项进行编译链接。例如,如果你使用 GCC 编译器,可以使用以下命令:
```
gcc -m64 ReadWrite_c.c -o ReadWrite_c
```
这里的 `-m64` 选项表示使用 64 位的目标文件和库文件进行链接。执行以上命令后,应该可以成功编译和链接程序了。
相关问题
/usr/bin/ld: i386 architecture of input file `ReadWrite_c.o' is incompatible with i386:x86-64 output collect2: error: ld returned 1 exit status
这个错误是由于编译时使用了 32 位的选项,而当前系统是 64 位的,所以链接器无法将 32 位的目标文件与 64 位的库文件进行链接导致的。
要解决这个错误,你需要使用 `-m32` 选项来将代码编译为 32 位的目标文件,然后再进行链接。例如,如果你使用 GCC 编译器,可以使用以下命令:
```
gcc -m32 ReadWrite_c.c -o ReadWrite_c
```
这里的 `-m32` 选项表示使用 32 位的目标文件和库文件进行链接。执行以上命令后,应该可以成功编译和链接程序了。
gcc -o test main.c ReadWrite_c.o /usr/bin/ld: i386 architecture of input file `ReadWrite_c.o' is incompatible with i386:x86-64 output collect2: error: ld returned 1 exit status
这个错误表示您的代码中有一些文件编译为位(i386),而您的编译器却尝试将其与64位(x86-64)的文件链接。这通常是因为您的编译器使用了错误的选项或库,或者您的代码包含一些不兼容的指令。
为了解决这个问题,您需要使用 `-m32` 选项来编译和链接您的代码,以确保它们都是32位的。例如,您可以使用以下命令来编译和链接您的代码:
```
gcc -m32 -o test main.c ReadWrite_c.o
```
这将使用 `-m32` 选项来编译和链接您的代码,以确保它们都是32位的。这应该可以解决您遇到的链接错误。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)