4.34615

4.3 | 26 ratings Rate this file 266 downloads (last 30 days) File Size: 21.8 KB File ID: #18508

Microsoft Visual Studio 2008 Mex and Mbuild Setup Files

by Vakur VEZIR

 

29 Jan 2008 (Updated 01 Feb 2008)

No BSD License  

Use these files to compile mex files from matlab command prompt with Visual Studio 2008

Download Now | Watch this File

File Information
Description

I installed Microsoft Visual Studio(MVS) 2008 and Matlab R2007b and tried "mex -setup" command from Matlab. However my MVS 2008 was not recognized by Matlab. I debugged mex.m and found a way to show MVS 2008 to Matlab. Necessary files are located at 2 different directories in zip file (VS2008MATLABMexCompilerFilesX64 and VS2008MATLABMexCompilerFilesX86), one is for win32 Operating System(OS) and the other one is for win64 OS. There is also "directory.txt" file in the zip which shows the directory that you should copy necessary files to. I'm using VISTA ultimate edition, but this may work for other OS(not tested). Simply copy 6 files in one of these directories(depend on your OS) to the directory specified in directory.txt and try "mex -setup" again. (Procedure for mbuild is similar to this one.)

Acknowledgements
This submission has inspired the following:
Microsoft 32/64-bit Visual C++ 2008 Express support files
MATLAB release MATLAB 7.4 (R2007a)
Other requirements Windows Vista x86 or x64 architectures (May work for winXP) Visual Studio 2008 Tested in Matlab R2007b
Zip File Content  
Other Files
VS2008MATLABMBuildCompilerFilesX86/msvc90compp.bat,
VS2008MATLABMBuildCompilerFilesX86/msvc90compp.stp,
VS2008MATLABMexCompilerFilesX64/msvc90engmatopts.bat,
VS2008MATLABMexCompilerFilesX64/msvc90freeengmatopts.bat,
VS2008MATLABMexCompilerFilesX64/msvc90freeopts.bat,
VS2008MATLABMexCompilerFilesX64/msvc90freeopts.stp,
VS2008MATLABMexCompilerFilesX64/msvc90opts.bat,
VS2008MATLABMexCompilerFilesX64/msvc90opts.stp,
VS2008MATLABMexCompilerFilesX86/msvc90engmatopts.bat,
VS2008MATLABMexCompilerFilesX86/msvc90freeengmatopts.bat,
VS2008MATLABMexCompilerFilesX86/msvc90freeopts.bat,
VS2008MATLABMexCompilerFilesX86/msvc90freeopts.stp,
VS2008MATLABMexCompilerFilesX86/msvc90opts.bat,
VS2008MATLABMexCompilerFilesX86/msvc90opts.stp,
directory.txt,
VS2008MATLABMBuildCompilerFilesX64/msvc90compp.bat,
VS2008MATLABMBuildCompilerFilesX64/msvc90compp.stp
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (37)
30 Jan 2008 Dimitri Shvorob

Thanks a lot! (Is there a way to make 'mbuild -setup' see VS 2008 too?)

31 Jan 2008 Pablo Sala

Very helpful. Thank you very much!

31 Jan 2008 Vakur VEZIR

Hi everyone,
Is there someone tried this on XP operating system? Please comment if so.
You are all welcome!

07 Feb 2008 Ali Sinop

Works perfect under XP. Thanks a lot.

11 Feb 2008 Erik Von Wurstelberg

it does not work with
vista business x64
MVS 2008
R2007b
installation is ok
compiling give the following error message
  C:\PROGRA~1\MATLAB\R2007B\BIN\MEX.PL:
  Error: Using options file:
         C:\Users\Nataste\AppData\Roaming\MathWorks\MATLAB\R2007b\mexopts.bat
         You cannot use this file with the WIN64 architecture because it enables
         a compiler for a different architecture.
         Running mex -setup may resolve this problem.

11 Feb 2008 Nhan Tien Cao

works perfectly, you are pro, thank you very much!

11 Feb 2008 Tsen Yao Peng

Does not work Vista 64 Matlab 2007

17 Feb 2008 Itzik Pinhas

Works perfectly.
Thank you very much.

18 Feb 2008 Rainer Betrug

Thank's!
works perfect with XP and Matlab2007b

20 Feb 2008 Tiago da Silva

I love you

21 Feb 2008 Armado Torres

It cannot compile x64 mex files...
useless

21 Feb 2008 Andre Pfeuffer

Only standard and professional versions of Visual Studio 2008 can handle AMD64

22 Feb 2008 Eric Tsai

Windows 2003 X86/X64 with SP2 tested.

23 Feb 2008 ivan scardanzan

does not seem to work under win xp 64

27 Feb 2008 Dean Fang

I wrote a document to describe how to adapt this for compiling 64-bit Matlab mex files using Visual Studio 2008. Please find it on our lab wiki and let me know how that works for you.

http://comkat.case.edu/comkat/comkat_wiki/index.php?title=Support:Tech_notes

Basically the trick is to force the mex to use the 64-bit compilers and libraries.

27 Feb 2008 Nirmal Jayaram

Does someone know how to get MATLAB R2007b to recognize Visual studio 2008 for Windows xp64? The procedures suggested by Vakur VEZIR and Dean Fang don't seem to work as such.

