mingw下编译生成的dll如何在vc6.0中调用?
用mingw写了一个简单的dll,但是在vc6.0中却无法调用!
这是头文件
#ifndef MATHOPERATOR_H_
#define MATHOPERATOR_H_
class MathOperator
{
public:
MathOperator();
~MathOperator();
int add(int m,int n);
int sub(int m,int n);
};
#endif /*MATHOPERATOR_H_*/
下面是导出的文件: DllTest.dll
EXPORTS
_ZN12MathOperator3addEii @1
_ZN12MathOperator3subEii @2
_ZN12MathOperatorC1Ev @3
_ZN12MathOperatorC2Ev @4
_ZN12MathOperatorD1Ev @5
_ZN12MathOperatorD2Ev @6
用vc的lib工具生成了在vc中的引用库DllTest.lib
然后在vc下使用,出现如下问题
#include <iostream>
#include "MathOperator.h"
using namespace std;
int main()
{
int m=5;
int n=10;
int addres;
addres=0;
cout<<"before :add result is "<<addres<<endl;
int subres=0;
MathOperator mop;
addres=mop.add(m,n);
subres=mop.sub(m,n);
cout<<"add result is "<<addres<<endl;
cout<<"sub result is "<<subres<<endl;
return 0;
}
"public: int __thiscall MathOperator::add(int,int)" (?add@MathOperator@@QAEHHH@Z)"
对于c++文件,是不是这两个函数的命名规则不一样啊,导致的不能使用? 如何修改才可以啊?
我尝试了下修改Dlltest.dll的导出文件DllTest.def 中的定义将
?add@MathOperator@@QAEHHH@Z)=_ZN12MathOperator3addEii @1
然后用lib工具
lib /machine:i386 /def:DllTest.def 生成DllTest.lib引用库,连接时没问题,可是运行时又有问题了?
请教各位大侠们,该如何解决,thank you!