what is difference between C static library and executables generated from matlab code using matlab coder?

14 views (last 30 days)
during code generation there is an option saying you want to generate C/C++ static libraries or executables?
i want to know the difference between them and which of them is suitable choice for code deployment on c6713?
how to write main function and is it required in both static library and executables?
thank you.

Answers (1)

Ryan Livingston
Ryan Livingston on 2 Apr 2014
You would likely want to generate a static library if you intend to utilize your generated code as a piece of a larger application on your C6713. In this case, you would likely be writing some other C code by hand or already have some code which will be run on the hardware and want to leverage your MATLAB code in that larger application. A static library does not require a main function. You would rather link it with your other code and call the generated functions from that code.
An executable is just that, a complete executable which can be run on its own. You would likely want to use this if you have the entirety of your application written in MATLAB and want to run the whole thing on your hardware. Creating an executable requires writing and supplying a main function as that main function is how the operating system knows to run the executable.
  2 Comments
Ryan Livingston
Ryan Livingston on 3 Apr 2014
Generally a main function is a function which has the signature:
int main (int argc, char *argv[])
where argc is the number of command-line arguments and argv is an array of strings representing those arguments.
Inside that main function, you would call the functions generated by MATLAB Coder. Examples of writing such a main and providing it to MATLAB Coder are available at:

Sign in to comment.

Categories

Find more on Build Configuration in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!