Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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;
}
mclRunMain((mclMainFcnType)run_main,0,NULL);
/* Call the library termination routine */
libmatrixTerminate();
/* Note that you should call mclTerminate application at the end of
* your application.
*/
mclTerminateApplication();
}

回答(0 个)

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by