【问题标题】:Unable to compile C++ programs on CentOS无法在 CentOS 上编译 C++ 程序
【发布时间】:2015-04-14 03:11:35
【问题描述】:

我在 ./configure 期间收到以下错误。

configure:3429: checking whether the C compiler works
configure:3451: gcc -m32 -D_FILE_OFFSET_BITS=64  -m32 conftest.c  >&5
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
configure:3455: $? = 1
configure:3493: result: no

configure:3498: error: in `/root/cjk/1.x/src/externals/mecab':
configure:3500: error: C compiler cannot create executables

我尝试了互联网上提到的几种解决方案,但无济于事。 我已经在机器上安装了完整的开发者包。 我也安装了 glibc-devel.i686 包。

【问题讨论】:

  • 显然,您正在尝试(交叉)在 64 位系统上编译 32 位程序/lib。这是可能的,但您需要安装 32 位库。阅读您的文档,了解如何在您的平台上执行此操作。

标签: c linux unix centos rhel


【解决方案1】:

我遇到了完全相同的问题(CentOS 6.5 x64,gcc 4.4.7)。我确保执行了yum install glibc-devel.i686。一个快速的find / -name "libgcc_s.*" 透露:

/lib64/libgcc_s.so.1
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libgcc_s.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libgcc_s.so

所以,也许您可​​以尝试here 建议的解决方法:

  1. 在链接行添加gcc_s库的绝对路径,或者
  2. (推荐)如果库的文件名附加了任何主要和次要版本号,只需在同一位置创建指向库的软链接,目标文件名中不包含主要和次要版本号。

我通过将-static 添加到我的gcc 调用来静态编译/链接我的应用程序。所以,

gcc -static -m32 ...

在这种情况下,请确保 yum install glibc-static.i686 已完成。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多