我需要在c程序中调用一个vc程序中的函数
#include"CaptrueYUV.h"
#pragma comment(lib, "CaptrueYUV.lib")//dll中导出函数为vc函数
void main(int argc, char *argv[])
{
int i3333;////////////////////////////////
int Capture1();///////////////////////////////dll中的函数声明
i3333 = Capture1();dll中的函数声明
}
错误:
main.obj : error LNK2001: unresolved external symbol _Capture1
Debug/tmn21.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.请指教是否这样调用?
错误原因?
vc中的这个函数为:
int Capture1(){
return 2;
}
急啊,请帮帮我!
#include"CaptrueYUV.h"
#pragma comment(lib, "CaptrueYUV.lib")//dll中导出函数为vc函数
void main(int argc, char *argv[])
{
int i3333;////////////////////////////////
int Capture1();///////////////////////////////dll中的函数声明
i3333 = Capture1();dll中的函数声明
}
错误:
main.obj : error LNK2001: unresolved external symbol _Capture1
Debug/tmn21.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.请指教是否这样调用?
错误原因?
vc中的这个函数为:
int Capture1(){
return 2;
}
急啊,请帮帮我!
解决方案 »
- Slider 鼠标单击问题
- 基于对话框的程序 如何获得主对话框的对象指针
- 框架内访问视图的问题
- 问个傻瓜问题。小弟的箱子底又空了
- 编程的几点小经验。
- 求助:如何读取一个文件夹中的所有文件信息?
- 请教:VC7中的classwizard在哪,快捷键是什么??
- 我安装了RationalRoseEnterpriseEditionforWindows.2002.05,却没有注册号码,谁能帮忙?
- WinMain(hInstance,hPrevInstance,lpszCmdLine,nCmdShow)中四个参数的意义?(新手上路)
- 如何让应用程序停止
- 还有其他的同仁们在翻译中文MFC吗?
- 我用FindWindowEx()找窗口,
extern "C"{
__declspec( dllexport ) int *Capture();
}
{
int i3333;////////////////////////////////
int Capture1();///////////////////////////////dll中的函数声明
i3333 = Capture1();dll中的函数声明
}这样应该不会通过编译吧
函数内声明函数应该不行
#include"CaptrueYUV.h"
#pragma comment(lib, "CaptrueYUV.lib")//dll中导出函数为vc函数
void main(int argc, char *argv[])
{
int i3333;
i3333 = Capture1();
}
这样应该没问题的
{
int i3333;////////////////////////////////
int Capture1();///////////////////////////////dll中的函数声明
i3333 = Capture1();dll中的函数声明
}这样应该不会通过编译吧
函数内声明函数应该不行
//////////////////////////////
要是没有int Capture1();///////////////////////////////这句错误如下:main.c
H:\tmn21\main.c(98) : warning C4013: 'Capture1' undefined; assuming extern returning int
Linking...
main.obj : error LNK2001: unresolved external symbol _Capture1
Debug/tmn21.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
也就是说我现在怀疑是dll中的这个函数没有导进来,可是我都是按照方法来做的阿,不知道为什么导不进来呢????这个问题困扰我好几天了,特郁闷
extern "C"{
__declspec( dllexport ) int *Capture();
}
改为
extern "C"{
__declspec( dllimport ) int *Capture();
}
extern "C"{
__declspec( dllexport ) int *Capture();
}
编译其它dll或exe时用
extern "C"{
__declspec( dllimport ) int *Capture();
}
main.c
h:\tmn21\captrueyuv.h(3) : error C2059: syntax error : 'string'
h:\tmn21\captrueyuv.h(14) : fatal error C1189: #error : include 'stdafx.h' before including this file for PCH
Error executing cl.exe.第一个错误箭头指向extern "C"{
按照你说的方法改了,现在的错误如下:
main.c
h:\tmn21\captrueyuv.h(3) : error C2059: syntax error : 'string'
h:\tmn21\captrueyuv.h(14) : fatal error C1189: #error : include 'stdafx.h' before including this file for PCH
Error executing cl.exe.第一个错误箭头指向extern "C"{
c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(15) : fatal error C1189: #error : MFC requires C++ compilation (use a .cpp suffix)
Error executing cl.exe.
是不是由于c程序不支持mfc的原因啊??
我该怎么办?难道要把c程序都改成cpp???