mercergeoinfo
mercergeoinfo

Reputation: 409

Compile Fortran to mex on Mac

I have been forced to return to an old bugbear lately: compiling a fortran script to run under Matlab on Mac. I have managed to compile the example c file to mex but the Fortran file refuses unless I use -c and the object of my desire, kt3d.for, throws up a whole list of fun but all linked to the same error (I guess).

I'm running Matlab R2011b on OSX 10.7.5 with XCode 4.6.1.

I've patched Matlab according http://www.mathworks.se/support/solutions/en/data/1-FR6LXJ/

Got a Fortran compiler running according to https://sites.google.com/site/dwhipp/tutorials/mac_compilers

I altered the mex file to call bash rather than sh but still no joy. Getting tired of having to boot up my old XP machine every time I want to run a kriging package so I would really like to compile these things for OSX.

Below is the error, it looks like an architecture issue but I cant figure out how to fix it.

>> 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.

Upvotes: 0

Views: 705

Answers (1)

kenm
kenm

Reputation: 23905

I believe those symbols are found in GSLIB. Assuming you have this installed and somewhere that your compiler can find it, you may need to add something like "-lgslib" to your mex command to get it to link the library for you.

Upvotes: 1

Related Questions