我想用 gfortran 编译一个 fortran 代码,这样它就可以在 Mac OS X 10.5 和 10.6 上运行。有没有办法做到这一点?我尝试在 10.6 上编译并在 10.5 上运行可执行文件时收到此消息:
dyld:未知所需的加载命令 0x80000022 跟踪/BPT 陷阱
该应用程序错误地在 OS X 10.6 机器上为 10.5 机器构建。开发人员可以通过考虑三件事来解决这个问题:
Using the correct compiler parameters:
gcc-4.2 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk ...
Using the correct linker settings (setting environment variable before link command). This is required, so that the OS X 10.6 linker will not use the loader command 'LC_DYLD_INFO_ONLY' (=0x80000022), because OS X 10.5 does not understand this command:
export MACOSX_DEPLOYMENT_TARGET=10.5
(or setenv MACOSX_DEPLOYMENT_TARGET=10.5)
修复此问题后,可以通过运行“otool”检查应用程序是否为 OS X 10.5 正确构建:
otool -l 二进制
正确的二进制文件不应包含任何“LC_DYLD_INFO_ONLY”加载命令(仅“LC_DYLD_INFO”命令)。
(另见我的博客文章http://grauonline.de/wordpress/?p=71)