我刚开始学习Kinect开发,想使用MinGW作为我的Kinect for Windows的开发环境。
我已经在c:\program files\Microsoft SDKS\kinect\v1.8下安装了Kinect for Windows SDK。然后按照MSDN上的这个例子,编写了一个初始化Kinect传感器的代码。
当我使用以下命令进行编译时:
g++ -c color.c -I "c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc"
我收到了很多警告和错误提示
Warnings
In file included from NuiApi.h:109:0, from color.c:2: c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc/NuiSensor.h:137:8: warning: extra tokens at end of # endif directive [enabled by default] #endif _Vector4_ ^ c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc/NuiSensor.h:160:8: warning: extra tokens at end of # endif directive [enabled by default] #endif _Matrix4_ ^ c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc/NuiSensor.h:209:8: warning: extra tokens at end of # endif directive [enabled by default] #endif _NUI_SKELETON_POSITION_INDEX_ ... ...
From I what I have searched, these warning are cause by compiler differences because Kinect SDK is intended for Visual Studio and they are egnorable.
Errors
NuiApi.h:47:5: error: definition of 'HRESULT NuiInitialize' is marked 'dllimport' NuiApi.h:47:5: error: '_In_' was not declared in this scope NuiApi.h:77:14: error: expected constructor, destructor, or type conversion before '(' token static_assert(E_NUI_FRAME_NO_DATA == 0x83010001, "Error code has changed."); ^ In file included from NuiApi.h:109:0, from color.c:2: c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc/NuiSensor.h:2105:1: error: '_Check_return_' does not name a type _Check_return_ HRESULT NUIAPI NuiGetSensorCount( _In_ int * pCount ); ^ ...(tons of _Check_return does not name a type) c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc/NuiImageCamera.h:78:39: error: '_In_' was not declared in this scope c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc/NuiImageCamera.h:78:70: error: '_Out_' was not declared in this scope
问题
我知道大多数这些错误(如果不是全部)都是因为Kinect SDK是针对VS开发的。但我是一个新手,想了解更多底层信息。所以我能否让我的g++与Kinect SDK一起使用,该怎么做? 任何帮助都将不胜感激!!
顺便说一下,这里有一个相关页面:
-std=c++11
标志(根据未识别的static_assert
)。由于这是C ++,请使用c ++扩展名(如.cpp)而不是.c。请注意,库也可能不兼容 :-/ 祝你好运。 - Jarod42