我正在尝试将matlab引擎包含在QT创建器中。我确信我已经在.pro文件中正确设置了INCLUDEPATH和LIBS,因为没有语法或链接问题。我补充说
D:\Program Files\Matlab32\bin;
D:\Program Files\Matlab32\runtime\win32;
D:\Program Files\Matlab32\bin\win32到我的路径。
在我写的mainwindow.cpp中
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "engine.h"
#include
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug() << "Trying to open the engine";
Engine *ep;
ep = engOpen(NULL);
engClose(ep);
}
MainWindow::~MainWindow()
{
delete ui;
}每次我尝试在Debug或Release模式下运行代码时,QT都会这样说
Starting D:\qt projects\build-VisVehicle-Qt_5_5_0-Release\release\VisVehicle.exe...
The program has unexpectedly finished.
D:\qt projects\build-VisVehicle-Qt_5_5_0-Release\release\VisVehicle.exe crashed.
通过评论代码,我发现它是导致失败的ep = engOpen(NULL)。
我在Windows 7上使用32位的Matlab R2015a,QT 5.5.0。我总是以管理员身份运行Matlab和QT。我也尝试在cmd中运行matlab -regserver,并且弹出了一个简化的Matlab命令行窗口。但QT程序仍然崩溃。每当我修改代码或环境时,我都会仔细清理并重建该程序,以避免潜在的构建问题。
如果有人给我一些关于这个问题的想法,我会非常感激。