How can I add additional linker flags to the generated makefile?
8 views (last 30 days)
Show older comments
MathWorks Support Team
on 13 Dec 2013
Edited: MathWorks Support Team
on 2 Jul 2020
I am generating C/C++ code from a Simulink model using Simulink Coder or Embedded Coder.
When I try to compile the generated code by running the .bat file, I get a linking error complaining about a conflict between LIBCMT and MSVCRT, with a suggestion to add the /NODEFAULTLIB:libname option to the linker flags.
I have found that adding this option to the ADDITIONAL_LDFLAGS field of the generated .mk file solves the issue. How can this option be automatically added to the generated makefile?
Accepted Answer
MathWorks Support Team
on 2 Jul 2020
Edited: MathWorks Support Team
on 2 Jul 2020
You can add link options to the model build information by using the "addlinkflags" function. To learn more, see the following documentation page:
To add the additional linker flags to the makefile, follow below steps:
1) Create a MATLAB function setBuildArgs.m with the following code inside:
function setBuildArgs(buildInfo)
linkFlags={'/NODEFAULTLIB:libname'};
addLinkFlags(buildInfo,linkFlags);
2) Open the model you want to generate code from, execute the following command:
>> set_param(gcs,'PostCodeGenCommand','setBuildArgs(buildInfo)');
3) Generate code and check the .mk file. The flag /NODEFAULTLIB:libname should now appear in the ADDITIONAL_LDFLAGS field.
0 Comments
More Answers (0)
See Also
Categories
Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!