|
FMEX Home FAQs How Can I Help? Examples Tools & Links
3. Why can't I compile FORTRAN90/95 source code using the MEX command? (This information has only been tested on Win32 using DVF6.x. On other platforms, mileage may vary.) R13 (v6.5) The Mathworks have finally updated mex.bat to handle .f90 files properly, however, they have specified compiler options that cause many Fortran9x files that worked perfectly with R11 and R12 to fail. You will need to alter your df66opts.bat file located at c:\matlab6p5\bin\win32\mexopts\ and then run >>mex -setup again If you examine your mexopts.bat file, you will find variables called OPTIMFLAGS and COMPFLAGS that look like set OPTIMFLAGS=/MD -Ox -DNDEBUG set COMPFLAGS=/fpp:"/m /S%MATLAB%/extern/include" -c -nokeep -G5 -nologo -DMATLAB_MEX_FILE /fixed set DEBUGFLAGS=/MDd -Zi Replace these lines with: set OPTIMFLAGS=/MT -Ox -DNDEBUG set COMPFLAGS=/fpp:"/m /S%MATLAB%/extern/include" -c -nokeep -G5 -nologo -DMATLAB_MEX_FILE set DEBUGFLAGS=/MTd -Zi (delete /fixed and change /MD -> /MT and /MDd -> /MTd) You can see my df66opts.bat for more details. R12 (v6) (This was submitted to me by Rob Brendel, I haven't tried it yet, as I don't have R12) Make changes, as above, to lines 1216, 1283 and 1618 of c:\matlab\bin\mex.bat . That should work just fine. R11 (version 5.x) Basically the problem is that mex.bat doesn't recognize files with extension .f90 as being source files, it thinks that they are object files and passes them straight to the linker. This is obviously problematic. This change will make your F90 code work fine: (1) open c:\matlab\bin\mex.bat
using notepad (or pico or emacs, for your *NIXers) And that is all you will need! You should be able
to run just fine.
This page was last updated on 01 August 2006 15:13 .
|