MATLAB Answers


Why does mclrunmain segfault when i call libmatixTerminate outside of mclrunmain?

Asked by Eric Jackowski on 16 Jan 2019
I'm a digitial designer that needs to break up the matlab compiler output into seperate functions so i can call them via DPI from my SystemVerilog code.
I took your matrixdriver example from teh compilersdk directory and got that working.
Then I split out all the init and terminate functions from the run_main and place them around the call to mclrunmain, see code at the end for modified main file.
This is how i want to call it in my SystemVerilog.
When I do this the application crashes.
If i move all the init and termintates back into the run_main, ti works fine.
Everything i see about mclrunmain says it doesn't matter when running on Linux.
So I removed the mclrunmain call it works fine.
What features if any am I missing out on if i don't use the mclrunmain function and why do the init and terminates need to be inside it?
int main()
/* Call the mclInitializeApplication routine. Make sure that the application
* was initialized properly by checking the return status. This initialization
* has to be done before calling any MATLAB API's or MATLAB Compiler generated
* shared library functions. */
if( !mclInitializeApplication(NULL,0) )
fprintf(stderr, "Could not initialize the application.\n");
return -1;
/* Call the library intialization routine and make sure that the
* library was initialized properly. */
if (!libmatrixInitialize()){
fprintf(stderr,"Could not initialize the library.\n");
return -2;
/* Call the library termination routine */
/* Note that you should call mclTerminate application at the end of
* your application.


Sign in to comment.




0 Answers