mex setup for Matlab - windows

I am having some trouble with the mex setup in terms of selecting a compiler. I have attempted to install windows SDK 7.1 but it fails each time. According to THIS forum it is because i have visual studio 10.0 installed (which I do). So ideally i should be able to set up mex with this compiler. But when i try i get the following error:
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/R2012a/win64.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++ 12.0 (with Microsoft Software Development Kit (SDK) linker)
...
[14] Microsoft Visual C++ 2010
[0] None
Compiler: 14
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.
*****************************************************************************
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 (line 206)
Unable to complete successfully.
So obviously i do need SDK??? I have tried un-installing the SDK 7.1 from microsoft several times but no luck.
I have thought that maybe i need to manually point mex deeper into the visual studio file system in order to find the compiler, any ideas about that?
I am using Windows 7 64 bit with matlab R2012a.
Thanks for your help.

I don't know the reason for this but this is how I got it right.
Uninstall all versions of Microsoft Visual C++ Redistributable from your computer.
Install Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1 from here: https://www.microsoft.com/en-in/download/details.aspx?id=4422
Try mex -setup again.

Related

ifort: error #10037: could not find 'link' in Visual Studio

I have tried to run a Fortran code (.FOR) using Visual Studio 2019 and installed Intel OneAPI basic toolkits.
when I run a Fortran code I receive "ifort: error #10037: could not find 'link'". Does anyone know the solution?
Thanks.
You need Microsoft Visual Studio configured to include C++ for Desktop Applications. See https://www.intel.com/content/www/us/en/developer/articles/guide/installing-microsoft-visual-studio-2019-for-use-with-intel-compilers.html for more details. You might need to do a Change/Modify of the Intel oneAPI HPC Toolkit (from the Windows Settings > Apps dialog) to get it recognized.

Compilation Error in VS Studio compiling Fortran code

