【问题标题】:Unable to run gcc on mac无法在 mac 上运行 gcc
【发布时间】:2018-03-29 04:19:22
【问题描述】:

我正在尝试在我的系统上编译简单的 C 代码。我在 macOS 10.11.6 上运行 gcc 版本 (4.9.2)。

ld: library not found for -lgcc
collect2: error: ld returned 1 exit status

我无法解决此问题。这个问题也不允许我安装任何 ./configure 软件包,因为它们需要 gcc 才能工作。

【问题讨论】:

    标签: macos gcc ld


    【解决方案1】:

    即使macOS下有一个叫gcc的程序,也不是真正的gcc编译器。它只是一个 Clang 编译器,你可以很容易地证明:

    gcc --version
    

    将打印:

    配置为:--prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM 版本 9.0.0 (clang-900.0.39.2)
    目标:x86_64-apple-darwin17.4.0
    线程模型:posix
    安装目录:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

    您应该能够通过在命令行中省略 -lgcc 标志来编译和链接您的程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-27
      • 2012-01-08
      • 2015-10-09
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多