Library could not initialize properly
2 次查看(过去 30 天)
显示 更早的评论
I am trying to execute a library in C++ that has been generated from the Library Compiler but the generated library does not want initialize properly.
I am following what is described in Generate a C++ mwArray API Shared Library and Build a C++ Application however my code gets stuck when trying to initialize my library.
I thought it came from the arguments of the function so I made a wrapper which removed the arguments but got the same problem.
The Matlab Runtime initializes properly but the library does not.
My code looks like that:
// Initialize Matlab runtime
if (!mclInitializeApplication(nullptr, 0))
{
std::cerr << "Could not initialize the application." << std::endl;
return -1;
}
// Initialize custom library
if (!MyFunctionWrapperInitialize())
{
std::cout << "Could not initialize the library properly\n";
}
// try to run function
try
{
MyFunctionWrapper();
// Call the application and library termination routine
MyFunctionWrapperTerminate();
}
// Catch the errors
catch (const mwException& e)
{
std::cout << e.what() << "\n";
}
catch (...)
{
std::cout << "Unexpected error thrown\n";
}
std::cout << "Myfunction ended\n";
// Terminate all Matlab Runtime instances
mclTerminateApplication();
This code returns in the console:
Could not initialize the library properly
Invalid input: Null runtime instance.
MyFunctionWrapper ended
I don't think I have the problem described here of the version conflict between the MCR and the Matlab version because the Matlab version of the computer on which the library has been compiled is MATLAB Version: 9.12.0.1975300 (R2022a) Update 3 and the MCR version on my computer is v912 as well.
If anyone knows where this problem comes from, thank you in advance.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 C Shared Library Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!