Matlab2016 and above set vs compiler

Source: Internet
Author: User
Tags versions visual studio
Matlab2016 and above set vs compilerThe use of MEX in MATLAB can be used to compile C + +, but first set up a compiler, you can use the Mex-setup command to set. If you have visual Studio installed on your computer, and then you install MATLAB, in general, simply enter mex-setup at the command line and follow the prompts to complete the compiler's settings.
However, if it is Visual Studio installed after the first installation of MATLAB, or for some other reason, it is likely that the Mex-setup command cannot find the installed Visual Studio compiler, then some modifications will be required to successfully set up the compiler.
Since MATLAB uses an XML file to save the configuration file from the 2016 release, the method may differ from this article if you are using MATLAB that is a previous version of 2016. (This article takes matlab2016a and visual Studio2012 as an example)
In the installation directory of MATLAB \bin\win64\mexopts directory has a variety of compiler configuration files, Matlab is dependent on these XML files and compilers to establish the association:

The XML file that corresponds to the compiler reads the compiler and SDK path information into the registry of the Windows system, because the Mex-setup command cannot find the compiler because of missing compiler and SDK path information in the registry.
For previous versions of Matlab2016, there are some STP and bat files in the \bin\win64\mexopts and mbuildopts directories, which also store path information for the SDK and different versions of the compiler.
To clear the Matlab2016 search compiler and SDK, use the MEX-SETUP-V command to see the search process (the following figure is the search process after the registry has been modified):

For example, in Visual studio2012, Matlab reads the installation path of the SDK and visual studio2012 primarily from the registry, and no information or information errors are present in the registry or environment variables. You can modify the registry and environment variables to suit your specific situation. This includes the following path information: Installation path for microsoft\visualstudio\sxs\vs7:visual Studio microsoft\visualstudio\sxs\vc7:visual The VC directory under the installation path of Studio Microsoft\microsoft sdks\windows\v8.0:microsoft SDKs v8.0 directory vs110comntools:visual The Common7\tools\ directory under the installation path of studio where Vs110comntools is an environment variable that can be modified or added in: My Computer--Properties--Advanced system settings--environment variables--System variables:

Win+r Open the Run window and enter the regedit command to open the Registry Editor:

In Registry Editor, HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE correspond to HKCU and HKLM in MATLAB, respectively:

Then add entries (subdirectories) and string values (to save the path) under the corresponding directory, such as the new "v8.0" item under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft sdks\windows\, Then create a new string value in the key, named "InstallationFolder" according to the instructions in the MATLAB search process, and fill in the value data, Microsoft SDKs is generally located in C:\Program Files (x86) \ Windows Kits Under


In turn, the search process where there is no correction, if the environment variable settings do not work, you need to restart the computer, and then mex-setup to complete the compiler settings.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.