xx.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) 错误

在vs2010下用别人提供的lib开发win32程序,编译时出现:

Dummy.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: xxx@x@x@@x referenced in function _main

造成这种错误的原因百度出来一坨一坨的,结果自己这次是用错了lib文件的版本,应该用win32的,用成x64的了。改用win32后,就可以了。


当然,还有一个吾等菜鸟中的屌丝喜闻乐见的错误,就是没有正确引入lib文件。在vs2010的解决方法是:

1、添加lib所在目录到Project Preperty->Linker->General->Additional Library Directories下,绝对路径相对路径均可,或者将所用lib拷至编译目录下。

2、在Project Preperty->Linker->Input->Additional Dependencies中加入lib名称,或者在需要引入此lib的文件前边加上

#pragma comment( lib, "xxx.lib")



error LNK2001: unresolved external symbol "__declspec(dllimport)错误

03-05

自己写的一个DLL,叫HookDll。然后在ViewDesktop程序中调用它。rn首先在ViewDesktop的cpp文件中声明了:rn_declspec(dllimport) void SetHook();rn然后调用了DLl里面的函数:SetHook();rnrn然后在 工程--设置---连接 里面设定了导入库文件:D:\HookDll\Debug\HookDll.lib rn(HookDll.dll跟HookDll.lib已经被复制到了D:\HookDll\Debug文件目录下面)rnrn出现LINK2001错误如下:rnViewDesktopDlg.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl SetHook(void)" (__imp_?SetHook@@YAXXZ)rnDebug/ViewDesktop.exe : fatal error LNK1120: 1 unresolved externalsrnrn下面是DLL文件内容:rnHookDll.cpp内容rn[code=C/C++]//#include rn#include rnrnHHOOK g_hMouse=NULL;//用来保存钩子句柄rn rn//在应用程序处理之后调用钩子。rnCFile log_file=CFile("C:\\tangaowen.txt",CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);rnrnrn//钩子函数rnLRESULT CALLBACK CallWndRetProc(int nCode, WPARAM wParam, LPARAM lParam)rnrn //在lParam里面检查所收到的消息。rn CTime time=CTime::GetCurrentTime ();rn CString string_time;rnrn string_time.Format ("%d年%d月%d日%d时%d分%d秒:",time.GetYear (),time.GetMonth (),time.GetDay (),time.GetHour (),time.GetMinute (),time.GetSecond ());rn log_file.Write (string_time,string_time.GetLength ());//向日志文件中写入事件发生的时间rn rn DWORD PID=0;//用来保存进程IDrn HANDLE handle;//用来保存进程句柄rn LPTSTR temp[50];//用来保存路径rnrn LPMSG msg=(LPMSG)lParam;rn GetWindowThreadProcessId(msg->hwnd,&PID);//由消息里面接收消息的窗口句柄得到进程ID。rn handle=OpenProcess(PROCESS_QUERY_INFORMATION,false,PID);//获得进程句柄,并且赋予进程PROCESS_QUERY_INFORMATION的access right.rn rn if(msg->message==WM_LBUTTONDBLCLK)//如果是鼠标双击消息。rn rnrn// GetProcessImageFileName(handle,temp,100);rnrnrn return CallNextHookEx(g_hMouse,nCode,wParam,lParam);rn rnrnrn return CallNextHookEx(g_hMouse,nCode,wParam,lParam);rnrn rnrn//安装钩子过程的函数rnvoid SetHook()rnrn g_hMouse=SetWindowsHookEx(WH_CALLWNDPROCRET,CallWndRetProc,GetModuleHandle("HookDll"),0);rnrnrn[/code]rn下面是HookDll.def文件内容:rn[code=C/C++]LIBRARY HookDllrnEXPORT rnSetHook @1[/code]rnrn下面是ViewDesktop中对SetHook()函数的调用:rn[code=C/C++]BOOL CViewDesktopDlg::OnInitDialog()rnrn CDialog::OnInitDialog();rnrn // Add "About..." menu item to system menu.rnrn // IDM_ABOUTBOX must be in the system command range.rn ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);rn ASSERT(IDM_ABOUTBOX < 0xF000);rnrn CMenu* pSysMenu = GetSystemMenu(FALSE);rn if (pSysMenu != NULL)rn rn CString strAboutMenu;rn strAboutMenu.LoadString(IDS_ABOUTBOX);rn if (!strAboutMenu.IsEmpty())rn rn pSysMenu->AppendMenu(MF_SEPARATOR);rn pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);rn rn rnrn // Set the icon for this dialog. The framework does this automaticallyrn // when the application's main window is not a dialogrn SetIcon(m_hIcon, TRUE); // Set big iconrn SetIcon(m_hIcon, FALSE); // Set small iconrn rn // TODO: Add extra initialization herernrn SetHook(); //DLL中函数在这里被调用rn rn return TRUE; // return TRUE unless you set the focus to a controlrnrnrnrnrnrn[/code]rn请前辈们看看是什么原因呢???在线等,急!万分感谢。rnrn

错误编译 error LNK2019: unresolved external symbol

03-25

