How to direct MATLAB's mex setup to the Microsoft Windows SDK for C++ compiling? (error in setting location) - c++

I am on Windows Vista, and want to use MATLAB to compile C++ functions. I had only the lcc compiler on the system, as can be seen when running mex -setup :
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/R2011a/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2011a\sys\lcc
[0] None
Compiler:
since lcc does not work for C++ I installed the Windows SDK 7.1 from here(windows site). I ran the Windows SDK 7.1 Command Prompt to see the directory it is installed to and see C:\Program Files\Microsoft SDKs\Windows\v7.1. I then run mex -setup again to set the compiler to Microsoft Visual C++ 2010, by telling mex to not locate the installed compilers, I choose the Microsoft Visual C++ 2010 option and then the path MATLAB looks at by default is one for Visual Studio; C:\Program Files\Microsoft Visual Studio 10.0. I try to override it, but there it does not work. Here is the exact actions taken:
>> 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/R2011a/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? n
Select a compiler:
[1] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker)
[2] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker)
[3] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker)
[4] Lcc-win32 C 2.4.1
[5] Microsoft Visual C++ 6.0
[6] Microsoft Visual C++ 2005 SP1
[7] Microsoft Visual C++ 2008 SP1
[8] Microsoft Visual C++ 2010
[9] Microsoft Visual C++ 2010 Express
[10] Open WATCOM C++
[0] None
Compiler: 8
Warning: The default location for Microsoft Visual C++ 2010 compiler is:
"C:\Program Files\Microsoft Visual Studio 10.0"
but either that directory does not exist or the configuration
is invalid.
Use C:\Program Files\Microsoft Visual Studio 10.0 anyway [y]/n? n
Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio 10.0]
C:\Program Files\Microsoft SDKs\Windows\v7.1
Please verify your choices:
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files\Microsoft Visual Studio 10.0
Are these correct [y]/n?
*****************************************************************************
Error: Microsoft Visual C++ 2010 requires the Microsoft Windows Software
Development Kit (SDK), but the SDK cannot be found. Examine your
Microsoft Visual C++ 2010 installation.
*****************************************************************************
??? Error using ==> mex at 208
Unable to complete successfully.
I do not know whether the directory should be different from C:\Program Files\Microsoft SDKs\Windows\v7.1, and if there is a way to identify this directory. I also do not know if the way that I give the directory is correct. I tried using single quotes around the directory name and the only variation is the that it stops to ask me whether the directory to visual studio is correct or not, I answer n and only this is given.
Compiler: Microsoft Visual C++ 2010
Location: C:\Program Files\Microsoft Visual Studio 10.0
Are these correct [y]/n? n
mex: No compiler selected. No action taken.
How can I add the compiler to MATLAB to be able to run mex on C++ funcitons/files?

If you are after the quick and easy approach (and do not use 64-bit matlab) I would suggest you download a free copy of Visual Studio 2010 C++ express and use that. That way mex -setup will detect it.

Related

Where are the Microsoft Visual C++ 2015-2022 Redistributable (x64) packages installed?

