2013-10-13 124 views
3

Kinect開發的新手。我想用MinGW作爲我的Kinect for windows的開發環境。編譯錯誤,MinGW(g ++),windows API的kinect

我已經在c:\ program files \ Microsoft SDKS \ kinect \ v1.8下安裝了Kinect for windows SDK。然後在MSDN的this example之後,我寫了一個代碼來初始化我的Kinect傳感器。

當我編譯使用:

g++ -c color.c -I "c:\Program Files\Microsoft SDKs\Kinect\v1.8\inc" 

我警告一大堆和錯誤

  1. 警告

    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_ 
        ... 
        ... 
    

    從我什麼我已搜查,這些警告是由於Kinect SDK發生異常導致的編譯器差異d的Visual Studio,他們是egnorable。

  2. 錯誤

    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一起工作嗎? 任何幫助將不勝感激!

順便說一句,here是相關的頁面:

+0

標題似乎有一些gcc不兼容:/。你必須使用'-std = C++ 11'標誌(根據未被識別的'static_assert')。由於它是C++,因此使用C++擴展(如.cpp)而不是.c。請注意,圖書館也可能是不相容的: - /祝你好運。 – Jarod42

+0

@ Jarod42感謝您的快速回放。我添加了-std == C++ 11,並且static_assert被識別了。我想大多數這些錯誤都與MICROSOFT源代碼註釋語言有關,我正在嘗試。 – Sky

回答

0

有一個辦法! 下載sal.hconcurrencysal.h(通過Google搜索找到它們)。將它們放在include目錄中,並在程序中包含sal.h。
正如上面在評論中提到的那樣,添加標誌-std == C++ 11。
然後打開NuiSkeleton.h,並在第412行和第534行處將NULL更改爲nullptr(所有實例)。
它應該然後運行沒有錯誤。