工程在(用vs2008 Debug x64方式编译)总是编译不过去,出现以下错误:rn1>DXAviPlayer.obj : error LNK2019: unresolved external symbol "public: void __cdecl CCritSec::Unlock(void)" (?Unlock@CCritSec@@QEAAXXZ) referenced in function "private: static long __cdecl CDXAviPlayer::GrabAVIFrameThread(class CDXAviPlayer *)" (?GrabAVIFrameThread@CDXAviPlayer@@CAJPEAV1@@Z)rn1>SecureVFWWrapper.obj : error LNK2001: unresolved external symbol "public: void __cdecl CCritSec::Unlock(void)" (?Unlock@CCritSec@@QEAAXXZ)rn1>DXAviPlayer.obj : error LNK2019: unresolved external symbol "public: void __cdecl CCritSec::Lock(void)" (?Lock@CCritSec@@QEAAXXZ) referenced in function "private: static long __cdecl CDXAviPlayer::GrabAVIFrameThread(class CDXAviPlayer *)" (?GrabAVIFrameThread@CDXAviPlayer@@CAJPEAV1@@Z)rn1>SecureVFWWrapper.obj : error LNK2001: unresolved external symbol "public: void __cdecl CCritSec::Lock(void)" (?Lock@CCritSec@@QEAAXXZ)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl CCritSec::~CCritSec(void)" (??1CCritSec@@QEAA@XZ) referenced in function "public: virtual __cdecl SecureVFWWrapperHelper::~SecureVFWWrapperHelper(void)" (??1SecureVFWWrapperHelper@@UEAA@XZ)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl CCritSec::CCritSec(void)" (??0CCritSec@@QEAA@XZ) referenced in function "public: __cdecl SecureVFWWrapperHelper::SecureVFWWrapperHelper(void)" (??0SecureVFWWrapperHelper@@QEAA@XZ)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "void __cdecl FreeMediaType(struct _AMMediaType &)" (?FreeMediaType@@YAXAEAU_AMMediaType@@@Z) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl CMediaType::~CMediaType(void)" (??1CMediaType@@QEAA@XZ) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: void __cdecl CMediaType::SetSubtype(struct _GUID const *)" (?SetSubtype@CMediaType@@QEAAXPEBU_GUID@@@Z) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: void __cdecl CMediaType::SetType(struct _GUID const *)" (?SetType@CMediaType@@QEAAXPEBU_GUID@@@Z) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl CMediaType::CMediaType(void)" (??0CMediaType@@QEAA@XZ) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "void __cdecl DbgLogInfo(unsigned long,unsigned long,char const *,...)" (?DbgLogInfo@@YAXKKPEBDZZ) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>x64\Debug\HiRainMDP.exe : fatal error LNK1120: 10 unresolved externalsrn1>Build log was saved at "file://d:\DirectXCodex64\NewDXUT_x64RmFmod\x64\Debug\BuildLog.htm"rn1>HiRainMDP - 13 error(s), 69 warning(s)rnrn在(用vs2008 Release x64方式编译)总是编译还是不过去,出现以下错误:rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "void __cdecl FreeMediaType(struct _AMMediaType &)" (?FreeMediaType@@YAXAEAU_AMMediaType@@@Z) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl CMediaType::~CMediaType(void)" (??1CMediaType@@QEAA@XZ) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: void __cdecl CMediaType::SetSubtype(struct _GUID const *)" (?SetSubtype@CMediaType@@QEAAXPEBU_GUID@@@Z) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: void __cdecl CMediaType::SetType(struct _GUID const *)" (?SetType@CMediaType@@QEAAXPEBU_GUID@@@Z) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>SecureVFWWrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl CMediaType::CMediaType(void)" (??0CMediaType@@QEAA@XZ) referenced in function "public: int __cdecl SecureVFWWrapper::BuildGraph(char const *)" (?BuildGraph@SecureVFWWrapper@@QEAAHPEBD@Z)rn1>x64\Release/HiRainMDP.exe : fatal error LNK1120: 5 unresolved externalsrn1>Build log was saved at "file://d:\DirectXCodex64\NewDXUT_x64RmFmod\x64\Release\BuildLog.htm"rn1>HiRainMDP - 6 error(s), 64 warning(s)rnrn工程使用了DirectShow。在(用vs2008 Debug Win32方式编译)可以编译过去,并且正常运行。在配置中我也配置了x64平台的Executable files、Include files和Library files

编译错误error LNK2019: unresolved external symbol,求解

06-25

