MCR issue at initialization
32 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm facing a weird issue. My Application can use MATLAB code embedded in plugin DLL. I've generated C++ shared dll using MATLAB Compiler 4.18. Two months ago everything went fine, the Matlab generated dll was used by another dll which is a wrapper for my application written in C++.
Now I want to build another MATLAB dll and wrap it the same way, but the libInitialize() call fails.
Here is part of the code doing initializations :
// in the wrapper DLL a constructor is initializing the MATLAB part
MyDll::MyDll()
{
mclmcrInitialize();
if (mclInitializeApplication(NULL, 0))
if (myLibInitialize())
...
}
When debugging i've found that the crash is here:
bool myLibInitializeWithHandlers(
mclOutputHandlerFcn error_handler,
mclOutputHandlerFcn print_handler)
{
int bResult = 0;
if (_mcr_inst != NULL)
return true;
if (!mclmcrInitialize())
return false;
if (!GetModuleFileName(GetModuleHandle("myLib"), path_to_dll, _MAX_PATH))
return false;
{
mclCtfStream ctfStream =
mclGetEmbeddedCtfStream(path_to_dll);
if (ctfStream) {
bResult = mclInitializeComponentInstanceEmbedded( &_mcr_inst,
error_handler,
print_handler,
ctfStream);
mclDestroyStream(ctfStream);
} else {
bResult = 0;
}
}
if (!bResult)
return false;
return true;
}
Crash in mclInitializeComponentInstanceEmbedded which i can't debug trace since it's part of MCR. I've noticed, though, that _mcr_inst pointer is always NULL. Is it the source of the issue?
I've lost my mind since the same code worked perfectly two months ago on my PC. I changed nothing, MATLAB is still 2012b, Matlab Compiler 4.18 and MCR installed on my Windows 7 64bit.
I guess the issue is linked to CTF acces problem. I tried to build my Matlab C++ DLL with no ctf embedded, same result.
I tried with simple matlab code in one .m file, same result.
Any suggestions appreciated.
Bruno
0 Kommentare
Antworten (2)
Tao Cui
am 15 Dez. 2017
not sure if your problem was solved since this is an old post. I have encountered same issue and this post solved my problem: https://stackoverflow.com/questions/18512801/call-matlab-dll-from-c-fail-to-initialize-the-library
Simple solution: do not include Matlab generated CPP files into your project, just use the header and the lib.
0 Kommentare
Jerome Mai
am 6 Apr. 2022
You need to delete the mcrCache folder to get it working again.
Run this in Matlab to find out the folder path:
mcrcachedir
It may be something like:
C:\Users\<user>\AppData\Local\Temp\<user>\mcrCache*.*\
0 Kommentare
Siehe auch
Kategorien
Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!