How can I use MATLAB Coder to create a library where I can call each function individually?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 23 Ago 2017
Risposto: MathWorks Support Team
il 24 Ago 2017
I have a "main" function I want to compile, and a number of supporting functions that also need compilation, as well, via Coder. The support functions are called by e/o, as well as by the main function.
For the sake of numeric unit testing, I need the resulting library/ies to allow access to each of the functions separately.
Risposta accettata
MathWorks Support Team
il 23 Ago 2017
First, disable function inlining to ensure every function has the code generated in a separate file. To accomplish this, please add the following to the first line in the function definition of every function:
coder.inline('never');
Now that every function will be generated in a separate file, the functions need to be each added to the library. The library will have have an entry for every function that is marked as an Entry-Point Function. To mark functions as such, please use the 'Add Entry-Point Function' button on the second page of the MATLAB Coder wizard, and generate the code again. Every function will now be generated in a separate file and will be callable through the library.
If you want to use the command line "codegen" instead, see the following example:
% Generate code and build a DLL
% In this example, there are three functions defined in separate files
% "main_function" takes no arguments, "support_1" takes a
% constant and "support_2" takes two constants
% The library will have entry points to all functions included
codegen -config:dll main_function support_1 -args {100} support_2 -args {1,5}
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Generating Code in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!