18 Mar 2008 sqhbrd hbtjv

I have :
matlab 7.4.0 (R2007a)
& microsoft visual studio 2008 pro edition (9.0)
Simple, and it's working.
Thanks a lot !!!

14 May 2008 IWBT TUBS

just what we seem to need

15 May 2008 Frustrated User

I had tried to fool Matlab in to beliving that VS 9.0 was VS 8.0 and only got 1/2 way there.

I installed these files and it worked like a charm. Thanks

30 May 2008 Bruno Carozza

Thanks a bunch!! Working perfectly

29 Jun 2008 Stefan Atev

Worked without issues

18 Aug 2008 Leos Junek

Does not work at x64 Vista Ultimate & Matlab 2007a & MS Visual Studio Pro 2008(ver. 9.0). Causing same error as described on 2008-02-11 by Erik Von Wurstelberg.

29 Aug 2008 Sudarshan Dayanidhi

Thanks!!! Recognition worked like a charm. However one still needs to have Windows SDK installed and the environment variable MSSDK set so that the compiler can actually work.

28 Sep 2008 Liuqing Yang

the matlab2007 didn't have the extern lib for the vs2008(msvc90)

29 Sep 2008 Paris Kaimakis

Many thanks Vakur, I found your post and attached .zip very helpful!

30 Sep 2008 Alexander Pastukhov

Thanks a lot! Worked perfectly with Windows XP SP 3 and Matlab v7.5.0!

04 Nov 2008 Hauke Heibel

Quite nice work so far! Unfortunately there is kinda big show stopper if you would want to compile with debug information (-g). Actually you really need to add /MDd to the DEBUGFLAGS in the msvc90compp.bat and in the msvc90opts.bat. In case these flags are missing your Matlab may completely crash. Once the files are changed, you need to re-run 'mex -setup'.

04 Nov 2008 Hauke Heibel

Anyways... thumbs up! :)

11 Nov 2008 Sharschchandra Bidargaddi

Hi,

I copied the files, and when I choose Visual C++ 2008 version, I get this error.

Please can any tell me what would be the problem?

Undefined subroutine &mexsetup::correct_version called at C:\MATLAB701\BIN\WIN32\mexopts\msvc90opts.stp line 25, <STDIN> chunk 2.
??? Error using ==> mex
Unable to complete successfully

Thanks,
Sharsch

25 Dec 2008 Wang Tianhui

I installed VC2008 in path "D:\programs\" and mex reported cannot-find-cl.exe error when I mex my cpp files after following the instructions provided by this article. But it works after I made the following changes:

in file msvc90opts.stp (Revision: 1.1.10.2):
change the line --
  my $default_location = "C:\\Program Files\\Microsoft Visual Studio 9.0";
to my vc installed path --
   my $default_location = "D:\\Programs\\Microsoft Visual Studio 9.0";

15 Jan 2009 Larry Baker

We were unable to use the files here with Microsoft Visual C++ 2008 Express. I have uploaded our support files for 32/64-bit Microsoft Visual C++ 2008 Express with the latest Windows Platform SDK are at http://www.mathworks.com/matlabcentral/fileexchange/22689.

24 Jan 2009 mklml

hi woudl you also have ideas on how I can associate the link files ? I have downloaded MVS2008 and used your files to install it. I want to instal an Intel fortran compiler and it keeps requesting the 'Microsoft Visual C++ 2005 linker' ?

13 Mar 2009 Amaren

i am getting the following error when i use mex - setup and then respond 'y'. what may be the reson. Please help
the error is
Undefined subroutine &mexsetup::correct_version called at C:\MATLAB7\BIN\WIN32\mexopts\msvc90opts.stp line 25, <STDIN> chunk 1.

20 Apr 2009 Gerald Lodron Lodron

cool thanx

25 Apr 2009 Carlos Guerrero Mosquera

Doesn't work at x64 Vista Business, Matlab R2007b and MS Visual Studio 2008. I tried with mex-setup but was not recognized by Matlab. The installation is OK but and the end you can't use the compiler :-(

10 Jun 2009 Daniel Wright

I get the following error when I use mbuild -setup:

Undefined subroutine &mexsetup::correct_version called at C:\MATLAB701\BIN\WIN32\mbuildopts\msvc90compp.stp line 26, <STDIN> chunk 1.
??? Error using ==> mbuild
Unable to complete successfully

I see that 2 others have had the same issue. Any suggestions are welcome; please send me an email. I am using Matlab 7.0.1 (R14) in Windows XP on an x86 machine

03 Aug 2009 Seong-Joo

It worked! Thank you.

Please login to add a comment or rating.
Updates
30 Jan 2008

To explain submission better!

31 Jan 2008

mbuild files are added.

01 Feb 2008

Change title and keywords for mbuild.

Tag Activity for this File
Tag Applied By Date/Time
external interface Vakur VEZIR 22 Oct 2008 09:45:23
mex visual studio 90 2008 setup mbuild Vakur VEZIR 22 Oct 2008 09:45:23
external interface Jun Li 14 Nov 2008 12:46:25
mex visual studio 90 2008 setup mbuild Jun Li 14 Nov 2008 12:46:30
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com