Matlab shared library is not initialized in release directory from Visual C++/CLI program

7 ビュー (過去 30 日間)
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 件のコメント
Kaustubha Govind
Kaustubha Govind 2013 年 9 月 19 日
The DLL file is loaded at run-time, so its location needs to be added to the system PATH environment variable.
Oliver
Oliver 2013 年 9 月 19 日
I tried this, but it doesn't work either ... do you have any further ideas? Thanks for helping me!

サインインしてコメントする。

採用された回答

Oliver
Oliver 2013 年 9 月 20 日
Ok, I did the setup of the whole Visual project once again from scratch and for some reasons it works now ... why ever. Thanks though.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeC Shared Library Integration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by