有偿求助,生成DLL并调用~
新手,需要写一些统计算法,牵扯到生成DLL并调用问题。在TestDll.c中定义了如下3个函数
程序代码:
//Statement and Copyright
__declspec(dllexport) int addint(int a, int b){
int c;
c = a + b;
return c;
}
__declspec(dllexport) float addfloat(float a, float b){
float c;
c = a + b;
return c;
}
__declspec(dllexport) double adddouble(double a, double b){
double c;
c = a + b;
return c;
}
在Test.c中调用
程序代码:
int main(){
int a = 5, b = 3;
int c = addint(a, b);
float d = 5, e = 3;
float f = addfloat(d, e);
double g = 5, h = 3;
double i = adddouble(g, h);
printf("%d %d %d",c,f,i);
}
使用MingGW生成dll并调用
gcc -shared -o TestDll.dll TestDll.c -Wl,--add-stdcall-alias
gcc -o Test Test.c -L./ -lTestDll
结果中整数相加为正确
float和double相加为一个非常长的字符串
求教,有偿,请联系微信: ColinO







