问题描述
我想在一个自己的mat_file_read.cpp在一个Qt项目中读取一个mat文件,我有问题。我的错误:
错误lnk2019:未解析的外部符号matOpen在函数int __cdecl read_mat_file(class QString)(?read_mat_file @ @YAHVQString @@@ Z)
在我的project.pro中,我包括:
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
在我的cpp文件的标题中:
#include< stdio.h>
#include< stdlib.h>
#includemat.h
#includematrix.h
#include< QString>
#include< QFileDialog>
在我的mat_file_reader.cpp:
#includeread_mat_file.h
int read_mat_file(QString file)
{
//变量定义
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;
}
奇怪的是,Qt编辑器正在识别函数从mat.h。
最后我找到一个解决方案,虽然我不明白为什么....我只改变了我的project.pro的Qt的下一行:
INCLUDEPATH + = C:\Program Files\MATLAB\MATLAB生产服务器\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
现在它工作....这很奇怪,我想,但对我来说没关系。 :)
感谢@Suever的支持。
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.
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.
这篇关于在Qt项目中阅读C ++中的Mat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!