Could not initialize the library properly
Afficher commentaires plus anciens
I have a small MATLAB function "function a = addmatrix(a1,a2) a = a1+a2;". I've created a project, added the function file, built and generated the .h, .lib and .dll files. Then I've added them to a new visual studio project as files, added the library directory to the Additional Libraries Directories. Also, I did the setup of MCR and got a copy from the include and lib files in the extern folder and added them to the visual studio project and added the paths to the Additional Include Directories and Additional Libraries Directories. I added also the lib files in the MCR lib folder to the Additional Libraries. I got no syntax errors, but when I debug the application it always couldn't initialize the library and return false.
This is my code:
//--------------------------------------------------------------------
if (!mclInitializeApplication(NULL,0))
{
std::cerr << "Could not initialize the application properly."<< std::endl;
return;
}
// Initialize the test library
if(!libtestInitialize())
{
std::cerr << "Could not initialize the library properly."<< std::endl;
return;
}
double r1[] = {1,3,5,7};
double r2[] = {2,4,6,8};
mwArray mwA1(1, 4, mxDOUBLE_CLASS);
mwArray mwA2(1, 4, mxDOUBLE_CLASS);
mwA1.SetData(r1, 4);
mwA2.SetData(r2, 4);
int nargout = 1;
mwArray mwA;
addmatrix(nargout,mwA,mwA1,mwA2);
double* o = new double[4];
mwA.GetData(o,4);
delete []o;
mclTerminateApplication();
libtestTerminate();
//-----------------------------------------------------------------
I cannot figure out where the problem. Is it in the lib or in the settings and properties of the project, or in the code.
I'm using MATLAB 2010a x86 with MCR 717 and Microsoft Visual Studio 2008 under windows 8 32-bit.
I appreciate your help.
Thanks
Réponses (2)
Ali Mustafa
le 8 Sep 2013
0 votes
Image Analyst
le 8 Sep 2013
0 votes
Look at the first item in this list from the FAQ's Compiler section: http://matlab.wikia.com/wiki/FAQ#My_standalone_executable_won.27t_run_on_the_target_computer._What_can_I_try.3F
1 commentaire
Ali Mustafa
le 8 Sep 2013
Catégories
En savoir plus sur C Shared Library Integration dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!