Problems installing C++ compiler for mex (Win 7 64-bit)

2 vues (au cours des 30 derniers jours)
George
George le 10 Déc 2014
Modifié(e) : George le 10 Déc 2014
(1) Errors finding a valid C++ compiler.
I had errors trying to create mex files because my C++ compilers were not installed with my installation of WinSDK 7.1. I did not have any of the professional versions Visual Studio, and had to rely on the C++ compilers of the WinSDK 7.1 which seem to be the only no-cost option from the compilers supported by Matlab for mex file compilation (see, e.g.: http://www.mathworks.com/support/compilers/R2012b/win64.html).
Trying to change my WinSDK 7.1 installation did not fix the problem. Attempts to change the WinSDK 7.1 installation (to add the compilers option, as described in the instructions from http://www.mathworks.com/matlabcentral/answers/101105-how-do-i-install-microsoft-windows-sdk-7-1) did not work. This process always failed for me with fatal errors at steps 4 & 5 of those instructions.
Windows SDK installer reported: A problem occurred while installing selected Windows SDK components. Installation of the "Microsoft Windows SDK for Windows 7 Compilers for x86" product has reported the following error: Fatal error during installation. Please attempt to resolve the problem and then start Windows SDK setup again. If you continue to have problems with this issue, please visit the SDK team support page at http://go.microsoft.com/fwlink/?LinkId=130245.
That support page was not helpful.
Eventually, I found that an update to restore Visual C++ compilers and libraries was available from Microsoft, and this seems to be how to fix the problem.
A key error during the attempt to install the Visual C++ compilers, as an option of WinSDK 7.1 seems to be: “Product: Microsoft Visual C++ Compilers 2010 Standard - enu - x86 -- A later version of Microsoft Visual C++ Compilers 2010 Standard - enu - x86 is already installed.”
Here’s my solution to this problem.
Install the update to restore the Visual C++ compilers. “Install this update to restore the Visual C++ compilers and libraries that may have been removed when Visual Studio 2010 Service Pack 1 (SP1) was installed. The compilers and libraries are part of the Microsoft Windows Software Development Kit for Windows 7 and the .NET Framework 4 (later referred to as the Windows SDK 7.1).” (<http://www.microsoft.com/en-ie/download/details.aspx?id=4422>)
Download Summary: 1. VC-Compiler-KB2519277.exe 2. readme.htm
INSTALLING THIS UPDATE (VC-Compiler-KB2519277) FIXED THE PROBLEM. Now, Matlab mex -setup finds a valid C++ compiler, and mex files (.mexw64) can be built, after fixing one more error…
(2) Error linking - Also, I had to edit the mexopts.bat file (found in e.g. C:\Users\username\AppData\Roaming\MathWorks\MATLAB\R2012a), to change the path of the SDK:
Edited mexopts.bat, and changed from:
set LINKERDIR=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1\
to:
set LINKERDIR=C:\Program Files\Microsoft SDKs\Windows\v7.1\
Then, mex found the appropriate libs for linking, and I was able to create mex files from C code.
I hope this helps to save you some time if you encounter these problems. Good luck.

Réponses (1)

George
George le 10 Déc 2014
Modifié(e) : George le 10 Déc 2014
Install the update to restore the Visual C++ compilers.
Edit the path to linked libraries in the mexopts.bat file.
(See details in the original question).

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by