今天编译一个工程,其中的一个mediastream工程(用vs2008以debug方式编译)总是编译不过去,该工程依赖DirectShow的BaseClasses.rnrn我用vs6.0以debug方式编译了BaseClasses.然后把下面的三个路径rnD:\Program Files\DXSDK\IncludernD:\Program Files\DXSDK\Samples\C++\DirectShow\BaseClassesrnD:\Program Files\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug (strmbasd.lib路径)rn分别添加到了mediastream对应的属性页中.rnrn但编译mediastream时出现输出下面的错误rn1>Generating Code...rn1>Linking...rn1>alaw.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specificationrn1> Creating library D:\Source\Source\SipPhoneWorkspace\Debug\mediastreamer2.lib and object D:\Source\Source\SipPhoneWorkspace\Debug\mediastreamer2.exprn1>dxfilter.obj : error LNK2019: unresolved external symbol "public: __thiscall CTransInPlaceFilter::CTransInPlaceFilter(wchar_t *,struct IUnknown *,struct _GUID const &,long *,bool)" (??0CTransInPlaceFilter@@QAE@PA_WPAUIUnknown@@ABU_GUID@@PAJ_N@Z) referenced in function "public: __thiscall CDXFilter::CDXFilter(struct IUnknown *,long *,int)" (??0CDXFilter@@QAE@PAUIUnknown@@PAJH@Z)rn1>dxfilter.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CTransformFilter::FindPin(wchar_t const *,struct IPin * *)" (?FindPin@CTransformFilter@@UAGJPB_WPAPAUIPin@@@Z)rn1>dxfilter.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CBaseFilter::JoinFilterGraph(struct IFilterGraph *,wchar_t const *)" (?JoinFilterGraph@CBaseFilter@@UAGJPAUIFilterGraph@@PB_W@Z)rn1>dxfilter.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CBaseFilter::QueryVendorInfo(wchar_t * *)" (?QueryVendorInfo@CBaseFilter@@UAGJPAPA_W@Z)rn1>dxfilter.obj : error LNK2019: unresolved external symbol "void __stdcall DbgBreakPoint(wchar_t const *,wchar_t const *,int)" (?DbgBreakPoint@@YGXPB_W0H@Z) referenced in function "public: virtual long __thiscall CTransInPlaceFilter::GetMediaType(int,class CMediaType *)" (?GetMediaType@CTransInPlaceFilter@@UAEJHPAVCMediaType@@@Z)rn1>dxfilter.obj : error LNK2019: unresolved external symbol "public: __thiscall CTransInPlaceInputPin::CTransInPlaceInputPin(wchar_t *,class CTransInPlaceFilter *,long *,wchar_t const *)" (??0CTransInPlaceInputPin@@QAE@PA_WPAVCTransInPlaceFilter@@PAJPB_W@Z) referenced in function "public: __thiscall CDXFilterInPin::CDXFilterInPin(class CTransInPlaceFilter *,long *)" (??0CDXFilterInPin@@QAE@PAVCTransInPlaceFilter@@PAJ@Z)rn1>dxfilter.obj : error LNK2019: unresolved external symbol "void __stdcall DbgAssert(wchar_t const *,wchar_t const *,int)" (?DbgAssert@@YGXPB_W0H@Z) referenced in function "public: struct tagAM_SAMPLE2_PROPERTIES * __thiscall CBaseInputPin::SampleProps(void)" (?SampleProps@CBaseInputPin@@QAEPAUtagAM_SAMPLE2_PROPERTIES@@XZ)rn1>dxfilter.obj : error LNK2019: unresolved external symbol "public: __thiscall CMemAllocator::CMemAllocator(wchar_t *,struct IUnknown *,long *)" (??0CMemAllocator@@QAE@PA_WPAUIUnknown@@PAJ@Z) referenced in function "public: __thiscall CDXFilterAllocator::CDXFilterAllocator(class CDXFilterInPin *,long *)" (??0CDXFilterAllocator@@QAE@PAVCDXFilterInPin@@PAJ@Z)rn1>dxfilter.obj : error LNK2019: unresolved external symbol "public: __thiscall CMediaSample::CMediaSample(wchar_t *,class CBaseAllocator *,long *,unsigned char *,long)" (??0CMediaSample@@QAE@PA_WPAVCBaseAllocator@@PAJPAEJ@Z) referenced in function "public: virtual long __thiscall CDXFilterAllocator::Alloc(void)" (?Alloc@CDXFilterAllocator@@UAEJXZ)rn1>D:\Source\Source\SipPhoneWorkspace\Debug\mediastreamer2.dll : fatal error LNK1120: 9 unresolved externalsrn1>Build log was saved at "file://d:\Source\Source\Common\mediastreamer2\build\wince\Debug\BuildLog.htm"rn1>mediastreamer2 - 10 error(s), 4 warning(s)rn========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========rnrnrn请各位大侠支招!!!

error LNK2019: unresolved external symbol __imp__“报错

08-27

