在vc++6.0中自己敲键盘输入的下面的程序,编译后生成dll文件老是出现如下的提示:
--------------------Configuration: user14 - Win32 Debug--------------------
Compiling...
user14.cpp
F:\psim例子 带dll\user14\user14.cpp(3) : error C2065: 't' : undeclared identifier
F:\psim例子 带dll\user14\user14.cpp(3) : error C2065: 'delt' : undeclared identifier
F:\psim例子 带dll\user14\user14.cpp(3) : error C2065: 'in' : undeclared identifier
F:\psim例子 带dll\user14\user14.cpp(3) : error C2065: 'out' : undeclared identifier
F:\psim例子 带dll\user14\user14.cpp(4) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
F:\psim例子 带dll\user14\user14.cpp(4) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
user14.obj - 1 error(s), 0 warning(s)
敲键盘输入的程序如下:
#include<stdio.h>
#include<math.h>
__declspec(dllexport) void simuser (t, delt, in, out)
double t, delt;
double *in, *out;
{
double a,b,c,d;
a=in[0];
b=in[1];
c=in[2];
if(t<c)
{
d=a;
}
else
{
d=b;
}
out[0]=d;
}
而直接打开其c源代码文件就编译没问题,复制或自己敲键盘输入就会出现上面的出错提示,我是个新手,请哪位高手大哥能帮我解决一下啊
答案:1.程序中要用_declspec(dllimport)导入,__declspec(dllexport)是DLL中的导出
2.__declspec(dllimport) void simuser (t, delt, in, out)加上参数类型
3.确定你生成的DLL已经复制到在编译的文件夹内(两个文件**.dll和**.ilk)
4.#pragma comment (lib,"***.lib")预编译去动态导入dLL
暂时没看到别的问题,还不行的话追问我
上一个:VC++随机矩形的程序,发现一个错误: 点击最小化时,弹出错误,未知软件异常
下一个:vc++如何获取磁盘信息?