Mex: compiler not found problem
76 views (last 30 days)
Show older comments
I am messing around trying to learn how to call c++ code form matlab, specifically i am trying the code following this http://www.shawnlankton.com/2008/03/getting-started-with-mex-a-short-tutorial/ but i got stuck quite early, my code is:
% Setup compiler
mex -setup
%Open c++ file
%edit(['helloworld.cpp']);
% setup mex file
mex helloworld.cpp
but i get the following output (i pasted it all, error is the last part i guess). I tried looking at the path of the compuler but i dont know what i should be looking fore ?
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Visual C++ 2008 Express in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 Express
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
*****************************************************************************
Error: Could not find the 64-bit compiler. This may indicate that the
"X64 Compilers and Tools" or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit MEX-files
Microsoft Visual C++ 2008 Express Edition requires that these two
packages are installed properly.
*****************************************************************************
Trying to update options file: C:\Users\thor\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2010a\bin\win64\mexopts\msvc90freeopts.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/en/data/1-5C27B9/?solution=1-5C27B9
Building with the -largeArrayDims option enables the new API.
**************************************************************************
Error: Could not find the compiler "cl" on the DOS path.
Use mex -setup to configure your environment properly.
C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Unable to locate compiler.
??? Error using ==> mex at 222
Unable to complete successfully.
Error in ==> mexFun at 25
mex helloworld.cpp
0 Comments
Answers (5)
Jan
on 13 Jan 2013
Edited: Jan
on 13 Jan 2013
In the error message you find this section:
Error: Could not find the 64-bit compiler. This may indicate that the
"X64 Compilers and Tools" or the Microsoft Windows Software
Development Kit (SDK) is not installed. To build 64-bit MEX-files
Microsoft Visual C++ 2008 Express Edition requires that these two
packages are installed properly.
This seems to be clear: Did you install the SDK properly? Did you read this already:
5 Comments
DoVile Last Name:
on 14 Jan 2013
3 Comments
Ken
on 16 Jan 2013
I've got the exact same problem. Fresh install of Matlab 2012b 64-bit on a fresh install of Windows 7 Enterprise 64-bit. I can't get the 7.1 SDK to install no matter what I try. I've installed VC++ 2010 Express and mex can't find the compiler. When I tell it to use the default location anyway, this is what I get:
Warning: The default location for Microsoft Visual C++ 2010 compiler is: "C:\Program Files (x86)\Microsoft Visual Studio 10.0" but either that directory does not exist or the configuration is invalid.
Use C:\Program Files (x86)\Microsoft Visual Studio 10.0 anyway [y]/n? y
Please verify your choices:
Compiler: Microsoft Visual C++ 2010 Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
*************************************************************************** Error: Could not find the 64-bit compiler. This may indicate that the "X64 Compilers and Tools" or the Microsoft Windows Software Development Kit (SDK) is not installed. To build 64-bit MEX-files Microsoft Visual C++ 2010 requires that these two packages are installed properly. ***************************************************************************
If I ever had the 64-bit compiler, it was likely deleted when Visual studio upgraded, as per one of your linked messages; but I can't re-install it as the installer requires SDK 7.1, which I can't install, getting the same error as DoVile. I've been cursing Microsoft for hours now. I'm very interested in the answer to this.
Ioan Alexandru
on 10 Jul 2014
I have the exact same problem. I installed all C++ compilers and Visual Studios from 2005 to 2013 without any positive results. I think this is a serious bug and Mathworks should do something about it since it greatly limits interfacing with 3rd party daqs...
1 Comment
Friedrich
on 10 Jul 2014
I pretty much doubt its a bug. Sounds more like an incomplete installation of the compiler. Check which compilers are supported in your release http://www.mathworks.com/support/sysreq/previous_releases.html and then make sure you also install the 64bit compiler package along with the 32bit one.
iyad salameh
on 10 Nov 2014
follow this and it should help
http://www.mathworks.com/matlabcentral/answers/64267-mex-files-and-compiler
0 Comments
Guilherme Verhalen
on 15 Jan 2018
I had the same issue, and after installing and re-installing the Microsoft SDK several times, found out that the issue was that another application added its install location on the Windows %PATH% and the folder name where it was installed had an especial character like "...\R&R\". This was causing the mex compiler to crash when expanding the Windows %PATH%. Removing this weird path solved my issue.
0 Comments
See Also
Categories
Find more on Troubleshooting in MATLAB Compiler SDK in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!