1>ReportError.obj : error LNK2019: unresolved external symbol __imp__PrintStrings referenced in function _ReportError@12rn1>ReportError.obj : error LNK2019: unresolved external symbol __imp__PrintMsg@8 referenced in function _ReportError@12rn1>F:\windows学习\API\ReportError\Debug\ReportError.exe : fatal error LNK1120: 2 unresolved externalsrn以上是我copy下来的报错,在这里说明一下:rn我定义了两个cpp文件,1.cpp和2.cpp,我的main()放在2.cpp中,在2.cpp中引用了函数PrintStringsrn和PrintMsg,而这两个函数是在1.cpp中定义的,我用的是VS2005,建立了一个win32基于控制台的程序,我把这两个文件都放在了Source File中,并通过头文件指明了引用关系。我不知道该如何处理这个报错!!!rn我是看着书上的程序自己调试的,我使用到了一个“Support.h”头文件,其定义如下:rn#if defined(UTILITY_3_0_EXPORTS)rn#define LIBSPEC _declspec(dllexport)rn#elif defined(__cplusplus)rn#define LIBSPEC extern "C" _declspec(dllimport) rn#elsern#define LIBSPEC _declspec(dllimport)rn#endifrnrn#define EMPTY _T("")rn#define YES _T("y")rn#define NO _T("n")rn#define CR 0x0Drn#define LF 0x0Arn#define TSIZE sizeof(TCHAR)rnrn/*limits and constants*/rn#define TYPE_FILE 1rn#define TYPE_DIR 2rn#define TYPE_DOT 3rnrn#define MAX_OPTIONS 20rn#define MAX_ARG 1000rn#define MAX_COMMAND_LINE MAX_PATH+50rnrn/*Commonly used functions*/rnLIBSPEC BOOL ConsolePrompt(LPCTSTR,LPTSTR,DWORD,BOOL);rn[color=#FF0000]LIBSPEC BOOL PrintStrings(HANDLE,...);rnLIBSPEC BOOL PrintMsg(HANDLE,LPCTSTR);[/color]rnLIBSPEC VOID ReportError(LPCTSTR,DWORD,BOOL);rnLIBSPEC VOID ReportException(LPCTSTR,DWORD);rnLIBSPEC DWORD Options(int,LPCTSTR*,LPCTSTR,...);rnLIBSPEC LPTSTR SkipArg(LPCTSTR);rnLIBSPEC VOID GetArgs(LPCTSTR,int *,LPTSTR *);rnLIBSPEC LPCTSTR wmemchr(LPCTSTR,TCHAR,DWORD);rnrn#ifdef _UNICODErn#define _tstrrchr wcsrchrrn#elsern#define _tstrrchr strrchrrn#endifrn#ifdef _UNICODErn#define _memtchr wmemchrrn#elsern#define _memtchr memchrrn#endifrnrn/*security functions*/rnLPSECURITY_ATTRIBUTES InitializeUnixSA(DWORD,LPTSTR,LPTSTR,LPDWORD,LPHANDLE);rnLPSECURITY_ATTRIBUTES InitializeAccessOnlySA(DWORD,LPTSTR,LPTSTR,LPDWORD,LPHANDLE);rnDWORD ReadFilePermissions(LPTSTR,LPTSTR,LPTSTR);rnBOOL ChangeFilePermissions(DWORD,LPTSTR,LPDWORD,LPDWORD);rnrn#define LUSIZE 1024rn#define ACCT_NAME_SIZE LUSIZErn

error LNK2019: unresolved external symbol __imp____glewActiveTexture错误解决

03-21

[code=text]rn1>Linking...rn1>gui.lib(skeletonview.obj) : error LNK2019: unresolved external symbol __imp____glewActiveTexture referenced in function "protected: virtual void __thiscall SkeletonView::draw(void)" (?draw@SkeletonView@@MAEXXZ)rn1>gui.lib(skeletonview.obj) : error LNK2019: unresolved external symbol __imp____glewUniform1i referenced in function "protected: virtual void __thiscall SkeletonView::draw(void)" (?draw@SkeletonView@@MAEXXZ)rn1>gui.lib(skeletonview.obj) : error LNK2019: unresolved external symbol __imp____glewUniformMatrix4fv referenced in function "protected: virtual void __thiscall SkeletonView::draw(void)" (?draw@SkeletonView@@MAEXXZ)rn1>gui.lib(depthrendertarget.obj) : error LNK2019: unresolved external symbol __imp____glewDeleteRenderbuffersEXT referenced in function "public: __thiscall DepthRenderTarget::~DepthRenderTarget(void)" (??1DepthRenderTarget@@QAE@XZ)rn1>gui.lib(depthrendertarget.obj) : error LNK2019: unresolved external symbol __imp____glewBindFramebufferEXT referenced in function "public: __thiscall DepthRenderTarget::~DepthRenderTarget(void)" (??1DepthRenderTarget@@QAE@XZ)rn1>gui.lib(depthrendertarget.obj) : error LNK2019: unresolved external symbol __imp____glewDeleteFramebuffersEXT referenced in function "public: __thiscall DepthRenderTarget::~DepthRenderTarget(void)" (??1DepthRenderTarget@@QAE@XZ)rn1>gui.lib(depthrendertarget.obj) : error LNK2019: unresolved external symbol __imp____glewCheckFramebufferStatusEXT referenced in function "public: __thrn[/code]rnadditional library directories加上了glew32.lib所在的文件夹,也解决不了问题。rn该怎么办呢?

error LNK2019: unresolved external symbol _F30AUSBDRIVER_DispatchPnp@8 reference

09-30

