Using matOpen in Visual Studio 2012

조회 수: 3 (최근 30일)
Fabian Jonsson
Fabian Jonsson 2013년 12월 18일
I'm trying to include the libmat library to be able to read .mat files in C++, however I've not been able to link it properly eventhough I've set it up exactly the same way as I have other libraries. I've tried two different approaches, but both fail.
First of all, I've added the following links in the project preferences:
VC++ Directories > Library Directories: C:\MATLABR2011b_x86\extern\lib\win32\microsoft
VC++ Directories > Include Directories: C:\MATLABR2011b_x86\extern\include
C/C++ > Additional Include Directories: C:\MATLABR2011b_x86\extern\include
Linker > Input > Additional Dependecies: libmat.lib; libmx.lib; libmex.lib
And added the libmat.dll, libmex.dll and libmx.dll to the debug folder of the project.
--------------------------------------------------------------------------------
Method 1:
#include "mat.h"
MATFile* file = matOpen("examplefile.mat","r");
I then get the following error:
First-chance exception: Microsoft C++ exception: fl::i18n::MwLcDataNotFound
--------------------------------------------------------------------------------
Method 2:
#include "mat.h"
std::string DLLFilename = "libmat.dll";
HMODULE libHandle = LoadLibrary(DLLFilename.c_str());
// I can comment out the following lines and the error persists
MATFile *(*myMatOpen)(const char*, const char*);
myMatOpen = (MATFile*(*)(const char*, const char*))GetProcAddress(libHandle, "matOpen");
And I get the same error using this method.
What am I missing?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by