|
FMEX Home
FAQs
How Can I Help?
Examples
Tools & Links
Yes, I do it quite frequently. The following is written
using Matlab 5.3, Compaq Visual Fortran 6.6, and Windows 2000. The example here
uses Fortran95 source, though this can be done in FORTRAN77 just as
easily. There are examples of MEX files that
use MKL: vvmult_mkl.f90, IMSL:
vvmult_imsl.f90, and CXML:
vvmult_cxml.f90.
First, you will need to modify your mexopts.bat file. On R13
(v6.5) modify the file c:\matlab6p5\bin\win32\mexopts\df66opts.bat. On R11 and
R12, you will need to issue the command prefdir(1)
to tell you where your mexopts.bat is located. You can see my mexopts.bat file
for R11/R12 and
R13 at these links.
In order to add IMSL, you will need to add the following lines
to your mexopts file:
set LINKFLAGS=%LINKFLAGS% sstatd.lib
sstats.lib
set LINKFLAGS=%LINKFLAGS% smathd.lib smaths.lib sf90mp.lib
set LIB=%LIB%;%DFDir%\IMSL\LIB;
For MKL, you will need to add these
lines, you must also uncomment one of the last three lines to specify the
processor type. Note that MEX files linked against mkl_p4.lib will only run on a
P4. MEX files linked against mkl_p3.lib will only run on a P3 or P4.
set LINKFLAGS=%LINKFLAGS% mkl_s.lib
mkl_lapack.lib
set LIB=%LIB%;C:\Program Files\Intel\MKL\ia32\lib
rem ********************************************************************
rem Choose One (p4=Pentium 4, p3=Pentium 3, def=all others)
rem ********************************************************************
rem set LINKFLAGS=%LINKFLAGS% mkl_def.lib
rem set LINKFLAGS=%LINKFLAGS% mkl_p3.lib
rem set LINKFLAGS=%LINKFLAGS% mkl_p4.lib
For CXML, add the following lines:
set LINKFLAGS=%LINKFLAGS% cxml.lib
set LIB=%LIB%;%DFDir%\CXML\LIB
set INCLUDE=%INCLUDE%;%DFDir%\CXML\INCLUDE
Note that many of the routines in
these libraries conflict. Many conflict across all 3 libraries, in fact.
Therefore, if you think that you might be using different libs on different
projects, you can also leave all of the LINKFLAG variables commented, and
specify the libraries on the command line. So if you want to use MKL, you build
the file with the command
» mex vvmult_mkl.f90 mkl_s.lib mkl_def.lib
mkl_lapack.lib
Likewise, the syntax for IMSL is:
» mex vvmult_imsl.f90 sstatd.lib
sstats.lib smathd.lib smaths.lib
And finally, CXML:
» mex vvmult_cxml.f90 cxml.lib
And there you go!
|