在做USB驱动开发,出现如下问题,请教大师rnrn将PNP函数放到一个独立的cpp文件中出现“标题”错误,如将此函数放到主函数中则没有错误,求解释:rnrn主函数 usb.cpp内容:rnrn#ifdef __cplusplusrnextern "C" rn#endifrn#include rn#include rn#ifdef __cplusplusrn; rn#endifrnrn#include "F30a_UsbDriver.h"rn#include "F30a_Pnp.h"rnrn#ifdef __cplusplusrnnamespace rn#endifrnPDRIVER_OBJECT pdoGlobalDrvObj = 0;rn#ifdef __cplusplusrn; // anonymous namespacern#endifrnrn#ifdef __cplusplusrnextern "C" rn#endifrnNTSTATUS DriverEntry(rn IN OUT PDRIVER_OBJECT DriverObject,rn IN PUNICODE_STRING RegistryPathrn )rnrn PDEVICE_OBJECT pdoDeviceObj = 0;rn NTSTATUS status = STATUS_UNSUCCESSFUL;rn pdoGlobalDrvObj = DriverObject; rn rn DriverObject->MajorFunction[IRP_MJ_PNP] = F30AUSBDRIVER_DispatchPnp; rnrn return STATUS_SUCCESS;rnrn#ifdef __cplusplusrn; // extern "C"rn#endifrnrnF30a_Pnp.h和F30a_Pnp.cpp内容如下:rn.h文件内容:rn#ifndef _F30A_PNP_Hrn#define _F30A_PNP_Hrnextern "C"rnNTSTATUS F30AUSBDRIVER_DispatchPnp(rn IN PDEVICE_OBJECT DeviceObject,rn IN PIRP Irprn );rn#endifrnrn.cpp文件内容:rn#include "F30a_Pnp.h"rnrnNTSTATUS F30AUSBDRIVER_DispatchPnp(rn IN PDEVICE_OBJECT DeviceObject,rn IN PIRP Irprn )rnrn NTSTATUS status = STATUS_SUCCESS;rn return status;rnrnrn如果将F30AUSBDRIVER_DispatchPnp函数放到usb.cpp中,是没有任何问题的,求原因

VS2013 ERROR LNK2019: unresolved external symbol

12-27

編譯時遇到錯誤, 文件都有加進Project, 不知道哪裏出問題, 部分代碼和完整錯誤提示如下.rnrncontext.hrn[code=c]#pragma oncern#include rn#include "loadVulkanAPI.h"rnrnvoid createInstance();rnvoid createDevice();rn... // 省略[/code]rnrncontext.cpprn[code=c]#include "context.h"rn#include "config.h"rn#include rnrnvoid createInstance()rnrn loadVulkanBaseAPI();rn ... // 省略rn vkSuccessOrDie(vkCreateInstance(&instanceCreateInfo, NULL, &instance), "Failed to create instance");rn loadVulkanInstanceAPI(instance);rn ... // 省略rnrnrnvoid createDevice()rnrn ... // 省略rn vkSuccessOrDie(vkCreateDevice(gpu, &deviceCreateInfo, NULL, &device), "Failed to create Vulkan Device");rn loadVulkanDeviceAPI(device);rnrn // Gather physical device memory propertiesrn vkGetPhysicalDeviceMemoryProperties(gpu, &deviceMemProps);rn vkGetDeviceQueue(device, 0, 0, &graphicsQueue);rnrn... // 省略[/code]rnrnloadVulkanAPI.hrn[code=c]#pragma oncern#define VK_USE_PLATFORM_WIN32_KHRrn#define VK_NO_PROTOTYPESrn#include "vulkan/vulkan.h"rn#include "NativeLibrary.h"rn#include "debugOutput.h"rnrnbool loadVulkanBaseAPI();rnbool loadVulkanInstanceAPI(VkInstance instance); rnbool loadVulkanDeviceAPI(VkDevice device);rn... // 省略[/code]rnrnloadVulkanAPI.cpprn[code=c]#include "loadVulkanAPI.h"rnrn#define PVR_STR(x) #xrn#define PVR_VULKAN_GET_INSTANCE_POINTER(instance, function_name) vk##function_name = (PFN_vk##function_name)vkGetInstanceProcAddr(instance, "vk" PVR_STR(function_name));rn#define PVR_VULKAN_GET_DEVICE_POINTER(device, function_name) vk##function_name = (PFN_vk##function_name)vkGetDeviceProcAddr(device, "vk" PVR_STR(function_name));rnrnstatic NativeLibrary vkLib("vulkan-1.dll");rnrnbool initVulkan()rnrn vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)vkLib.getFunction("vkGetInstanceProcAddr");rn vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)vkLib.getFunction("vkEnumerateInstanceExtensionProperties");rn vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties)vkLib.getFunction("vkEnumerateInstanceLayerProperties");rn vkCreateInstance = (PFN_vkCreateInstance)vkLib.getFunction("vkCreateInstance");rn vkDestroyInstance = (PFN_vkDestroyInstance)vkLib.getFunction("vkDestroyInstance");rn return true;rnrnrnbool initVulkanInstance(VkInstance instance)rnrn PVR_VULKAN_GET_INSTANCE_POINTER(instance, EnumerateDeviceLayerProperties);rn ... // 省略rn return true;rnrnrnbool initVulkanDevice(VkDevice device)rnrn PVR_VULKAN_GET_DEVICE_POINTER(device, CreateRenderPass);rn ... // 省略rn return true;rnrn...// 省略[/code]rnrn錯誤Outputrn[code=text]1>context.obj : error LNK2019: unresolved external symbol "bool __cdecl loadVulkanBaseAPI(void)" (?loadVulkanBaseAPI@@YA_NXZ) referenced in function "void __cdecl createInstance(void)" (?createInstance@@YAXXZ)rn1>context.obj : error LNK2019: unresolved external symbol "bool __cdecl loadVulkanInstanceAPI(struct VkInstance_T *)" (?loadVulkanInstanceAPI@@YA_NPAUVkInstance_T@@@Z) referenced in function "void __cdecl createInstance(void)" (?createInstance@@YAXXZ)rn1>context.obj : error LNK2019: unresolved external symbol "bool __cdecl loadVulkanDeviceAPI(struct VkDevice_T *)" (?loadVulkanDeviceAPI@@YA_NPAUVkDevice_T@@@Z) referenced in function "void __cdecl createDevice(void)" (?createDevice@@YAXXZ)[/code]

