I am trying to read a MATLAB formatted data file (data.mat) file in C++. I referred to the following post "Link mat.h in a C++ file" and tried the given example code.
using namespace std;
int main() {
MATFile *pmat;
pmat = matOpen("data.mat","r");
return 0;
}
From the answer to the post, I ran the example code using the following command,
Command:
g++ main.cpp -o out -I/Applications/MATLAB_R2019a.app/extern/include -L/Applications/MATLAB_R2019a.app/extern/lib -lmat
Output:
ld: library not found for -lmat
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In order to fix this, I copied 'mat.h', 'matrix.h' and 'tmwtypes.h'
to the code directory. But, now when I am running the code, I am getting a different error and I am not able to find any solution for this.
Command:
g++ main.cpp -o out
Output:
Undefined symbols for architecture x86_64:
"_matOpen_800", referenced from:
_main in main-d0f06c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can someone please help me with this. I am using Mac OS Mojave. Thank you.