gpt4 book ai didi

macos - 每次升级 Xcode 时,我都会收到 brew installed GCC 的链接器错误

转载 作者:行者123 更新时间:2023-12-03 17:51:37 27 4
gpt4 key购买 nike

因此,我升级到 Mavericks 以及最新版本的 Xcode (5.02),并且——正如预期的那样,无法编译任何包含 C 扩展的新 Ruby gem。这特别发生在我自己的项目 NMatrix 中,其中包括 C 和 C++ 代码。

我重新安装了 Xcode 的命令行工具。然后我升级了 Homebrew 软件。然后我卸载了 rbenv、ruby-build 和我的自定义 GCC 版本(4.7 除外,它是手动安装的,而不是通过 brew 安装的)。

接下来,我使用 brew 来安装 gcc48(和 gcc49 以更好地衡量)。我指示我的 gem 使用 GCC-4.8.2 而不是 GCC 4.9 的开发快照构建。

好消息是我的 gem 现在可以正确编译了。坏消息是它不会链接。这里只是链接步骤:

$ bundle exec rake compile
cd tmp/x86_64-darwin13.0.0/nmatrix/2.0.0
make
linking shared-object nmatrix.bundle
ld: warning: directory not found for option '-L/usr/lib64/atlas'
0 0x10ef3f724 __assert_rtn + 144
1 0x10ef7425e archive::File<x86_64>::makeObjectFileForMember(archive::File<x86_64>::Entry const*) const + 1118
2 0x10ef73c3b archive::File<x86_64>::justInTimeforEachAtom(char const*, ld::File::AtomHandler&) const + 139
3 0x10ef883fe ld::tool::InputFiles::searchLibraries(char const*, bool, bool, bool, ld::File::AtomHandler&) const + 210
4 0x10ef8f181 ld::tool::Resolver::resolveUndefines() + 189
5 0x10ef911a5 ld::tool::Resolver::resolve() + 79
6 0x10ef3fb17 main + 669
A linker snapshot was created at:
/tmp/nmatrix.bundle-2013-10-15-085036.ld-snapshot
ld: Assertion failed: (memberIndex != 0), function makeObjectFileForMember, file /SourceCache/ld64/ld64-224.1/src/ld/parsers/archive_file.cpp, line 355.
collect2: error: ld returned 1 exit status
make: *** [nmatrix.bundle] Error 1
rake aborted!
Command failed with status (2): [make...]

这很奇怪,有几个原因。
  • 这是一个零星的错误。我们已经看过几次了,它似乎总是因为不明原因而消失。
  • 我不认为 ld: warning line 是相关的,但它可能是相关的。 ATLAS 由 Xcode 的 Accelerate 框架提供,在当前版本的 Xcode 中,它似乎不再位于 /usr/lib64/atlas (或者也许从来没有)。该路径只是可能的安装位置之一,并且正确包含正确的路径 (/usr/local/atlas)。
  • 当我搜索上面给出的函数原型(prototype)时,我看到了很多 LLVM 的东西。这都是 Mac OS X 的错误。所以这是特定于 Mac 的。但是,当我提供 GCC 时,为什么它会使用 LLVM?是否使用正确版本的 GCC 进行编译但试图链接错误的版本?

  • 最后一个可能是最好的假设。似乎此错误仅出现在您无法覆盖默认 GCC 安装(即 Mac)的计算机上。

    我无法安装新的 ATLAS,因为没有已知的方法可以关闭 MacBook Air 上的节流——这是安装 ATLAS 的先决条件,所以我无法消除 ld警告。

    有人对这些错误可能意味着什么有任何想法吗?编译器/链接器专家?任何人?

    更新
    我突然想到查看 mkmf.log ,我发现了一些额外的信息。果然,这是一个 ATLAS 问题。但我不太确定为什么它只在一个目录中查找。
    ld: warning: directory not found for option '-L/usr/lib64/atlas'
    Undefined symbols for architecture x86_64:
    "_ATL_dgemm", referenced from:
    _cblas_dgemm in libcblas.a(cblas_dgemm.o)
    "_ATL_dsyreflect", referenced from:
    _cblas_dgemm in libcblas.a(cblas_dgemm.o)
    "_ATL_dsyrk", referenced from:
    _cblas_dgemm in libcblas.a(cblas_dgemm.o)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: #include <cblas.h>
    4:
    5: /*top*/
    6: extern int t(void);
    7: int t(void) { void ((*volatile p)()); p = (void ((*)()))cblas_dgemm; return 0; }
    8: int main(int argc, char **argv)
    9: {
    10: if (argc > 1000000) {
    11: printf("%p", &t);
    12: }
    13:
    14: return 0;
    15: }
    /* end */

    "gcc -o conftest -I/Users/jwoods/.rbenv/versions/2.0.0-p247/include/ruby-2.0.0/x86_64-darwin13.0.0 -I/Users/jwoods/.rbenv/versions/2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/jwoods/.rbenv/versions/2.0.0-p247/include/ruby-2.0.0 -I../../../../ext/nmatrix -I/usr/local/atlas/include -I/usr/include/atlas -Wall -Werror=return-type -I/Users/jwoods/.rbenv/versions/2.0.0-p247/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -Wall -Werror=return-type -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/jwoods/.rbenv/versions/2.0.0-p247/lib -L/usr/local/atlas/lib -L/usr/local/lib -L/usr/lib -L/usr/lib64/atlas -L. -L/Users/jwoods/.rbenv/versions/2.0.0-p247/lib -L/usr/local/lib -lcblas -llapack -lruby-static -lcblas -llapack -lpthread -ldl -lobjc "
    conftest.c:7:27: error: too few arguments to function call, expected 14, have 0
    int t(void) { cblas_dgemm(); return 0; }
    ~~~~~~~~~~~ ^
    /usr/local/atlas/include/cblas.h:470:1: note: 'cblas_dgemm' declared here
    void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
    ^
    1 error generated.
    checked program was:
    /* begin */
    1: #include "ruby.h"
    2:
    3: #include <cblas.h>
    4:
    5: /*top*/
    6: extern int t(void);
    7: int t(void) { cblas_dgemm(); return 0; }
    8: int main(int argc, char **argv)
    9: {
    10: if (argc > 1000000) {
    11: printf("%p", &t);
    12: }
    13:
    14: return 0;
    15: }
    /* end */

    最佳答案

    我相信我找到了答案。 extconf.rb 中的 lib 搜索目录之一(生成 Makefile)是 /usr/lib64/ ,系统上不存在。因此,一旦我从搜索路径中删除它,它就会正确编译和链接。

    我还在 $libs 中添加了一个条目定义可能有用也可能没用。

    它从 $libs += " -llapack -lcblas -latlas "到:

    $libs += " -llapack -lclapack -lcblas -latlas "

    但是最后一点解决了链接后的问题,而不是期间。

    关于macos - 每次升级 Xcode 时,我都会收到 brew installed GCC 的链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20004120/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com