howto: mex Matlab r2008a + MS Visual C/C++ Prof Edition 2008, win64



Hi, I am having problems with setting up matlab r2008a to
compile C++ mex files with Visual Studio 2008 prof. on
windows XP 64bits.

When I run mex -setup, matlab doesn't find any compilers.
If i choose not to let matlab locate compilers:

mex -setup
Please choose your compiler for building external interface
(MEX) files:

Would you like mex to locate installed compilers [y]/n? n

Select a compiler:
[1] Intel C++ 9.1 (with Microsoft Visual C++ 2005 linker)
[2] Intel Visual Fortran 10.1 (with Microsoft Visual C++
2005 linker)
[3] Intel Visual Fortran 9.1 (with Microsoft Visual C++
2005 linker)
[4] Microsoft Platform SDK 14.0
[5] Microsoft Visual C++ 2005
[6] Microsoft Visual C++ 2008

[0] None

Compiler: 6

The default location for Microsoft Visual C++ 2008
compilers is C:\Program Files (x86)\Microsoft Visual Studio
9.0,
but that directory does not exist on this machine.

Use C:\Program Files (x86)\Microsoft Visual Studio 9.0
anyway [y]/n? y

Please verify your choices:

Compiler: Microsoft Visual C++ 2008
Location: C:\Program Files (x86)\Microsoft Visual Studio
9.0

Are these correct [y]/n? y

************************************************************
***************
Warning: MEX-files generated using Microsoft Visual C++
2008 require
that Microsoft Visual Studio 2008 run-time
libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to
other MATLAB
users, be sure that they have the run-time
libraries.
************************************************************
***************

Trying to update options file: C:\Documents and
Settings\svepe\Application
Data\MathWorks\MATLAB\R2008a\mexopts.bat
From template: C:\PROGRA~1
\Matlab\R2008a\bin\win64\mexopts\msvc90opts.bat

Done . . .

************************************************************
**************
Warning: The MATLAB C and Fortran API has changed to
support MATLAB
variables with more than 2^32-1 elements. In
the near future
you will be required to update your code to
utilize the new
API. You can find more information about this
at:

http://www.mathworks.com/support/solutions/data/1-
5C27B9.html?solution=1-5C27B9
Building with the -largeArrayDims option enables
the new API.
************************************************************
**************

Visual Studio 9.0 is installed in "C:\Program Files (x86)
\Microsoft Visual Studio 9.0\", the same directory where
matlab try to find it.


When I then try to mex a file:

mex test.cpp -v -g
This is mex, Copyright 1984-2007 The MathWorks, Inc.

-> Default options filename found in C:\Documents and
Settings\svepe\Application Data\MathWorks\MATLAB\R2008a
------------------------------------------------------------
----
-> Options file = C:\Documents and
Settings\svepe\Application
Data\MathWorks\MATLAB\R2008a\mexopts.bat
MATLAB = C:\PROGRA~1\Matlab\R2008a
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = -c -Zp8 -GR -W3 -EHs -
D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -
D_SECURE_SCL=0 -DMATLAB_MEX_FILE -nologo /MD
OPTIMFLAGS = -O2 -Oy- -DNDEBUG
DEBUGFLAGS = -Zi -Fd"test.mexw64.pdb"
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS
= /dll /export:mexFunction /MAP /LIBPATH:"C:\PROGRA~1
\Matlab\R2008a\extern\lib\win64\microsoft" libmx.lib
libmex.lib libmat.lib /implib:C:\DOCUME~1\svepe\LOCALS~1
\Temp\mex_7pRkhg\templib.x /MACHINE:X64 kernel32.lib
user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib
LINKDEBUGFLAGS
= /DEBUG /PDB:"test.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"test.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
------------------------------------------------------------
----


--> cl -c -Zp8 -GR -W3 -EHs -D_CRT_SECURE_NO_DEPRECATE -
D_SCL_SECURE_NO_DEPRECATE -D_SECURE_SCL=0 -
DMATLAB_MEX_FILE -nologo /MD /FoC:\DOCUME~1\svepe\LOCALS~1
\Temp\mex_7pRkhg\test.obj -IC:\PROGRA~1
\Matlab\R2008a\extern\include -IC:\PROGRA~1
\Matlab\R2008a\simulink\include -Zi -Fd"test.mexw64.pdb" -
DMX_COMPAT_32 H:\Exjobb\run\test.cpp


C:\PROGRA~1\MATLAB\R2008A\BIN\MEX.PL: Error: Compile
of 'test.cpp' failed.



I have read that on earlier versions of matlab you could
solve this by setting the environment variable, MSSDK to
the path where platform SDK where. I have installed
microsoft SDK v6.0a. I can find it in the paths:
C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A
and
C:\Program Files\Microsoft SDKs\Windows\v6.0A
so Im not shure which path to use.

Does anyone know or have clue how to fix this problem?

Thanks
Sven



.



Relevant Pages

  • Re: Matlab cannot find compiler over mapped drive
    ... > Could anyone confirm that Matlab refuses to use a mapped drive to do ... Can you use compilers installed on a different machine in windows? ... That was actually what I tried, but maybe because it's a mapped drive, it says that the location (X:\program files\Microsoft Visual Studio 9.0) does not exist. ... I am able to use a mapped drive location in the latest version of MATLAB. ...
    (comp.soft-sys.matlab)
  • Re: Matlab cannot find compiler over mapped drive
    ... Could anyone confirm that Matlab refuses to use a mapped drive to do ... Can you use compilers installed on a different machine in windows? ... You could try specifying the path explicitly to MATLAB: ... it says that the location (X:\program files\Microsoft Visual Studio 9.0) ...
    (comp.soft-sys.matlab)
  • matlab + C + lib = not working?!
    ... Ok i have some C code which i have written in Visual Studio 2008 as a console application and it works just fine. ... However when I try to use it through matlab R2009a i get a linking error. ... EDU>> mex CCDgettest.cpp ... Copyright Microsoft Corporation. ...
    (comp.soft-sys.matlab)
  • matlab + C + lib = not working?!
    ... Ok i have some C code which i have written in Visual Studio 2008 as a console application and it works just fine. ... However when I try to use it through matlab R2009a i get a linking error. ... EDU>> mex CCDgettest.cpp ... Copyright Microsoft Corporation. ...
    (comp.soft-sys.matlab)
  • matlab + C + lib = not working?!
    ... Ok i have some C code which i have written in Visual Studio 2008 as a console application and it works just fine. ... However when I try to use it through matlab R2009a i get a linking error. ... EDU>> mex CCDgettest.cpp ... Copyright Microsoft Corporation. ...
    (comp.soft-sys.matlab)