error LNK2019: unresolved external symbol __imp__报错

08-28

我定义了外部的DLL,定义如下rnlib.hrn[code=C/C++]rnextern "C"_declspec(dllexport) bool PrintStrings(HANDLE hOut,...);rnextern "C"_declspec(dllexport) bool PrintMsg(HANDLE hOut,LPCTSTR pMsg);rn[/code]rnlib.cpprn[code=C/C++]#include"Envirmnt.h"rn#includern#includern#includern#includern#include"lib.h"rnrn//write message the output handlern/*rnPrintString:该函数具有不定的参数列表,rnva_list 定义了一个保存可变参数列表的变量,它将指向一个串结构rnva_start 将特定参数之后的参数列表保存到va_list指向的串结构rnva_arg 从串结构中取回一个制定类型的元素返回,并指向串中的下一个元素rnWriteConsole 将字符串写入制定的控制台字符缓冲rn*/rnrnbool PrintStrings(HANDLE hOut,...)rnrn DWORD MsgLen,Count;rn LPCTSTR pMsg;rn va_list pMsgList;//current message stringrn va_start(pMsgList,hOut);//start processing the messagern while((pMsg=va_arg(pMsgList,LPCTSTR))!=NULL)rn rn MsgLen=_tcslen(pMsg);rn if(!WriteConsole(hOut,pMsg,MsgLen,&Count,NULL)&&!WriteFile(hOut,pMsg,MsgLen*sizeof(TCHAR),&Count,NULL))rn rn return false;rn rn rn va_end(pMsgList);rn return true;rnrnrnrnrnbool PrintMsg(HANDLE hOut,LPCTSTR pMsg)rnrn return PrintStrings(hOut,pMsg,NULL);rnrnrnrn/*prompt the user at the console and get a response*/rnbool ConsolePrompt(LPCTSTR pPromptMsg,LPTSTR pResponse,DWORD MaxTchar,bool Echo)rnrn HANDLE hStdIn,hStdOut;rn DWORD TcharIn,EchoFlag;rn bool Success;rn hStdIn=CreateFile(_T("CONIN$"),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);rn hStdOut=CreateFile(_T("CONOUT$"),GENERIC_WRITE,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);rn EchoFlag=Echo?ENABLE_ECHO_INPUT:0;rn Success=SetConsoleMode(hStdIn,ENABLE_LINE_INPUT|EchoFlag|ENABLE_PROCESSED_INPUT)&&SetConsoleMode(hStdOut,ENABLE_WRAP_AT_EOL_OUTPUT|ENABLE_PROCESSED_OUTPUT)&&PrintStrings(hStdOut,pPromptMsg)&&ReadConsole(hStdIn,pResponse,MaxTchar,&TcharIn,NULL);rn if(Success)rn rn pResponse[TcharIn-2]='\0';rn rn CloseHandle(hStdIn);rn CloseHandle(hStdOut);rn return Success;rnrn[/code]rnReportError是要调用该DLL的一个工程,我将DLL和lib都考到了ReportError的路径中,还是报错rn[code=C/C++]rn#pragma comment(lib,"PrintDll.lib")rn#include"EvryThng.h"rnrnVOID ReportError(LPCTSTR UserMessage,DWORD ExitCode,BOOL PrintErrorMsg);rnint _tmain()rnrn ReportError("hello",1,true);rn return 0;rnrnrnVOID ReportError(LPCTSTR UserMessage,DWORD ExitCode,BOOL PrintErrorMsg)rnrn DWORD eMsgLen,LastErr=GetLastError();rn LPTSTR lpvSysMsg;rn HANDLE hStdErr=GetStdHandle(STD_ERROR_HANDLE);rn PrintMsg(hStdErr,UserMessage);rn if(PrintErrorMsg)rn rn eMsgLen=FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,NULL,LastErr,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)&lpvSysMsg,0,NULL);rn PrintStrings(hStdErr,_T("\n"),lpvSysMsg,_T("\n"),NULL);rn HeapFree(GetProcessHeap(),0,lpvSysMsg);rn rn if(ExitCode>0)rn rn ExitProcess(ExitCode);rn rn elsern return ;rnrn[/code]rnEvryThng.h的定义: rn[code=C/C++] #include"Envirmnt.h" #include #include #include #include #include"Support.h" #ifdef _MT #include #if !defined(_Wp64) #define DWORD_PTR DWORD #define LONG_PTR LONG #define INT_PTR INT #endif #endifrn[/code]rnrnSupport.h的定义:rnrn[code=C/C++]rnrn #if defined(PRINTDLL_EXPORTS) #define LIBSPEC _declspec(dllexport) #elif defined(__cplusplus) #define LIBSPEC extern "C" _declspec(dllimport) #else #define LIBSPEC _declspec(dllimport) #endif #define EMPTY _T("") #define YES _T("y") #define NO _T("n") #define CR 0x0D #define LF 0x0A #define TSIZE sizeof(TCHAR) /*limits and constants*/ #define TYPE_FILE 1 #define TYPE_DIR 2 #define TYPE_DOT 3 #define MAX_OPTIONS 20 #define MAX_ARG 1000 #define MAX_COMMAND_LINE MAX_PATH+50 /*Commonly used functions*/ LIBSPEC BOOL ConsolePrompt(LPCTSTR,LPTSTR,DWORD,BOOL); LIBSPEC BOOL PrintStrings(HANDLE,...); LIBSPEC BOOL PrintMsg(HANDLE,LPCTSTR); LIBSPEC VOID ReportError(LPCTSTR,DWORD,BOOL); LIBSPEC VOID ReportException(LPCTSTR,DWORD); LIBSPEC DWORD Options(int,LPCTSTR*,LPCTSTR,...); LIBSPEC LPTSTR SkipArg(LPCTSTR); LIBSPEC VOID GetArgs(LPCTSTR,int *,LPTSTR *); LIBSPEC LPCTSTR wmemchr(LPCTSTR,TCHAR,DWORD); #ifdef _UNICODE #define _tstrrchr wcsrchr #else #define _tstrrchr strrchr #endif #ifdef _UNICODE #define _memtchr wmemchr #else #define _memtchr memchr #endif /*security functions*/ LPSECURITY_ATTRIBUTES InitializeUnixSA(DWORD,LPTSTR,LPTSTR,LPDWORD,LPHANDLE); LPSECURITY_ATTRIBUTES InitializeAccessOnlySA(DWORD,LPTSTR,LPTSTR,LPDWORD,LPHANDLE); DWORD ReadFilePermissions(LPTSTR,LPTSTR,LPTSTR); BOOL ChangeFilePermissions(DWORD,LPTSTR,LPDWORD,LPDWORD); #define LUSIZE 1024 #define ACCT_NAME_SIZE LUSIZErnrn[/code]rnrn