I am getting this error while compiling my Fortran code in VS Studio:
warning #31001: The dll for reading and writing the pdb (for example, mspdb110.dll) could not be found on your path.
I also looked to change the Base Platform Toolset in Project Properties, but in VS 2019 IDE I couldn't find this option to edit it.
I am using Intel Compiler 2021. I have also tried upgrading my VS Studio to latest version but the problem persists.
Please tell how to fix this.
This message is saying that your Visual Studio is misconfigured. Make sure that you have the "Desktop Development for C++" and "Windows 10 SDK" components of Visual Studio installed (see https://www.intel.com/content/www/us/en/developer/articles/guide/installing-microsoft-visual-studio-2019-for-use-with-intel-compilers.html) You may need to uninstall both the Intel compiler and Visual Studio, then reinstall.

Visual Studio 2010 x64 Compiler on Windows 10

I've installed Visual Studio 2010 Express but I need the x64 compiler toolset. I can not install the compiler toolset with the Windows 7.1 SDK on my Windows 10 machine, it says ".NET Framework 4 is not installed".
How can I get the x64 compilers of Visual Studio 2010?
For me it worked with the following steps (older Visual Studio version can be downloaded through https://www.visualstudio.com/vs/older-downloads/ (required login))
Install Microsoft Visual Studio 2010 Express (en_visual_studio_2010_vc_express_web_installer_x86_516528)
Install Microsoft Visual Studio 2010 SP1 (mu_visual_studio_2010_sp1_web_installer_x86_651694)
Install Microsoft SDK (from https://www.microsoft.com/en-us/download/details.aspx?id=8279). Note that when running the installer a warning will appear saying that "some components cannot be installed". Just ignore this (press OK) and continue with the installation using the default settings. Note that the 64-bit C++ compiler is not installed at this point.
Install KB2519277 (from https://www.microsoft.com/en-us/download/details.aspx%3Fid=4422).
Both the 32- and 64-bit Visual Studio 2010 C++ compilers should now be installed.
Note that I'm not sure if all the above steps are actually necessary and if the order is strictly relevant (e.g. it might also work without installing SP1 or installing SP1 later) but this is what worked for me.
I found an installer for VS 2010 Professional on CNet: http://download.cnet.com/Microsoft-Visual-Studio-2010-Professional/3000-2212_4-10618634.html It installed the x64 compilers as well.

"program can't start because msvcp100.dll is missing" for Every single code

This error is taking toll of my training schedule.
Everytime I create any C++ application in my VS2010, It runs fine on my machine but if I run it on different machine, It starts with this error.
Error goes if I copy msvcp100.dll in System Folder then it shouts for some other DLL. It requires some 5-6 different DLLs.
Most irritating part is even if I write a simple Console based Addition program, It gives this error.
(I should not but)I would have agree if I design some fancy forms and all... But for simple Addition program????
Am I missing out somethings in Settings? or VS2010 to blame??
Somewhat related question: this But this problem seems different
By default, MSVC projects are set to link against the dynamic run time library which generates a dependency on the visual C++ run time redistributable. As you have already found out, this dependency is not guaranteed so your install utility has to install the visual c++ run time first.
You can avoid this by changing your project settings. Load the project properties and go to: "Configuration Properties"/"C/C++"/"Code Generation"
In the item labelled "Runtime Library", select "Multi Threaded (/MT)"
for the release version"Multi Threaded Debug (/MTd)" for the debug version.
You have to be careful while doing this that all the other libraries that your application links are also compiled against the static run time.
You need to have Visual C++ Libraries installed if you want to run your app.
Using the compiler options to change the runtime library worked for me ("Configuration Properties"/"C/C++"/"Code Generation". In the item labelled "Runtime Library", select "Multi Threaded (/MT)" for the release version and "Multi Threaded Debug (/MTd)" for the debug version). I did have to do both the debug and the release to get the release to work. Don't know why (it is possible that I did not do it correct the first time).
Note: I was using VC2010 Express version on Windows 7 to compile. I tested on an old XP machine.
Another note: MS information at http://msdn.microsoft.com/en-us/library/2kzt1wy3(v=vs.100).aspx
If you have installed a new copy of Windows on your computer or have reinstalled one then you will come across an error called "The program can’t start because MSVCP100.dll is missing from your computer. Try reinstalling the program to fix the problem." on your computer.
The basic reason behind this error is that the Visual C++ doesn’t get installed when you reinstall or install a fresh copy of Windows operating system. In order to check Visual C++ is installed on your PC or not, open Control Panel → All Programs and Features and then search for Visual C++ in the software list. If you don’t find the software installed there then you have to install it.
I would suggest, first of all, install the Visual C++ 2010 package and check if it has solved msvcp100.dll missing error or not. If the issue is not resolved by the Microsoft Visual C++ 2010 then install 2013 or 2015 versions of Microsoft Visual C++. Here is the list of download links of Microsoft Visual C++ for both x86 and x64 architectures:
Microsoft Visual C++ 2010 SP1 Redistributable Package (x64)
Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)
Visual C++ Redistributable Packages for Visual Studio 2013
Visual C++ Redistributable for Visual Studio 2015
→ The latest supported Visual C++ downloads
I hope, now you are able to fix “The program can’t start because MSVCP100.dll is missing error on your computer. To know more details, you can follow this guide.
Thanks

Setting up mex to use the Visual Studio 2010 compiler

I have Visual Studio 2010 installed. However, MATLAB doesn't find the compiler.
>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[0] None
Compiler:
If I answer n to the question, I get the following
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 C++ 9.1 (with Microsoft Visual C++ 2005 SP1 linker)
[3] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker)
[4] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker)
[5] Intel Visual Fortran 10.1 (with Microsoft Visual C++ 2005 SP1 linker)
[6] Microsoft Visual C++ 2005 SP1
[7] Microsoft Visual C++ 2008 Express
[8] Microsoft Visual C++ 2008 SP1
[0] None
Compiler: 8
The default location for Microsoft Visual C++ 2008 SP1 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? n
Please enter the location of your compiler: [C:\Program Files (x86)\Microsoft Visual Studio 9.0]
What is the easiest way to compile my c++ code to make it available in MATLAB? Install Visual C++ 2008? oO
It depends on what MATLAB version you are using. R2010b supports VS2010 out of the box. If you have R2010a, there is a patch available:
Update From the World of MEX: Visual Studio 2010 Support
How can I use Microsoft Visual C++ 2010 to create MEX files with MATLAB 7.10 (R2010a)?
There are more than 1 ways of working around your problem, and only one involves money :)
Buy/Upgrade to a new Matlab version (R2010b recognizes and works with VS2010).
You don't have to install the full VS2008 package, the old Windows SDK v7.0 is enough. Once installed, matlab should recognize is when you do a mbuild -setup.
As you yourself suggested, install VS2008.
For future reference: http://www.mathworks.com/support/compilers/R2010b/index.html
You can also make your c++ code available to Matlab without using mex. Matlab is capable of loading external DLLs and calling their functions. So you can wrap your code into a DLL, and bypass mex entirely.
Generally, I found this to be an easier way of calling C or C++ code from matlab. The drawback is that you would not have all the facilities for manipulating matlab data structures that mex provides. You can still pass data back and forth, some things are more cumbersome, such as allocating an array in C and giving the ownership of it to matlab.

Resources