QT调用第三方dll (Lib方式)

在项目的.pro文件中,增加一句

LIBS += -L"D:/qtsrc/myproject" -lmydll

在.cpp文件中,声明mydll.dll里面导出的函数:

extern "C"
{
    int add(int a,int b);
    int subtract(int x,int y);   
}

然后就可以调用了:

#include <QDebug>
void foo()
{
     int result1 = add(3,8);
     int result2 = subtract(100,22);

     qDebug()<<"result1="<<result1
                  <<"result2="<<result2
                  <<endl;

}

 

posted @ 2019-06-12 13:14  长老猪  阅读(3694)  评论(0编辑  收藏  举报