最近在做個調用網路攝影機資料進行掃描識別的程式,本人愚鈍,環境搭建都要半天時間,之前在windows案頭環境下就弄了半天,現在要將程式移植到wm下,移入之後根本不是想象的那麼輕鬆,由於wm和win案頭作業系統的DirectShow SDK有很多差別,只能是重新搞了。
幾番周折後又下載了個操作camera的樣本源碼,是基於windows標準庫來建立的,為了想儘快看到是否能成功調用網路攝影機,趕緊動手進行項目建立,我的wm SDK只有基於MFC的智能應用程式,只能先建立個空的C++項目了,這樣的話項目比較“純淨”。
項目建立完成,進行編譯,本來就不寄予多大的希望一次性成功,出現以下錯誤:
錯誤 1 error C2146: syntax error : missing ';' before identifier 'ContextRecord' F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winnt.h 2978
錯誤 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winnt.h 2978
錯誤 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winnt.h 2978
錯誤 4 error C2146: syntax error : missing ';' before identifier 'LPCONTEXT' F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winbase.h 1416
錯誤 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winbase.h 1416
錯誤 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winbase.h 1416
錯誤 7 error C2061: syntax error : identifier 'LPCONTEXT' F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winbase.h 2119
錯誤 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winbase.h 2127
錯誤 9 error C2143: syntax error : missing ',' before '*' F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\winbase.h 2127
錯誤 10 error C2040: 'PCONTEXT' : '_CONTEXT *' differs in levels of indirection from 'int' F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\excpt.h 65
錯誤 11 error C2378: 'LPCONTEXT' : redefinition; symbol cannot be overloaded with a typedef F:\Program Files\Windows Mobile 6 SDK\PocketPC\include\ARMV4I\excpt.h 68
從上面錯誤中大略可以看出,都是系統檔案的問題,應該是環境的問題,所以在經過一些資料尋找後,將解決方案羅列如下(首先wm SDK肯定是要提前安裝好的):
1. 當前項目右鍵-屬性-平台修改為windows mobile x SDK
2. 配置屬性-C/C++-前置處理器-前置處理器定義欄裡面: NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_WINDOWS;_USRDLL;TEST_DLL_EXPORTS;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE
3. 連結器-輸入-附加依賴項:strmbase.lib strmiids.lib
4. 連結器-系統-子系統欄-windows CE
然後編譯嘍,如果還有錯誤應該跟環境問題沒大的關係了,希望跟我有同樣“遭遇”的新手們能儘快解決問題,由於此問題屬於mobile的開發環境搭建中的基點,所以我故意將標題命名成如上。