Thread Subject: problem compiling Fortran mex file

Subject: problem compiling Fortran mex file

From: Kevin Johnson

Date: 25 Nov, 2009 16:38:22

Message: 1 of 3


Hi,

My problem is that I have been unable to create a Fortran-based mex file in MATLAB because of failure to compile and/or link the source files. I am testing a very simple example (given below).

My setup is:

Hardware: new MaxBook Pro
OS: OS X 10.6.2
Developer software: XCode 3.2
Application: MATLAB R2009b
Fortran Compiler: Intel Professional 11.1 trial copy
Previous compiler: gfortran 4.2.3 from r.research.att.com/tools/

This was my first attempt to create mex files, so initially I installed a version of gfortran and had no success getting it to compile. I edited the mexopt.sh file etc as per various user posts I could find, still no luck. Finally I uninstalled gfortran using the terminal commands and restored the original mexopt.sh file from a backup copy.

Then I obtained a trial copy of Intel Fortran Compiler Professional 11.1 and installed it apparently without problems.

I used the "mex -setup" command from within MATLAB in the command window:
 
>> mex -setup

    Options files control which compiler to use, the compiler and link command
    options, and the runtime libraries to link against.

    Using the 'mex -setup' command selects an options file that is
    placed in ~/.matlab/R2009b and used by default for 'mex'. An options
    file in the current working directory or specified on the command line
    overrides the default options file in ~/.matlab/R2009b.
 
    To override the default options file, use the 'mex -f' command
    (see 'mex -help' for more information).

The options files available for mex are:

  1: /Applications/MATLAB_R2009b.app/bin/gccopts.sh :
      Template Options file for building gcc MEX-files
 
  2: /Applications/MATLAB_R2009b.app/bin/mexopts.sh :
      Template Options file for building MEX-files via the system ANSI compiler
 

  0: Exit with no changes

Enter the number of the compiler (0-2):

I entered "2".

Next I ran this simple test of the compiler:

mex yprimef.F yprimefg.F
yprimef(1,1:4)

which gave the output

/Applications/MATLAB_R2009b.app/bin/mex: line 997: gfortran: command not found

    mex: compile of ' "yprimef.F"' failed.

??? Error using ==> mex at 221
Unable to complete successfully.


Apparently gfortran is still lurking in there somwewhere, or I have failed to point things to the correct directory somwhow, etc.

Any thoughts?

Thanks

Subject: problem compiling Fortran mex file

From: Kevin Johnson

Date: 25 Nov, 2009 19:54:20

Message: 2 of 3

Also, should the Intel compiler show up as a specific choice under the MATLAB "mex -setup" command?

Subject: problem compiling Fortran mex file

From: William

Date: 9 Jan, 2010 23:45:06

Message: 3 of 3

Did you ever solve this issue? I have the same error. It seems that the gcc that comes installed on OS X does not handle fortran. Which version of OS X are you using? I have 10.6.2

William Barnett

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
fortran William 9 Jan, 2010 18:49:06
rssFeed for this Thread

Contact us at files@mathworks.com