Library could not initialize properly

9 次查看(过去 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 个)

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by