我正在尝试在Visual Studio 2012中构建一个C ++ / CLI库(在Win8 Release Preview上),以便在C#中使用函数InitializeTouchInjection和InjectTouchInput。
我这样定义我的课
// MultiTouchWrapper.h
namespace MultiTouchWrapper {
public ref class MultiTouchInjection
{
public:
static bool InitializeMultiTouch(int maxCount);
static bool InjectMultiTouch(int count, float *x, float *y, int *id);
};
}
并实现功能
//MultiTouchWrapper.cpp
#include "stdafx.h"
#include "MultiTouchWrapper.h"
namespace MultiTouchWrapper{
bool MultiTouchInjection::InitializeMultiTouch(int maxCount){
if(InitializeTouchInjection(maxCount, TOUCH_FEEDBACK_DEFAULT)) return true;
return false;
}
bool MultiTouchInjection::InjectMultiTouch(int count, float *x, float *y, int *id){
POINTER_TOUCH_INFO *contacts = new POINTER_TOUCH_INFO[count];
for(int i=0; i<count; i++){
contacts[i].pointerInfo.pointerType = PT_TOUCH;
contacts[i].pointerInfo.pointerId = id[0];
contacts[i].pointerInfo.ptPixelLocation.y = (LONG)y[0];
contacts[i].pointerInfo.ptPixelLocation.x = (LONG)x[0];
contacts[i].touchFlags = TOUCH_FLAG_NONE;
contacts[i].touchMask = TOUCH_MASK_NONE;
}
if(InjectTouchInput(count, contacts)) return true; //defined like this to avoid a warning about BOOL vs bool.
return false;
}
在stdafx.h中,我添加了<windows.h>
,其中提供了InitializeTouchInjection
和InjectTouchInput
到<WinUser.h>
的定义。
我遇到的问题是,当我尝试构建这个库时,我得到两个函数的错误LNK2028和LNK2019:
Error 1 error LNK2028: unresolved token (0A00003B) "extern "C" int __stdcall InjectTouchInput(unsigned int,struct tagPOINTER_TOUCH_INFO const *)" (?InjectTouchInput@@$$J18YGHIPBUtagPOINTER_TOUCH_INFO@@@Z) referenced in function "public: static bool __clrcall MultiTouchWrapper::MultiTouchInjection::InjectMultiTouch(int,float *,float *,int *)" (?InjectMultiTouch@MultiTouchInjection@MultiTouchWrapper@@$$FSM_NHPAM0PAH@Z) C:\Users\mediascape\documents\visual studio 2012\Projects\MultiTouchWrapper\MultiTouchWrapper\MultiTouchWrapper.obj MultiTouchWrapper
Error 2 error LNK2028: unresolved token (0A000063) "extern "C" int __stdcall InitializeTouchInjection(unsigned int,unsigned long)" (?InitializeTouchInjection@@$$J18YGHIK@Z) referenced in function "public: static bool __clrcall MultiTouchWrapper::MultiTouchInjection::InitializeMultiTouch(int)" (?InitializeMultiTouch@MultiTouchInjection@MultiTouchWrapper@@$$FSM_NH@Z) C:\Users\mediascape\documents\visual studio 2012\Projects\MultiTouchWrapper\MultiTouchWrapper\MultiTouchWrapper.obj MultiTouchWrapper
Error 3 error LNK2019: unresolved external symbol "extern "C" int __stdcall InitializeTouchInjection(unsigned int,unsigned long)" (?InitializeTouchInjection@@$$J18YGHIK@Z) referenced in function "public: static bool __clrcall MultiTouchWrapper::MultiTouchInjection::InitializeMultiTouch(int)" (?InitializeMultiTouch@MultiTouchInjection@MultiTouchWrapper@@$$FSM_NH@Z) C:\Users\mediascape\documents\visual studio 2012\Projects\MultiTouchWrapper\MultiTouchWrapper\MultiTouchWrapper.obj MultiTouchWrapper
Error 4 error LNK2019: unresolved external symbol "extern "C" int __stdcall InjectTouchInput(unsigned int,struct tagPOINTER_TOUCH_INFO const *)" (?InjectTouchInput@@$$J18YGHIPBUtagPOINTER_TOUCH_INFO@@@Z) referenced in function "public: static bool __clrcall MultiTouchWrapper::MultiTouchInjection::InjectMultiTouch(int,float *,float *,int *)" (?InjectMultiTouch@MultiTouchInjection@MultiTouchWrapper@@$$FSM_NHPAM0PAH@Z) C:\Users\mediascape\documents\visual studio 2012\Projects\MultiTouchWrapper\MultiTouchWrapper\MultiTouchWrapper.obj MultiTouchWrapper
我不知道该怎么做。我已尝试在配置属性&gt;&gt;中包含/ LD C / C ++&gt;&gt;命令行菜单。我已尝试在高级菜单中将调用约定更改为__cdecl
,但它始终会恢复为__stdcall
。
如何解决这些链接器错误?