Error Initializing MCR: CTF file...Could not open source package?

42 ビュー (過去 30 日間)
Paul
Paul 2014 年 3 月 4 日
編集済み: Paul 2014 年 3 月 7 日
The full message I got from running my application executable is:
Error Initializing MCR: CTF file 'C:\Users\..\AppData\Local\Temp\mathworks_tmp_4916_32418' failed to open for 'Read' access. Error message: Could not open source package'
I am using MatLab 2013b (8.2.701) 64bit, MCR version 8 to compile a simple matlab file into a C shared library. The command I supplied was mcc -B csharedlib:libmatrix solution.m which Matlab then generated these files:
libmatrix.c, libmatrix.lib, libmatrix.dll, libmatrix.h, and libmatrix.exp libmatrix.export
In my Visual Studio C++ project (platform set to x64, Windows7.1 SDK), I made sure to have include, lib, and dll directories setup properly so everything seemed OK during compilation.
Here's the partial code from my .c file:
#include "libmatrix.h"
mclmcrInitialize();
if( !mclInitializeApplication(NULL,0) ) {
fprintf(stderr, "Could not initialize the application.\n");
return -1;
}
if (!libmatrixInitialize()){
fprintf(stderr,"Could not initialize the library.\n");
printf("the error msg: %s\n", mclGetLastErrorMessage());
return -2;
}
mlfSolution(2, &MX, &MD, MI, MJ, MS, MINFO, MY, MLB, MUB);
libmatrixTerminate();
mclTerminateApplication();
I have no clue why it's not working, any help will be greatly appreciated.

採用された回答

Friedrich
Friedrich 2014 年 3 月 5 日
Hi,
This happens when you include the MATLAB compiler generated C/C++ source files (LIBNAME.c or LIBNAME.cpp) into your project. When your call for initializing the DLL is made it calls the function from the C/C++ source file instead of the one in the DLL. So then it looks for the CTF in the EXE (where it's actually not) instead of in the DLL.
So long story short: Do not include the .c/.cpp files generated by MATLAB Compiler into your project. Only the header file and .lib file is needed.
  2 件のコメント
Paul
Paul 2014 年 3 月 6 日
Hi Friedrich, thanks for looking into my problem. I removed the C/C++ source file, but then I got this error "The procedure entry point mlfSolution could not be located in the dynamic link library libmatrix.dll."
What am I missing here?
Paul
Paul 2014 年 3 月 7 日
編集済み: Paul 2014 年 3 月 7 日
Okay, it turned out that I was linking an older version of the dll. Replaced it with an updated one, and everything works. Thanks again for the solution, Friedrich.

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

その他の回答 (3 件)

Paul
Paul 2014 年 3 月 4 日
So no one knows anything about this type of error? Is this error uncommon or am I providing too little information? Any input will be greatly appreciated.

Image Analyst
Image Analyst 2014 年 3 月 4 日
I've never heard of that one. If you've exhausted the things to try on the FAQ then you'll have to call them.
  1 件のコメント
Paul
Paul 2014 年 3 月 5 日
Thanks Image for pointing out that FAQ article. I didn't know this problem is uncommon...

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


Paul
Paul 2014 年 3 月 5 日
Not sure if this has to do with my Matlab command to generate the C shared Library. Anyone has any thought?

カテゴリ

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