【问题标题】:ld: symbol dyld_stub_binder not found (normally in libSystem.dylib)ld:未找到符号 dyld_stub_binder(通常在 libSystem.dylib 中)
【发布时间】:2019-06-13 14:42:54
【问题描述】:

Fortran 编译器不起作用,我认为这是一种 PATH 问题。

我使用的是 MacOS Mojave 10.14.5。我试图运行我从别人那里得到的 fortran 代码。它编译得很好,但是在运行它时出现错误。首先是分段错误,所以我不确定出了什么问题。但我 90% 确定代码没有错,因为它是由其他人运行的。但是编译和运行像 HelloWorld 这样的简单代码运行良好。

我发现我的 gfortran 使用的是 anaconda 版本(4.8.5?),所以我将其更改为 Homebrew 版本(9.1.0)编辑 bashrc 文件。之后(我不确定究竟是什么改变了问题。我尝试了很多可以在 Google 上找到的东西,比如重新安装 gcc。我可能搞砸了路径) 我的 fortran 编译器甚至无法编译 HelloWorld 代码。

PRINT *, "Hello World!"
END                

.

(base) dyn-137-229-27-249:~ jjung11$ gfortran hello.f90 -o hello
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd
ld: symbol dyld_stub_binder not found (normally in libSystem.dylib).  Needed to perform lazy binding to function __gfortran_set_args for architecture x86_64
collect2: error: ld returned 1 exit status

它说我需要做惰性绑定,但我不知道这是什么意思,即使我用谷歌搜索了它,我也无法学会如何做。

我在尝试运行自己的代码时多次看到的错误如下:

(base) dyn-137-229-27-249:~ jjung11$ /Volumes/easystore/code/mhdread_sc ; exit;
dyld: Library not loaded: /sasbuild/local/xmac01/GNU_CC_CXX_7.1/gcc_7.1.0/lib/libgfortran.4.dylib
  Referenced from: /Volumes/easystore/code/mhdread_sc
  Reason: image not found
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

我试图更改 dyld 路径但没有成功。事实上,我不太清楚它的含义。

我自己的代码目前得到的错误如下:

/Volumes/easystore/code/mhdread_sc -grid ../openggcm_run/2008Jun28_002/2008Jun28_002.grid -fin ../openggcm_run/2008Jun28_002/target/2008Jun28_002.3df. -diptime 2008:06:28:10:00:0.000 -fth 2008Jun28_002.TB_GSEorbit.mhd -fsc TB.GSE.orbit -t0 3600 -tt 43200 -dt 60
 test
 3600                                                                                                                                                                                                    
At line 55 of file mhdread_sc.f
Internal Error: get_unit(): Bad internal unit KIND

实际上,尽管我已经为这个问题苦苦挣扎了好几天,但我只是编程的初学者 (Brew/Xcode/PATH/bashrc/mac),所以请善待解决方案。难的话我可能看不懂。

编辑- 新错误

(base) dyn-137-229-27-249:~ jjung11$ which gfortran -a
/usr/local/bin/gfortran
(base) dyn-137-229-27-249:~ jjung11$ gfortran -o hello.f90 hello
ld: can't link with a main executable file 'hello' for architecture x86_64
collect2: error: ld returned 1 exit status

【问题讨论】:

  • 诊断请给which -a gfortran的结果
  • @PierredeBuyl (base) $ which -a gfortran /usr/local/bin/gfortran /Users/jjung11/anaconda3/bin/gfortran /usr/local/bin/gfortran
  • 有两个安装,如果你打算只使用 conda 版本,我建议你删除/usr/local/bin/gfortran。你是怎么安装的? (自编译、二进制安装程序等)?您的计算机是受管理的还是您是管理员?
  • @PierredeBuyl 我不是管理员,但我可以使用 sudo。当我为 Python3 安装 anaconda 时,会自动安装 anaconda。我使用 brew install gcc 安装 /usr/local/bin/gfortran (我认为。)一个问题是 anaconda 版本低(4.8.5),我不知道如何更新它。
  • 能否把~/.bashrc的anaconda设置去掉,重启终端,再试一次?您可能需要注销并再次登录(我不知道 mac os 在什么时候重新初始化 shell 环境)。

标签: macos fortran homebrew gfortran


【解决方案1】:

这看起来像是编译器和/或运行时库的版本冲突。

~/.bashrc 中删除 anaconda 设置。

然后,确保 Apple 提供的“开发者工具”是最新的,更新 homebrew,从 homebrew 更新 gcc/gfortran 安装。如果这不起作用,我想不出远程诊断和/或修复安装的方法。

【讨论】:

  • 有趣的是,您建议删除 anaconda 设置。我在编译 Golang 项目时遇到了类似的问题。原来问题是我改变了我的 conda 环境。当我回到基础 conda 环境时,一切都已修复。感谢您的解释,它帮助我解决了我的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-10-03
  • 1970-01-01
  • 2013-11-18
  • 2020-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多