最近做三个CCD摄像头的图像采集,遇到一个问题,一直都没有解决,请教高手啊,这到底是什么原因?
源程序:
void CHInewdlltest2Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
unsigned char pView[10]="view1";
unsigned char pImage[10]="image1";
char *pBuffer;
int m_imagerow=0;
int m_imagecol=0;
if (CBcam::DeviceNames().size() == 0)
{
AfxMessageBox("error");
}
else
{
// Get the devicename of the first camera
CString DeviceName = *(CBcam::DeviceNames().begin());
// Create the driver object and open the driver
CBcam Bcam;
Bcam.Open(DeviceName);
// Setting VideoFormat=0, VideoMode=5 yields col x row, Mono8
Bcam.SetVideoMode(DCS_Format7, DCS_Mode0); if (m_CameraNo==0) {
m_imagerow=ROW_A302FS ;
m_imagecol=COL_A302FS ;
}
else if (m_CameraNo==1)
{
m_imagerow=ROW_A101F ;
m_imagecol=COL_A101F ;
}
else
{
m_imagerow=ROW_A601F ;
m_imagecol=COL_A601F;
} // Create image buffer
const long ImageSize = m_imagecol * m_imagerow;
pBuffer = new char[ImageSize];
// Allocate Resources (MaxBuffers, MaxBufferSize)
Bcam.AllocateResources(1, ImageSize);
// Grab the image
Bcam.GrabImage(pBuffer, ImageSize, 3000 ); // timeout 3 sec.
// image processing...
// clean up
}
try
{
}
catch( ... )
{
throw ;
}
}错误代码:
--------------------Configuration: HInewdlltest2 - Win32 Debug--------------------
Compiling...
StdAfx.cpp
NOTE: WINVER has been defined as 0x0500 or greater which enables
Windows NT 5.0 and Windows 98 features. When these headers were released,
Windows NT 5.0 beta 1 and Windows 98 beta 2.1 were the current versions.
For this release when WINVER is defined as 0x0500 or greater, you can only
build beta or test applications. To build a retail application,
set WINVER to 0x0400 or visit http://www.microsoft.com/msdn/sdk
to see if retail Windows NT 5.0 or Windows 98 headers are available.
See the SDK release notes for more information.
Compiling...
Skipping... (no relevant changes detected)
HInewdlltest2.cpp
HInewdlltest2Dlg.cpp
Linking...
HInewdlltest2Dlg.obj : error LNK2001: unresolved external symbol "public: void __thiscall Bcam::CBcam::Open(class CString,struct HWND__ *)" (?Open@CBcam@Bcam@@QAEXVCString@@PAUHWND__@@@Z)
HInewdlltest2Dlg.obj : error LNK2001: unresolved external symbol "public: static class std::list<class CString,class std::allocator<class CString> > __cdecl Bcam::CBcam::DeviceNames(void)" (?DeviceNames@CBcam@Bcam@@SA?AV?$list@VCString@@V?$allocator
@VCString@@@std@@@std@@XZ)
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_InitBase
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_InitBase
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_InitBase
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_UninitUse
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_UninitUse
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_UninitUse
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __imp___vscprintf
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >(char const *)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z)
atlsd.lib(atlbase.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(Allocate.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(AtlTraceModuleManager.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(atltrace.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(Externs.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(AtlDebugAPI.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(atlfuncs.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(atlbase.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(Allocate.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(AtlTraceModuleManager.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(atltrace.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(Externs.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(AtlDebugAPI.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(atlfuncs.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
Debug/HInewdlltest2.exe : fatal error LNK1120: 11 unresolved externals
执行 link.exe 时出错.
Creating browse info file...HInewdlltest2.exe - 1 error(s), 0 warning(s)
源程序:
void CHInewdlltest2Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
unsigned char pView[10]="view1";
unsigned char pImage[10]="image1";
char *pBuffer;
int m_imagerow=0;
int m_imagecol=0;
if (CBcam::DeviceNames().size() == 0)
{
AfxMessageBox("error");
}
else
{
// Get the devicename of the first camera
CString DeviceName = *(CBcam::DeviceNames().begin());
// Create the driver object and open the driver
CBcam Bcam;
Bcam.Open(DeviceName);
// Setting VideoFormat=0, VideoMode=5 yields col x row, Mono8
Bcam.SetVideoMode(DCS_Format7, DCS_Mode0); if (m_CameraNo==0) {
m_imagerow=ROW_A302FS ;
m_imagecol=COL_A302FS ;
}
else if (m_CameraNo==1)
{
m_imagerow=ROW_A101F ;
m_imagecol=COL_A101F ;
}
else
{
m_imagerow=ROW_A601F ;
m_imagecol=COL_A601F;
} // Create image buffer
const long ImageSize = m_imagecol * m_imagerow;
pBuffer = new char[ImageSize];
// Allocate Resources (MaxBuffers, MaxBufferSize)
Bcam.AllocateResources(1, ImageSize);
// Grab the image
Bcam.GrabImage(pBuffer, ImageSize, 3000 ); // timeout 3 sec.
// image processing...
// clean up
}
try
{
}
catch( ... )
{
throw ;
}
}错误代码:
--------------------Configuration: HInewdlltest2 - Win32 Debug--------------------
Compiling...
StdAfx.cpp
NOTE: WINVER has been defined as 0x0500 or greater which enables
Windows NT 5.0 and Windows 98 features. When these headers were released,
Windows NT 5.0 beta 1 and Windows 98 beta 2.1 were the current versions.
For this release when WINVER is defined as 0x0500 or greater, you can only
build beta or test applications. To build a retail application,
set WINVER to 0x0400 or visit http://www.microsoft.com/msdn/sdk
to see if retail Windows NT 5.0 or Windows 98 headers are available.
See the SDK release notes for more information.
Compiling...
Skipping... (no relevant changes detected)
HInewdlltest2.cpp
HInewdlltest2Dlg.cpp
Linking...
HInewdlltest2Dlg.obj : error LNK2001: unresolved external symbol "public: void __thiscall Bcam::CBcam::Open(class CString,struct HWND__ *)" (?Open@CBcam@Bcam@@QAEXVCString@@PAUHWND__@@@Z)
HInewdlltest2Dlg.obj : error LNK2001: unresolved external symbol "public: static class std::list<class CString,class std::allocator<class CString> > __cdecl Bcam::CBcam::DeviceNames(void)" (?DeviceNames@CBcam@Bcam@@SA?AV?$list@VCString@@V?$allocator
@VCString@@@std@@@std@@XZ)
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol @_RTC_CheckStackVars@8
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_CheckEsp
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_Shutdown
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_InitBase
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_InitBase
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_InitBase
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __RTC_UninitUse
bcamapimfcd.lib(BcamException.obj) : error LNK2001: unresolved external symbol __RTC_UninitUse
bcamapimfcd.lib(BcamPropertyBag.obj) : error LNK2001: unresolved external symbol __RTC_UninitUse
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol __imp___vscprintf
bcamapimfcd.lib(Bcam.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >(char const *)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z)
atlsd.lib(atlbase.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(Allocate.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(AtlTraceModuleManager.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(atltrace.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(Externs.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(AtlDebugAPI.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(atlfuncs.obj) : error LNK2001: unresolved external symbol ___security_cookie
atlsd.lib(atlbase.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(Allocate.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(AtlTraceModuleManager.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(atltrace.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(Externs.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(AtlDebugAPI.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
atlsd.lib(atlfuncs.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
Debug/HInewdlltest2.exe : fatal error LNK1120: 11 unresolved externals
执行 link.exe 时出错.
Creating browse info file...HInewdlltest2.exe - 1 error(s), 0 warning(s)
还有debug和release的库可能不相同。
unresolved external symbol "public: void __thiscall Bcam::CBcam::Open(class CString,struct HWND__ *)" (?Open@CBcam@Bcam@@QAEXVCString@@PAUHWND__@@@Z)
这种错误,一看就知道是,在代码中使用了这个函数,但这个函数的函数体没有参与编译
典型的就是少了某些库,
你可以写个CLASS,
a.h a.cpp,函数都写好,申明放.h,实现放cpp,你的新项目只引入a.h,编译就会出上面的错误,你再把 a.cpp引入进去,再编译,就没问题了,你把a.cpp编译成lib,引入也一样