error LNK2019: unresolved external symbol的问题

04-12

小弟初学VC,目前正在研究用VC++和Windows DDK来开发打印虚拟驱动程序,出力成一个Tiff文件.rn目前编译后出现以下错误rndi2tiff.obj : error LNK2019: unresolved external symbol _TIFFClose@4 referenced in function "bool __stdcall TIFFEndDoc(void)" (?TIFFEndDoc@@YG_NXZ)rnddi2tiff.obj : error LNK2019: unresolved external symbol _TIFFWriteDirectory@4 referenced in function "bool __stdcall TIFFAddPage(struct _SURFOBJ *,bool)" (?TIFFAddPage@@YG_NPAU_SURFOBJ@@_N@Z)rnddi2tiff.obj : error LNK2019: unresolved external symbol _TIFFOpen@8 referenced in function "bool __stdcall TIFFAddPage(struct _SURFOBJ *,bool)" (?TIFFAddPage@@YG_NPAU_SURFOBJ@@_N@Z)rnddi2tiff.obj : error LNK2019: unresolved external symbol _TIFFWriteScanline@16 referenced in function "void __stdcall TIFFWrite(char *)" (?TIFFWrite@@YGXPAD@Z)rntifflib.lib(tif_win3.obj) : error LNK2019: unresolved external symbol _fstat referenced in function __tiffSizeProcrnf:\vss\00.work\00.test\tiffprinter\src\i386\tiffprinteruni.dll : error LNK1120: 5 unresolved externalsrn请各位高手指点迷津,函数TIFFClose,TIFFWriteDirectory,TIFFOpen,TIFFWriteScanline都在Tiffio.h中有定义,并且TiffSetField可以编译通过,如果把Tiffio.h文件中的extern "C"去掉,则TiffSetField也找不到了,它们之间的不同点是TiffSetField是__cdecl的调用方式,其它的调用方式是__stdcall,请问应该如何修改才能解决该问题?rnrn#pragma comment( lib, "***.lib" )这个方法已经试过了,不好用,本人建的是makefile工程.rn

ACE的"error LNK2019: unresolved external symbol"链接错误

09-21

