{"id":33,"date":"2011-05-24T14:28:46","date_gmt":"2011-05-24T19:28:46","guid":{"rendered":"http:\/\/www.matthewcroberts.com\/?page_id=33"},"modified":"2011-05-24T14:28:46","modified_gmt":"2011-05-24T19:28:46","slug":"q8-external-libraries","status":"publish","type":"page","link":"http:\/\/www.matthewcroberts.com\/?page_id=33","title":{"rendered":"Q8: External Libraries"},"content":{"rendered":"<p>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.\u00a0<span style=\"font-family: 'Times New Roman';\">There are examples of MEX files that use MKL:\u00a0<a href=\"http:\/\/aede.osu.edu\/people\/roberts.628\/papers\/research\/fmex\/files\/vvmult_mkl.f90.txt\">vvmult_mkl.f90<\/a>, IMSL:\u00a0<a href=\"http:\/\/aede.osu.edu\/people\/roberts.628\/papers\/research\/fmex\/files\/vvmult_imsl.f90.txt\">vvmult_imsl.f90,<\/a>and CXML:\u00a0<a href=\"http:\/\/aede.osu.edu\/people\/roberts.628\/papers\/research\/fmex\/files\/vvmult_cxml.f90.txt\">vvmult_cxml.f90<\/a>.<\/span><\/p>\n<p>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<span style=\"font-family: Fixedsys;\">prefdir(1)<\/span> to tell you where your mexopts.bat is located. You can see my mexopts.bat file for<a href=\"http:\/\/aede.osu.edu\/people\/roberts.628\/papers\/research\/fmex\/files\/r11_r12_mexopts.bat.txt\">R11\/R12<\/a> and\u00a0<a href=\"http:\/\/aede.osu.edu\/people\/roberts.628\/papers\/research\/fmex\/files\/r13_df66opts.bat.txt\">R13 <\/a>at these links.<\/p>\n<p>In order to add IMSL, you will need to add the following lines to your mexopts file:<\/p>\n<p><span style=\"font-family: 'Arial Black';\">set LINKFLAGS=%LINKFLAGS% sstatd.lib sstats.lib<br \/>\nset LINKFLAGS=%LINKFLAGS% smathd.lib smaths.lib sf90mp.lib<br \/>\nset LIB=%LIB%;%DFDir%\\IMSL\\LIB;<\/span><\/p>\n<p><span style=\"font-family: 'Times New Roman';\">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.<\/span><\/p>\n<p><span style=\"font-family: Fixedsys;\">set LINKFLAGS=%LINKFLAGS% mkl_s.lib mkl_lapack.lib<br \/>\nset LIB=%LIB%;C:\\Program Files\\Intel\\MKL\\ia32\\lib<br \/>\nrem ********************************************************************<br \/>\nrem Choose One (p4=Pentium 4, p3=Pentium 3, def=all others)<br \/>\nrem ********************************************************************<br \/>\nrem set LINKFLAGS=%LINKFLAGS% mkl_def.lib<br \/>\nrem set LINKFLAGS=%LINKFLAGS% mkl_p3.lib<br \/>\nrem set LINKFLAGS=%LINKFLAGS% mkl_p4.lib<\/span><\/p>\n<p><span style=\"font-family: 'Times New Roman';\">For CXML, add the following lines:<\/span><\/p>\n<p><span style=\"font-family: Fixedsys;\">set LINKFLAGS=%LINKFLAGS% cxml.lib<br \/>\nset LIB=%LIB%;%DFDir%\\CXML\\LIB<br \/>\nset INCLUDE=%INCLUDE%;%DFDir%\\CXML\\INCLUDE<\/span><\/p>\n<p><span style=\"font-family: 'Times New Roman';\">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<\/span><\/p>\n<p><span style=\"font-family: Fixedsys;\">\u00bb mex\u00a0vvmult_mkl.f90 mkl_s.lib mkl_def.lib mkl_lapack.lib<\/span><\/p>\n<p>Likewise, the syntax for IMSL is:<\/p>\n<p><span style=\"font-family: Fixedsys;\">\u00bb mex\u00a0vvmult_imsl.f90 sstatd.lib sstats.lib smathd.lib smaths.lib<\/span><\/p>\n<p><span style=\"font-family: 'Times New Roman';\">And finally, CXML:<\/span><\/p>\n<p><span style=\"font-family: Fixedsys;\">\u00bb mex\u00a0vvmult_cxml.f90 cxml.lib<\/span><\/p>\n<p>And there you go!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0There are examples of MEX files that use MKL:\u00a0vvmult_mkl.f90, IMSL:\u00a0vvmult_imsl.f90,and CXML:\u00a0vvmult_cxml.f90. First, you will need to modify your mexopts.bat file. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":24,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-33","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=33"}],"version-history":[{"count":0,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages\/33\/revisions"}],"up":[{"embeddable":true,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages\/24"}],"wp:attachment":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}