I know visual C++ 2015-2022 is installed because:
A. I see it in Apps & Features (Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.31.31103
B. I see it in registry HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\X64
but %VCINSTALLDIR% is not set on my path, and I cant find the dll's anywhere.
I need to be really specific with my IT dept to get this fixed. I want to add the dll to the system path but I have to find them first!
I managed to find VC_redist.x64.exe in C:\ProgramData\Package Cache\{2aaf1df0-eb13-4099-9992-962bb4e596d1} but I think that is pretty strange... it may be unrelated to the install.
Any help appreciated!
For me they are at
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC
Do note that %VCINSTALLDIR% only works in the Visual Studio Developer Command Prompt. That should be located under the Visual Studio XXXX folder in your start menu or it can be launched directly from inside visual studio. You can then enter
cd %VCINSTALLDIR%
in the terminal to get where the directory is located on your machine.
According to Github/Microsoft Visual C++ Files are in %VCINSTALLDIR%Redist\MSVC\v143 folder.
The easiest way to locate the redistributable files is by using environment variables set in a developer command prompt. In Visual Studio 2022, the redistributable files are in the %VCINSTALLDIR%Redist\MSVC\v143 folder. In the latest version of Visual Studio 2019, you'll find the redistributable files in the %VCINSTALLDIR%Redist\MSVC\v142 folder. In both Visual Studio 2017 and Visual Studio 2019, they're also found in %VCToolsRedistDir%. In Visual Studio 2015, these files can be found in %VCINSTALLDIR%redist<locale>, where is the locale of the redistributable packages.
I know visual C++ 2015-2022 is installed because:
A. I see it in Apps & Features (Microsoft Visual C++ 2015-2022
Redistributable (x64) - 14.31.31103
...
You're confusing Visual Studio (the development environment) with Microsoft Visual C++ Redistributable (a runtime support library). There isn't even such a thing as "visual C++ 2015-2022". Each version of Visual Studio has one specific year, such as Visual Studio 2017 (VS2017). The redistributable works for all Visual Studio versions between VS2015 and VS2022.
%VCINSTALLDIR% is set by the command prompts of all Visual Studio version, but the value will differ between Visual Studio variants. You can install multiple versions of Visual Studio side by side on the same computer.

Query: How to run application without Visual Studio 2017 installed in windows?

System : Windows 10 x64
IDE : Visual studio 2017
If we have not installed visual studio 2017 in system and if we want to run the application c++ .exe which build on visual studio 2017 what should we need to do or which dll required to install in system?
-> is msvcp140d.dll, ucrtbased.dll, vcruntime140d.dll dll part of Redistributable files?
-> What's condition for licensing about msvcp140d.dll, ucrtbased.dll, vcruntime140d.dll ? if want to release c++ tool with .exe?
You could download vc_redist.xXX.exe from Microsoft Downloads on the client cpmputer. Also, you could find it in your VS file, such as C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Redist\MSVC\14.16.27012.

Microsoft Visual C++ compiler for Dymola

I would like to use Microsoft Visual Studio 14.0's built in C compiler for simulation in 32-bit Dymola Demo Version 2017. I have opted to include C++ compiler during MVS installation and the files exist in the proper locations. When passing Dymola the location to the compiler, I receive the error:
Compiling and linking the model (Visual C++).
Error in script usage. The correct usage is:
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin\vcvars32"
or
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin\vcvars32" store
"Testing 32-bit compilation"
The command "cl" is either misspelled or could not be found.
Below attached are my settings.
Microsoft have changed some scripts or directory structure.
Visual Studio 2015 (aka 14.0) is supported out of the box by Dymola 2017 FD01 or newer,
so the easiest solution would probably be to switch to the very latest Dymola version:
https://www.3ds.com/products-services/catia/products/dymola/latest-release/
Also, when installing newer versions of Visual Studio, you should make sure to install the C++ components!!
If you forgot to install those, you can still install them later by following these steps:
open Visual Studio
click File, New, Project, then Templates, Visual C++
if the C++ parts are not installed, you will have the option to install them here
after that, you should be able to run the compiler test as shown in the screenshot below

MEX can't locate VS Express 2013 compiler - MATLAB R2013a

While setting up mex on my machine using mex -setup -v, VS Express 2013 compiler can't be found
for some reasons (see above screenshot). I still have VS 2010 installed on my machine, but I'd like to have the option to select the Express 2013 compiler on C:\Program Files (x86)\Microsoft Visual Studio 12.0\ . Has someone experienced such an issue so as to share his experience?
Thanks
Express Visual Studio compilers are not supported by Matlab.

Setting up MATLAB with a C++ compiler [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm kind of new to this, and just want to ask. How can I set up MATLAB to work with a C++ compiler. It seems that since I'm running Windows 8.1 as a prerelease, I'm not able to run visual studio 2013. So, I'm thinking of some C++ compiler that I can use when I run `mex -setup'
Update
I used Microsoft Windows SDK for Windows 7 and .NET Framework 4, and selected it as the compiler, and it worked.
Thanks.
mex -setup
All is documented here: http://www.mathworks.co.uk/help/matlab/ref/mex.html
The list of supported and compatible compilers for R2013b is here: http://www.mathworks.co.uk/support/compilers/R2013b/index.html
Older releases are linked from this page.
First do you have a C++ compiler installed on your PC? If you do this should work..
>>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
Compiler: 5
The default location for Microsoft Visual C++ 2005 compilers is
C:\Program Files (x86)\Microsoft Visual Studio 8,
1
but that directory does not exist on this machine.
Use C:\Program Files (x86)\Microsoft Visual Studio 8 anyway [y]/n? n
Please enter the location of your compiler:
[C:\Program Files (x86)\Microsoft Visual Studio 8]
E:\Program Files (x86)\Microsoft Visual Studio 8
Please verify your choices:
Compiler: Microsoft Visual C++ 2005
Location: E:\Program Files (x86)\Microsoft Visual Studio 8
Are these correct [y]/n? y
Trying to update options file:
C:\Users\fullfanta\AppData\Roaming\MathWorks\MATLAB\R2008a\mexopts.bat
From template: E:\PROGRA~1\MATLAB\R2008a\bin\win64\mexopts\msvc80opts.bat
Done . . .