在Mac上将Fortran编译为mex

时间:2013-03-26 15:47:41

标签: macos matlab fortran

我最近被迫回到一个旧的bugbear:编译一个fortran脚本在Mac下的Matlab下运行。我已经设法将示例c文件编译为mex但Fortran文件拒绝,除非我使用-c和我想要的对象kt3d.for,抛出一整个有趣的列表但是所有链接到相同的错误(我猜)

我在OSX 10.7.5上使用XCode 4.6.1运行Matlab R2011b。

我根据http://www.mathworks.se/support/solutions/en/data/1-FR6LXJ/

修补了Matlab

根据https://sites.google.com/site/dwhipp/tutorials/mac_compilers

运行Fortran编译器

我改变了mex文件来调用bash而不是sh但仍然没有快乐。每次我想运行kriging包时都厌倦了启动旧的XP机器,所以我真的想为OSX编译这些东西。

下面是错误,它看起来像是架构问题,但我无法弄清楚如何解决它。

>> mex kt3d.for
Undefined symbols for architecture x86_64:
  "_chknam_", referenced from:
      _readparm_ in kt3d.o
  "_cova3_", referenced from:
      _kt3d_ in kt3d.o
  "_ktsol_", referenced from:
      _kt3d_ in kt3d.o
  "_mexfunction_", referenced from:
     -exported_symbol[s_list] command line option
  "_picksup_", referenced from:
      _kt3d_ in kt3d.o
  "_setrot_", referenced from:
      _kt3d_ in kt3d.o
  "_setsupr_", referenced from:
      _kt3d_ in kt3d.o
  "_srchsupr_", referenced from:
      _kt3d_ in kt3d.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

    mex: link of ' "kt3d.mexmaci64"' failed.

Error using mex (line 206)
Unable to complete successfully.

1 个答案:

答案 0 :(得分:1)

我相信这些符号可以在GSLIB中找到。假设您已经安装了这个并且编译器可以找到它,您可能需要在mex命令中添加类似“-lgslib”的内容,以便它为您链接库。