C 编译器无法在 OpenSUSE 上创建可执行文件

C compiler cannot create executables on OpenSUSE

我尝试从源代码编译 xdebug,但我变成了这个输出:

fobo66@linux-3z16:~/xdebug-2.3.3> ./configure
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... no
configure: error: in `/home/fobo66/xdebug-2.3.3':
configure: error: C compiler cannot create executables
See `config.log' for more details

There is my config.log.

我发现了可能的错误:

/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: i386 architecture of input file '/usr/lib/crt1.o' is incompatible with i386:x86-64 output /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: i386 architecture of input file '/usr/lib/crti.o' is incompatible with i386:x86-64 output /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: i386 architecture of input file '/usr/lib/crtn.o' is incompatible with i386:x86-64 output /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: dynamic STT_GNU_IFUNC symbol 'strcmp' with pointer equality in '/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie

那么,当我的编译器不工作时如何解决这个问题?

尝试用 gcc 编译一些简单的代码

#include <stdio.h>
int main () { printf("hello world\n"); return 0; }

使用命令

gcc -o simple simple.c

如果出现这样的错误"command not found",则gcc不在环境路径中。

还要确保 gcc 可以找到标准头文件(如 stdio.h 和 e.t.c)

/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: i386 architecture of input file '/usr/lib/crt1.o' is incompatible with i386:x86-64 output 链接器似乎正在获取所需 obj 文件的 32 位版本,而它需要 64 位版本。尝试将 LD_LIBRARY_PATH 环境变量设置为来自 /usr/lib64 的适当路径,然后重新编译。

已解决!

我刚刚用正确的架构重新安装了 glibc-devel

怎么做:

  1. 转到 YaST
  2. 选择"Software Management"工具
  3. 在搜索字段中键入 glibc
  4. 将包 glibcglibc-devel 标记为更新(单击复选框)
  5. 选择glibc套餐
  6. 单击底部的 "Versions" 选项卡
  7. 选择架构正确的版本,例如2.19-16.15.1-x86_64
  8. 选择glibc-devel包并为它做6和7
  9. 点击"Accept"
  10. 等待安装结束
  11. 关闭window

此编译后应该可以正常工作。

这是类似于 Windows 的方法,这就是它糟糕的原因:)

如果有人知道如何从终端执行此操作,请在此处写下答案。