qt matlab dll文件,qt调用matlab生成的dll

qt调用matlab生成的dll

我现在在做毕业设计,要做一个软件界面,里面有一个函数是用matlab语言写的,我已经可以再vs2010上调用matlab生成的dll了,但是Qt上没办法成功调用。希望大神指导下,谢谢!下面是我的代码

项目里面的代码:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = startButton

TEMPLATE = app

SOURCES += main.cpp\

widget.cpp

HEADERS  += widget.h \

spot_simulationdll.h \

libspot_simulation.h

FORMS    += widget.ui

OTHER_FILES +=

spot_simulationdll.lib

spot_simulationdll.dll

libspot_simulation.lib

libspot_simulation.dll

INCLUDEPATH += H:/matlab2011/extern/include

INCLUDEPATH += H:/matlab2011/extern/include/win32

LIBS+=-L H:/matlab2011/extern/lib/win32/microsoft -l libmx

LIBS+=-L H:/matlab2011/extern/lib/win32/microsoft -lmclmcrrt

LIBS+=-L H:/matlab2011/extern/lib/win32/microsoft -l mclmcr

cpp里面的代码:

#include "widget.h"

#include "ui_widget.h"

#include

#include

#include

#include

#include

#include

#include

#include "spot_simulationdll.h"

Widget::Widget(QWidget *parent) :

QWidget(parent),

ui(new Ui::Widget)

{

startButton =new QPushButton(tr("start"));

connect(startButton,SIGNAL(clicked()),this,SLOT(startButtonSlots()));

QVBoxLayout *layout = new QVBoxLayout;

layout->addWidget(startButton);

setLayout(layout);

}

Widget::~Widget()

{

delete ui;

}

typedef void (*Fun)(void); //定义函数指针,以备调用

typedef bool (*Fun2)(void);

typedef bool (*Fun3)(void);

void Widget::startButtonSlots()

{

QLibrary lib("myfuncdll.dll");

QMessageBox msg;

if(lib.load())

{

QMessageBox::information(NULL,"OK","DLL load is OK!");

Fun open=(Fun)lib.resolve("_spot_simulation"); //援引 _mlfMyFunc() 函数

Fun2 init=(Fun2)lib.resolve("_spot_simulationdllInitialize");//援引 _myfuncdllInitialize() 函数

Fun2 termi=(Fun3)lib.resolve("_spot_simulationTerminate");//援引 _myfuncdllTerminate() 函数

if (open) //是否成功连接上 add() 函数

{

QMessageBox::information(NULL,"OK","Link to Function is OK!");

init(); //库初始化

//double _x[5] = {1, 2, 3, 4, 5}; //输入数组

// double _y[5]; //输出数组

//  mxArray* x = mxCreateDoubleMatrix(1, 5, mxREAL);//创建1*5矩阵

//  memcpy(mxGetPr(x), (void*)_x, sizeof(_x)); //拷贝输入数据

//  mxArray* y = mxCreateDoubleMatrix(1, 5, mxREAL);//创建1*5矩阵

open();

//  memcpy(_y, mxGetPr(y), sizeof(_y));//拷贝输出数据

//  QString song=QString::number(_y[1]);

//  QMessageBox::information(NULL,"OK",song);

termi();//结束DLL库

}

else

QMessageBox::information(NULL,"NO","Linke to Function is not OK!!!!");

}

else

QMessageBox::information(NULL,"NO","DLL is not loaded!");

}

出现的错误:

cannot find -lmclmcrrt

错误:cannot find H:/matlab2011/extern/lib/win32/microsoft: Permission denied

错误:cannot find -lmclmcr

错误:error: ld returned 1 exit status

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值