generateAudioPlugin error - MEX configured to use visual studio c++ 2019, but LCC is the default compiler

OS: Windows 10 Home
As the thread title indicates, when I attempt to generate an audio plugin (after running mex -setup to configure MEX to use visual studio c++ 2019 and validateAudioPlugin) this appears on the console:
>> mex -setup
MEX configured to use 'Microsoft Visual C++ 2019 (C)' for C language compilation.
To choose a different language, select one from the following:
mex -setup C++
mex -setup FORTRAN
MEX configured to use 'Microsoft Visual C++ 2019' for C++ language compilation.
>> validateAudioPlugin('TremoloProj6')
Checking plugin class 'TremoloProj6'... passed.
Generating testbench file 'testbench_TremoloProj6.m'... done.
Running testbench... passed.
Generating mex file 'testbench_TremoloProj6_mex.mexw64'... done.
Running mex testbench... passed.
Deleting testbench.
Ready to generate audio plugin.
>> generateAudioPlugin('TremoloProj6')
..Warning: Selected C compiler is incompatible with C99 (ISO) language standard. Code generation will switch to C89/90 (ANSI) instead. Consider changing C compiler or
target language setting to suppress this warning.
??? 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. Or, to specify a C++ compiler, enter 'mex -setup' at the command prompt. To generate C code, set the target language to C in
the configuration object.
Code generation failed: View Error Report
I've been searching for information on how to change the target language, but I have not been able to find anything that works when I use it.
Here's the code for the audio plugin I'm trying to generate:
classdef TremoloProj6 < audioPlugin
methods
function out = process(~,in)
out = in;
end
end
end

 Accepted Answer

I figured it out, I needed to use these two lines of code to set the target language to c++:
cfg = coder.config('lib');
cfg.TargetLang = 'C++';
This thread can be closed.

2 Comments

If I recall correctly, using that command made Matlab use Microsoft Visual C++ 2019 for C++ compilation, but Matlab still had the target language for compilation set to C, so it defaulted to the LCC compiler.

Sign in to comment.

More Answers (1)

I am having the same issue that you had, but your solution is not working. What else can you remember doing?

2 Comments

Unfortunately, I do not recall doing anything else, as I have not touched this project in years.
Do you have Visual Studio? Did you do "mex -setup C++" to select it?

Sign in to comment.

Categories

Find more on Code Generation and Deployment in Help Center and File Exchange

Products

Release

R2021a

Community Treasure Hunt

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

Start Hunting!