我試圖讓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程序仍然崩潰。每當我修改代碼或環境時,我都會仔細清理並重建該程序,以避免潛在的構建問題。
如果有人給我一些關於這個問題的想法,我將非常感激。