Arritmic February 2016

Read Mat Files in C++ in a Qt project

I am trying to read a mat-file in an own mat_file_read.cpp in a Qt project, and I am having problems. My error:

error lnk2019: unresolved external symbol matOpen referenced in function "int __cdecl read_mat_file(class QString)" (?read_mat_file@@YAHVQString@@@Z)"

In my project.pro, I am including:

INCLUDEPATH += C:\Program Files\MATLAB\MATLAB Production Server\R2015a\extern\include\
LIBS += -LC:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64
        -llibmx
        -llibmat
        -llibeng

In the header of my cpp file:

#include <stdio.h>
#include <stdlib.h>
#include "mat.h"
#include "matrix.h"
#include <QString>
#include <QFileDialog>

In my mat_file_reader.cpp:

#include "read_mat_file.h"
int read_mat_file(QString file)
{

    // Variable definition
    int result;
    MATFile *pmat;

    if (file.isEmpty()) return 0;
    QByteArray ba = file.toLatin1();
    const char *rootFile = ba.data();
    pmat = matOpen(rootFile,"r");

    result = 0;

  return (result==0)?EXIT_SUCCESS:EXIT_FAILURE;

}

And the curious thing is the Qt editor is recognizing the functions from "mat.h". It is suggesting me the functions....

Thanks so much in advance.

Answers


Arritmic February 2016

Finally I found a solution, although I don't understand fine why.... I only changed the next lines in my project.pro of Qt:

INCLUDEPATH += C:\Program Files\MATLAB\MATLAB Production Server\R2015a\extern\include\
LIBS += -llibmx -LC:\librerias\matlab\extern\lib\win64\microsoft
LIBS += -llibmat -LC:\librerias\matlab\extern\lib\win64\microsoft
LIBS += -llibeng -LC:\librerias\matlab\extern\lib\win64\microsoft

Now it is working.... It's strange I think, but for me It's ok. :)

Thanks so much @Suever for the support.

Post Status

Asked in February 2016
Viewed 2,927 times
Voted 9
Answered 1 times

Search




Leave an answer