oneurlvs編譯
⑴ vs2010如何編譯驅動
1、安裝VS2010,安裝WDK 7.0(DDK);
2、新建VC++->Empty Project
3、打開Configuration Manager 並新建一個名稱為「 dirver 」的Solution Configuration 並將「dirver」 設為Active Solution Configuration .
4、打開View-> property Manager。
5、在"dirver" solution configuration 上點擊右鍵,選擇Add new property Sheet。取名為「dirverProperty」. 並對他進下以下設置。
5.1. C\C++ - General - Debug Information Format = Program Database (/Zi)
5.2. C\C++ - Preprocessor - Preprocessor Definitions = _X86_ [add also DBG for Debug config]
【WIN32;_DEBUG;_X86_;i386;STD_CALL;CONDITION_HANDLING;WIN32_LEAN_AND_MEAN;NT_UP;SRVDBG;DBG;_IDWBUILD;_WIN32_WINNT=0x0400;% (PreprocessorDefinitions)】
5.3. C\C++ - Code Generation - Enable C++ Exceptions = No
5.4. C\C++ - Code Generation - Basic Runtime Checks = Default
5.5. C\C++ - Code Generation - Buffer Security Check = No (/GS-)
5.6. C\C++ - Advanced - Calling Convention = __stdcall (/Gz)
5.7. C\C++ - Advanced - Compile As = Compile as C Code (/TC) [if you are going to use plain C]
5.8. Linker - General - Output File = $(OutDir)\$(ProjectName).sys
5.9. Linker - General - Enable Incremental Linking = Default
5.10. Linker - Input - Additional Dependencies = ntoskrnl.lib hal.lib $(NOINHERIT) [add here needed libs here e.g. ntoskrnl.lib hal.lib]
【不知道上面是不是筆誤,應該為:ntoskrnl.lib;hal.lib;%(AdditionalDependencies)】
5.11. Linker - Input - Ignore All Default Libraries = Yes (/NODEFAULTLIB)
5.12. Linker - Manifest File - Generate Manifest = No
5.13. Linker - System - SubSystem = Native (/SUBSYSTEM:NATIVE)
5.14. Linker - System - Driver = Driver (/DRIVER)
5.15. Linker - Advanced - Entry Point = DriverEntry
5.16. Linker - Advanced - Base Address = 0x10000
5.17. Linker - Advanced - Randomized Base Address = Disable (/DYNAMICBASE:NO)
【這個也是錯誤的:應該置空】
5.18. Linker - Advanced - Data Execution Prevention (DEP) = Disable (/NXCOMPAT:NO)
【這個也是錯誤的:應該置空】
6. Config VC++ Directories
6.1 Open Open up property manager by clicking on Menu View->Property Manager.
6.2 Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp.<Platform>.users" file for each Configuration|Platform. These are the files
for the global settings, similar to the old tools/Options/VC++ Directories.
6.3 Multi-Select "Microsoft.cpp.<Platform>.users", right click and bring up the property page window
6.4 In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by
semicolons
(eg:Include Directories config As:
$(ddkroot)\INC
$(ddkroot)\INC\WNET
$(ddkroot)\INC\DDK\WNET
Library Directories config As:
$(ddkroot)\LIB\WNET\I386
)
6.5 Make sure to save the settings before shutting down Visual Studio.
6.6 Re-launch Visual Studio and the new settings will be in effect.
6.7 Note: If you would like to only change the settings for one project, you can right click on the project and bring up the property page. Change the settings for 「VC++
Directories」, these settings will be persisted to the project file.
七. OK. Have done. Now you can test it with simple code, e.g.:
#include "ntddk.h"
NTSTATUS
DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING RegistryPath)
{
return STATUS_UNSUCCESSFUL;
}
特別說明:
1.
Visual Studio 2010 在智能設備開發方面只支持Windows Phone OS 7.0。如果你要為Windows CE 5.0和Windows Mobile 6.5開發應用程序,請安裝Visual Studio 2008。
2.
做驅動開發時,SDK的版本要和WDK的版本一致,即Win7 WDK要配Win7 SDK,否則會出現編譯錯誤。VS2010里集成了Windows SDK 7.0A。
3.
如果出現類似如下編譯錯誤,解決方法是:拷貝C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\sal.h,然後覆蓋掉C:\WinDDK\7600.16385.1\inc\api\sal.h。
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2143: syntax error : missing ')' before 'const'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\crtdefs.h(550): error C2143: syntax error : missing '{' before 'const'
.......
⑵ VS2015專業版 C++編譯中出現MSB4184錯誤
不會!!!!!
⑶ WIN7 64位系統,VS2010 x64中PCL all-in-one配置,編譯時出現問題,具體如下列圖片所示,求大神解答。
1、出現錯誤:fatal error LNK1123: 轉換到 COFF 期間失敗: 文件無效或損壞
解決方案:項目\屬性\配置屬性\清單工具\輸入和輸出\嵌入清單:原來是「是」,改成「否」。
Q:該方法治標不治本,每次新建一個項目時都要重新配置。還有為什麼這么做就能解決該問題呢?
A:1)治本的方法:
<1>項目\屬性\配置屬性\清單工具\輸入和輸出\嵌入清單:原來是「是」,改成「否」。
<2>項目|項目屬性|配置屬性|連接器|清單文件|生成清單 「是」改為「否」。
<3>若以上兩步後仍沒解決問題,則按照以下方法解決:
查找是否有兩個cvtres.exe。一個是C:\Program Files(x86)\Microsoft Visual Studio 10.0\vc\bin\cvtres.exe, 另一個是C:\Windows\Microsoft.NET\Framework\v4.0.30319\cvtres.exe。右鍵屬性|詳細信息 查看兩者版本號,刪除/重命名較舊的版本,或者重新設置Path變數。
刪除舊版本的cvtres.exe後,就不需要每次都設置配置了。
2)為什麼這么操作可以解決問題?筆者未查明原因,同仁們有清楚的可以給出評論。
2、1>lena.obj : error LNK2019: 無法解析的外部符號 _cvReleaseImage,該符號在函數 _main 中被引用
1>lena.obj : error LNK2019: 無法解析的外部符號 _cvDestroyWindow,該符號在函數 _main 中被引用
1>lena.obj : error LNK2019: 無法解析的外部符號 _cvWaitKey,該符號在函數 _main 中被引用
1>lena.obj : error LNK2019: 無法解析的外部符號 _cvShowImage,該符號在函數 _main 中被引用
1>lena.obj : error LNK2019: 無法解析的外部符號 _cvNamedWindow,該符號在函數 _main 中被引用
1>lena.obj : error LNK2019: 無法解析的外部符號 _cvLoadImage,該符號在函數 _main 中被引用
1>c:\users\yunyan\documents\visual studio 2010\Projects\lena\Debug\lena.exe : fatal error LNK1120: 6 個無法解析的外部命令
1>
1>生成失敗。
1>
1>已用時間 00:00:01.52
========== 生成: 成功 0 個,失敗 1 個,最新 0 個,跳過 0 個 ==========
解決方案:出現錯誤的原因可能有二,一種是系統配置不對(如x64位下仍使用Win32則錯),另一種是少添加了庫。筆者的是第一種原因,因為一直習慣了在x86下編寫Win32程序,所以編譯的時候仍使用了Win32,那麼必然運行失敗。該問題怎麼破呢?如下:
右擊項目名稱,選擇「屬性」,彈出頁面的最上方中間一項「平台」選擇x64,在該平台下按照OpenCV中文網的配置過程。
⑷ c語言結構體初始化(編譯系統vs2010)
.location 這種叫按名稱初始化,是gun對c的擴展,只有gnu支持,就是linux下的編譯器支持(gcc, g++)
程序員寫代碼的時候,最好使用被廣泛支持的標准,盡量不要使用個別編譯器的私有定義。
關注優酷上的 」C學習指南「,在第10章里會講這個問題。
⑸ 在VS中編譯C++程序,發現數組中結束標記並非'\0',而是一個值為-52的特殊字元
這很正常,因為你申請了5個元素的空間,而你的字元串長度不夠,沒有充分利用這段空間。
恰巧你又工作在vc的debug模式下,在這個模式下,vc會自動把所有棧上數據填充成0xcc
"燙燙燙燙",也就是你看到的-52