I cannot change default C++ compiler.

21 visualizaciones (últimos 30 días)
Tomislav  Bacek
Tomislav Bacek el 8 de Jun. de 2017
Editada: Cem Dogan el 11 de Jun. de 2021
Hi all,
I have installed Microsoft Visual Studio Professional 2015 on Win10 64bit, and Matlab 2015b.
I am using Simulink to compile my models, and then run them in TwinCAT environment.
However, I am having troubles compiling Simulink model. I got to know that VS 2015 does not come with C++ compilers pre-installed, so I installed them. To use TwinCAT, I need to compile in C++.
Writing mex -setup in c and mex -setup cpp in Matlab, I get the following: MEX configured to use 'Microsoft Visual C++ 2015 Professional' for (C) C++ language compilation. 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...
When I run SetupTwinCatTarget.p, I get the following: ################################################################### ########### TwinCAT TE1400 1.2.1229.0 Setup ####################### TwinCAT TE1400 paths were added successfully. TwinCAT TE1400 uses "Microsoft Visual C++" compilers to build TwinCAT modules from generated code. It is recommended to use a "Microsoft Visual C++" compiler also for mex builds. mex was configured to use the compiler "Microsoft Visual C++ 2015 Professional".
However, when I try to build my Simulink model, I keep getting the following error: Warning: Code generation report creation failed due to missing description file The specified code generation target is configured to generate C++, but the C-only compiler, LCC, is the default compiler. To allow code generation, you can deselect the 'Generate makefile' option. To generate C code, open the Configuration Parameters dialog and set the target language to C. Or, to specify a C++ compiler, enter 'mex -setup' at the command prompt.
I do not understand why Simulink wants to use LCC.
Thanks a lot!
Regards, Tomislav
  1 comentario
Cem Dogan
Cem Dogan el 11 de Jun. de 2021
Editada: Cem Dogan el 11 de Jun. de 2021
Hi,
I had the same problem and want to comment my solution here as this post is not answered yet.
First of all, you need to check your Matlab versions compatible compiler https://www.mathworks.com/support/requirements/previous-releases.html. As it is stated, Matlab 2015b doesn't support VS2015. To solve your problem, you need to setup VS2013 or you need to update your Matlab version from 2015b to 2016b.
Besides, if you want to run your simulink model in x64 operating system. You need to do more work. There is a thing called Test signing to generate x64 files for TwinCAT TE1400 Target for Simulink.
1) Before running Visual studio setup, Run it as an administrator.
2) While in setup progress, choose custom setup and check Visual C++ box.
3) For x64 system, you have to use Twincat 4024.0 or newer version.
4) Setup the TwinCAT on Visual Studio not independent from VS.
5) Install TE1400 Target for Simulink and Link the toolbox to the Matlab. For linking toolbox, check the below pdf's page 10.
6) Run 'Developer Command Prompt for VS2015 ' as an admin and paste 'makecert -r -pe -ss PrivateCertStore -n CN=MyTestSigningCert MyTestSigningCert.cer'.
7) Go to windows environment variables, add new System Variable , set variable name: TWINCATTESTCERTIFICATE, set variable value MyTestSigningCert.
8) Restart computer, Open the bios. In security, disable the Secure Mode. Save and exit.
9) Run the command window (cmd) as an administrator and paste 'bcdedit /set testsigning yes'.
10) Restart the computer and try to build x64 Simulink file.
For further knowledge, check https://download.beckhoff.com/download/Document/automation/twincat3/TE1400_TC3_Target_Matlab_EN.pdf

Iniciar sesión para comentar.

Respuestas (4)

Tuncay  ÖLÇER
Tuncay ÖLÇER el 11 de Jul. de 2018
I have also got exactly the same problem. Is there any solution suggestion to this problem? Thanks in advance for your efforts.

Manuel
Manuel el 10 de Oct. de 2018
I have the same issue. I also tried to use the MinGW64 Compiler C++. "mex -setup cpp" tells me that the correct compiler is used, but I get the same error message as the author.

Joachim Vonzitzewitz
Joachim Vonzitzewitz el 23 de Mayo de 2019
Did anyone figure out a solution to this problem?

RMH
RMH el 28 de Mayo de 2019
Editada: RMH el 28 de Mayo de 2019
Only suggestion I found that worked was to manually select the toolchain used, before clicking "Generate" in MATLAB Coder. I installed matlab's free MinGW-w64 and got it working that way, but letting it automaticallly locate a toolchain failed with same error message as author.

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by