Showing results for 
Show  only  | Search instead for 
Did you mean: 
Registered: ‎05-20-2014

Using a library and setting compiler commands

Hello all,

I'd like to read .mat files (created with Matlab) for my test bench. Mathworks provides a C/C++ header file mat.h in combination with a library file for this purpose. The library file requires additional compiler commands which I am unable to configure in Vivado HLS in a way that works. Maybe somebody can help me out with this?

According to this Mathworks site I need to include mat.h and libmat.dll in two different folders in the matlab installation path.


Examples for valid compiler settings I found on stackoverflow (Mathwork doesn't seem to provide any) are:

cc -I/usr/local/MATLAB/R2011a/extern/include/ -L/usr/local/MATLAB/R2011a/bin/glnxa64 animate_shot.c -o animate_shot -lmat -lmx
g++ program.cpp -I/usr/local/MATLAB/R2012a/extern/include -L/usr/local/MATLAB/R2012a/bin/glnxa64 -L/usr/local/MATLAB/R2012a/extern/lib -lmat -o program

So basically I have to add the header (-I), the library (-L) and the name of the library (-l).


I went to Properties after right clicking my main project in the HLS Explorer and configured it as you can see in the following screenshots:





Alas I still receive these errors:


C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:10: undefined reference to `matOpen'
C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:14: undefined reference to `matGetVariable'
C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:15: undefined reference to `mxIsDouble'
C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:15: undefined reference to `mxIsEmpty'
C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:17: undefined reference to `mxGetNumberOfElements'
C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:18: undefined reference to `mxGetPr'
C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:26: undefined reference to `mxDestroyArray'
C:\Users\readMatTest\readMatTest\solution1\csim\build/../../../../testbench.cpp:27: undefined reference to `matClose'

where line 10 in testbench.cpp is for example:

 MATFile *pmat = matOpen(file, "r");

What could be the cause for this?


(I would provide the project files, but I don't think I can share the mathworks files for copyright reasons)


0 Kudos
1 Reply
Registered: ‎06-24-2015



Did you try including the mat.h additionally in the HLS project?

Google your question before posting. If someone's post answers your question, mark the post as answer with "Accept as solution". If you see a particularly good and informative post, consider giving it Kudos (click on the 'thumbs-up' button).
0 Kudos