I got the answer. The MATLAB version should match MCR version. So, in order to work with MCR 717, I have to build the MATLAB function using MATLAB 2012a. This solves the problem
Could not initialize the library properly
6 vues (au cours des 30 derniers jours)
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
0 commentaires
Réponses (2)
Image Analyst
le 8 Sep 2013
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
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!