Matlab shared library is not initialized in release directory from Visual C++/CLI program
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have programmed a small application in Visual C++/CLI (Visual Studio 2012 Professional) in which I call a Matlab function. This Matlab function has been compiled to a C++ shared library by the Matlab Compiler R2012a. I'm working with Windows 7, 64 Bit, but my program and library are compiled for 32 Bit.
Up to now I always started the program in the debug mode directly from Visual C++ and everything worked fine, especially the calling of the Matlab function did not give any problems. But now I wanted to compile the program in release mode and tried to start it separately from Visual studio. In the beginning there were some problems with Matlab DLLs (could not be found), so I simply copied all DLLs to the release directory (there may be some better method). Now the program seems to start, but when it tries to load my Matlab library it stops without any message. Here is a small code snippet which shows how I load my Matlab library:
try {
MessageBox::Show("Before mclInitializeApplication");
// initialize MCR
if (!mclInitializeApplication(NULL,0)) {
MessageBox::Show("Can't initialize MCL");
this->~Form1();
} else {
MessageBox::Show("Before thermoMatlabLibInitialize");
if(!thermoMatlabLibInitialize()) {
MessageBox::Show("Could not initialize the thermoMatlab-library");
this->~Form1();
}
}
} catch (const mwException& e) {
MessageBox::Show("Caught mwException");
}
The first two success-MessageBoxes are displayed ("Before mclInitializeApplication" and "Before thermoMatlabLibInitialize") but then neither "Could not initialize the thermoMatlab-library" nor "Caught mwException" is shown. Furthermore, there is no system error from Windows about the application either. The file "thermoMatlabLib.dll" is also contained in the release directory.
Does anyone know why this happens? Why is the exception not caught? Is it the wrong exception type or is there no exception at all?
Thank you very much in advance! Oliver
4 commentaires
Kaustubha Govind
le 19 Sep 2013
The DLL file is loaded at run-time, so its location needs to be added to the system PATH environment variable.
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur C Shared Library Integration dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!