Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks

4 visualizzazioni (ultimi 30 giorni)
Hello, let me start by saying what I have installed:
  • Matlab/Simulink 2013a - 64 bit
  • Microsoft Visual C++ Compilers 2010 SP1 Standard - x64 and x86 (both installed)
  • Microsoft Visual C++ 2010 Redistributable - 10.0.40219, x64 and x86 (both installed)
  • Microsoft Windows SDK 7.1
  • Microsoft .NET Framework 4 and 4.5.2
  • Windows 7
I work for a company that requires that I use these exact versions of software for compatibility issues so please don't recommend that I get "newer versions" of any of these pieces of software.
Here's what I'm trying to do
  • Setup the compiler as follows:
  1. Open Matlab
  2. enter 'mex -setup'
  3. choose my compiler
  4. check the results of setting the compiler using 'mex.getCompilerConfigurations()'
Here's the code and output from this:
>> mex -setup
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Software Development Kit (SDK) 7.1 in c:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Software Development Kit (SDK) 7.1
Location: c:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
***************************************************************************
Warning: MEX-files generated using Microsoft Windows Software Development
Kit (SDK) require that Microsoft Visual Studio 2010 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:\Users\iw542d\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2013a\bin\win64\mexopts\mssdk71opts.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/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
Building with the -largeArrayDims option enables the new API.
**************************************************************************
>> CC = mex.getCompilerConfigurations()
Reference to non-existent field 'The system cannot find the path specified.
VSINSTALLDIR'.
Error in mex.CompilerConfigurationFactory/determineLocation (line 281)
location = detailStruct.(outputValue);
Error in mex.CompilerConfigurationFactory/process (line 127)
basicStructArray(numberOfLangs).Location = determineLocation(obj,
storageLocations{index}, basicStructArray, detailsStruct);
Error in mex.getCompilerConfigurations (line 56)
compConfig = process(ccF);
>>
Next, I'm trying to build a Simulink model and I get the following error message
Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler.
HOW DO I FIX THIS COMPILER ISSUE?

Risposte (1)

Ryan Livingston
Ryan Livingston il 18 Mar 2015
The error from mex.getCompilerConfigurations() states that VSINSTALLDIR cannot be found. In MATLAB run:
getenv VSINSTALLDIR
to see if you get a value for that variable. If not, I would:
1. Restart Windows to see if the SDK installation settings take hold after rebooting
2. Try to MEX a simple file. In a directory where you have write privileges:
copyfile(fullfile(matlabroot,'extern','examples','mex','yprime.c'),pwd)
mex -v yprime.c
Does that work? If not, that will need to be resolved first.
  2 Commenti
Brad
Brad il 19 Mar 2015
Ok thanks,
I did:
getenv VSINSTALLDIR
And got a blank output:
''
Next, I did your two steps and it seemed to work:
>> copyfile(fullfile(matlabroot,'extern','examples','mex','yprime.c'),pwd)
>> mex -v yprime.c
***************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
****************************************************************************
-> Default options filename found in C:\Users\iw542d\AppData\Roaming\MathWorks\MATLAB\R2013a
----------------------------------------------------------------
-> Options file = C:\Users\iw542d\AppData\Roaming\MathWorks\MATLAB\R2013a\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2013a
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = /c /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 = /Z7
arguments =
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2013a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /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 /nologo /manifest /incremental:NO /implib:"C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\templib.x" /MAP:"yprime.mexw64.map"
LINKDEBUGFLAGS = /debug /PDB:"yprime.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"yprime.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\yprime.obj -I"C:\Program Files\MATLAB\R2013a\extern\include" -I"C:\Program Files\MATLAB\R2013a\simulink\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 yprime.c
yprime.c
Contents of C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\mex_tmp.rsp:
C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\yprime.obj
--> link /out:"yprime.mexw64" /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2013a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /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 /nologo /manifest /incremental:NO /implib:"C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\templib.x" /MAP:"yprime.mexw64.map" @C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\mex_tmp.rsp
Creating library C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\templib.x and object C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\templib.exp
--> del "C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\templib.x" "C:\Users\iw542d\AppData\Local\Temp\mex_Lrgi7n\templib.exp"
--> mt -outputresource:"yprime.mexw64;2" -manifest "yprime.mexw64.manifest"
Microsoft (R) Manifest Tool version 6.1.7716.0
Copyright (c) Microsoft Corporation 2009.
All rights reserved.
--> del "yprime.mexw64.manifest"
--> del "yprime.mexw64.map"
What do you think the next steps should be?

Accedi per commentare.

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by