我试图让matlab引擎参与QT创建器。我确信我已经在.pro文件中正确设置了INCLUDEPATH和LIBS,因为没有语法或链接问题。我加了未能通过Matlab调用Matlab从QT开始
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 <QDebug>
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;
}
每次我尝试在调试运行代码或发布模式,QT说
开始d:\ QT项目\集结VisVehicle-Qt_5_5_0- Release \ release \ VisVehicle.exe ... 程序意外完成。 D:\ qt projects \ build-VisVehicle-Qt_5_5_0-Release \ release \ VisVehicle.exe崩溃。
通过评论代码,我发现它是导致失败的ep = engOpen(NULL)。 我在Windows 7上使用32位的Matlab R2015a,QT 5.5.0。我总是以管理员身份运行Matlab和QT。我也尝试在cmd中运行matlab -regserver,并且弹出了一个简化的Matlab命令行窗口。但QT程序仍然崩溃。每当我修改代码或环境时,我都会仔细清理并重建该程序,以避免潜在的构建问题。
如果有人给我一些关于这个问题的想法,我将非常感激。