在項目的.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; }