我下的是ACE5.5版本,编译用的是“ACE_Static.sln”文件,选择的“Release”,按照《中篇:ACE程序员教程》里的第一个例子写好程序,头文件和库文件路径都设好了,附加库文件也添加了“ACEs.lib”,链接报错。为了排除设置问题,我在VS的命令提示符下用link命令手动链接,还是同样的错误。rnrnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ACE_SOCK_Acceptor::~ACE_SOCK_Acceptor(void)" (__imp_??1ACE_SOCK_Acceptor@@QAE@XZ) referenced in function $L28134rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ACE_SOCK_Stream::~ACE_SOCK_Stream(void)" (__imp_??1ACE_SOCK_Stream@@QAE@XZ) referenced in function $L28134rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall ACE_INET_Addr::~ACE_INET_Addr(void)" (__imp_??1ACE_INET_Addr@@UAE@XZ) referenced in function $L28134rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ACE_SOCK_Stream::ACE_SOCK_Stream(void)" (__imp_??0ACE_SOCK_Stream@@QAE@XZ) referenced in function "public: __thiscall Server::Server(int)" (??0Server@@QAE@H@Z)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ACE_SOCK_Acceptor::ACE_SOCK_Acceptor(class ACE_Addr const &,int,int,int,int)" (__imp_??0ACE_SOCK_Acceptor@@QAE@ABVACE_Addr@@HHHH@Z) referenced in function "public: __thiscall Server::Server(int)" (??0Server@@QAE@H@Z)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ACE_INET_Addr::ACE_INET_Addr(void)" (__imp_??0ACE_INET_Addr@@QAE@XZ) referenced in function "public: __thiscall Server::Server(int)" (??0Server@@QAE@H@Z)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ACE_INET_Addr::ACE_INET_Addr(unsigned short,unsigned int)" (__imp_??0ACE_INET_Addr@@QAE@GI@Z) referenced in function "public: __thiscall Server::Server(int)" (??0Server@@QAE@H@Z)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall ACE_SOCK_Stream::close(void)" (__imp_?close@ACE_SOCK_Stream@@QAEHXZ) referenced in function "public: int __thiscall Server::handle_connection(void)" (?handle_connection@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl ACE_Log_Msg::log(enum ACE_Log_Priority,char const *,...)" (__imp_?log@ACE_Log_Msg@@QAAHW4ACE_Log_Priority@@PBDZZ) referenced in function "public: int __thiscall Server::handle_connection(void)" (?handle_connection@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall ACE_Log_Msg::conditional_set(char const *,int,int,int)" (__imp_?conditional_set@ACE_Log_Msg@@QAEXPBDHHH@Z) referenced in function "public: int __thiscall Server::handle_connection(void)" (?handle_connection@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall ACE_SOCK_Stream::recv_n(void *,unsigned int,int,class ACE_Time_Value const *,unsigned int *)const " (__imp_?recv_n@ACE_SOCK_Stream@@QBEHPAXIHPBVACE_Time_Value@@PAI@Z) referenced in function "public: int __thiscall Server::handle_connection(void)" (?handle_connection@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class ACE_Log_Msg * __cdecl ACE_Log_Msg::instance(void)" (__imp_?instance@ACE_Log_Msg@@SAPAV1@XZ) referenced in function "public: int __thiscall Server::handle_connection(void)" (?handle_connection@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl ACE_Log_Msg::last_error_adapter(void)" (__imp_?last_error_adapter@ACE_Log_Msg@@SAHXZ) referenced in function "public: int __thiscall Server::handle_connection(void)" (?handle_connection@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall ACE_INET_Addr::get_host_name(void)const " (__imp_?get_host_name@ACE_INET_Addr@@QBEPBDXZ) referenced in function "public: int __thiscall Server::accept_connections(void)" (?accept_connections@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall ACE_SOCK_Acceptor::accept(class ACE_SOCK_Stream &,class ACE_Addr *,class ACE_Time_Value *,int,int)const " (__imp_?accept@ACE_SOCK_Acceptor@@QBEHAAVACE_SOCK_Stream@@PAVACE_Addr@@PAVACE_Time_Value@@HH@Z) referenced in function "public: int __thiscall Server::accept_connections(void)" (?accept_connections@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ACE_Time_Value::ACE_Time_Value(long,long)" (__imp_??0ACE_Time_Value@@QAE@JJ@Z) referenced in function "public: int __thiscall Server::accept_connections(void)" (?accept_connections@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned short __thiscall ACE_INET_Addr::get_port_number(void)const " (__imp_?get_port_number@ACE_INET_Addr@@QBEGXZ) referenced in function "public: int __thiscall Server::accept_connections(void)" (?accept_connections@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __thiscall ACE_SOCK::get_local_addr(class ACE_Addr &)const " (__imp_?get_local_addr@ACE_SOCK@@QBEHAAVACE_Addr@@@Z) referenced in function "public: int __thiscall Server::accept_connections(void)" (?accept_connections@Server@@QAEHXZ)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl ace_os_main_i(class ACE_Main_Base &,int,char * * const)" (__imp_?ace_os_main_i@@YAHAAVACE_Main_Base@@HQAPAD@Z) referenced in function _mainrnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl ACE_OS::atoi(char const *)" (__imp_?atoi@ACE_OS@@YAHPBD@Z) referenced in function "int __cdecl ace_main_i(int,char * * const)" (?ace_main_i@@YAHHQAPAD@Z)rnace_1 error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl ACE_OS::exit(int)" (__imp_?exit@ACE_OS@@YAXH@Z) referenced in function "int __cdecl ace_main_i(int,char * * const)" (?ace_main_i@@YAHHQAPAD@Z)rnace_1 fatal error LNK1120: 21 unresolved externalsrnrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试