VS2010如果设置编译驱动

my_westlife 2011-05-10 04:01:09
google了很多帖子都没用,谁能给个比较清楚的设置步骤,进行编译driver,非常感谢啊!
...全文
1493 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
恐小怖 2011-09-21
  • 打赏
  • 举报
回复
搭配太麻烦,,还是用VS2008好了哎.
gas007wei 2011-06-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 bobo008 的回复:]
这篇更好点,参考一下
http://blog.csdn.net/Sniffer_Wang/archive/2011/03/26/6280729.aspx
写作人:Sniffer_Wang





前提:vs2010 ,wdk7已经安装

1. 新建 “解决配置管理器” 名称可为:Driver

2. 建立空项目,添加cpp文件。

3. 打开 视图->其他视图->……
[/Quote]
这篇的链接器依赖附属项是关键啊。。。。
my_westlife 2011-05-19
  • 打赏
  • 举报
回复
用了,不习惯就卸载了。不过D我自己找出来毛病了。DDK链接库冲突。
zswolf2000 2011-05-13
  • 打赏
  • 举报
回复
win8以后的WDK将使用vs2010,嘿嘿,我现在正在用
曹大夯 2011-05-11
  • 打赏
  • 举报
回复
不太建议用VC来编译驱动。还是用WDK的内建编译环境保险。
my_westlife 2011-05-11
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 huntercao 的回复:]
不太建议用VC来编译驱动。还是用WDK的内建编译环境保险。
[/Quote]
新的问题是:1> Usb.cpp
1>d:\mytestdriver\wdm.h(14197): fatal error C1189: #error : "No target architecture defined"
1> Pnp.cpp
1>d:\mytestdriver\wdm.h(14197): fatal error C1189: #error : "No target architecture defined"
1> Init.cpp
1>d:\mytestdriver\wdm.h(14197): fatal error C1189: #error : "No target architecture defined"
1> Dispatch.cpp
1>d:\mytestdriver\wdm.h(14197): fatal error C1189: #error : "No target architecture defined"
my_westlife 2011-05-11
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 huntercao 的回复:]

不太建议用VC来编译驱动。还是用WDK的内建编译环境保险。
[/Quote]
我用内建的环境编译不过去啊,所以才想用VS2010.您可以在帮我看看另一个帖子的源代码吗?帮我看看错误出在哪里。我用VC6 编译的时候加了usbd.lib和setupapi.lib 就成功了,但是DDK却还是过不去。
BoBo008 2011-05-10
  • 打赏
  • 举报
回复
这篇更好点,参考一下
http://blog.csdn.net/Sniffer_Wang/archive/2011/03/26/6280729.aspx
写作人:Sniffer_Wang





前提:vs2010 ,wdk7已经安装

1. 新建 “解决配置管理器” 名称可为:Driver

2. 建立空项目,添加cpp文件。

3. 打开 视图->其他视图->属性管理器

4. 右击 Driver|Win32选择属性;





配置:

常规:

目标文件扩展名:.sys



VC++目录 (我的wdk安装目录为:C:\WinDDK\)

可执行文件目录:C:\WinDDK\7600.16385.1\bin\x86;$(ExecutablePath)



包含目录:

c:\WinDDK\7600.16385.1\inc;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)\include;$(WindowsSdkDir)\common\include;$(FrameworkSDKDir)include;c:\WinDDK\7600.16385.1\inc\api;c:\WinDDK\7600.16385.1\inc\ddk;$(IncludePath)



库目录:

C:\WinDDK\7600.16385.1\lib\win7\i386;$(LibraryPath)





链接器:

常规

输出文件:$(OutDir)\$(ProjectName).sys

输入

附属依赖项:

ntoskrnl.lib;Hal.lib;wdm.lib;wdmsec.lib;wmilib.lib;ndis.lib;MSVCRT.LIB;LIBCMT.LIB;%(AdditionalDependencies)

忽略所有默认库: 是 (/NODEFAULTLIB)

清单文件

生成清单:否 (/MANIFEST:NO)

启动用户账户控制:否 (/MANIFESTUAC:NO)

调试

生成调试信息:是 (/DEBUG)

生成映射文件:是 (/MAP)

映射文件名:$(TargetDir)$(TargetName).map

系统

子系统: 控制台 (/SUBSYSTEM:CONSOLE)

堆栈保留大小:4194304

堆栈提交大小:4096

驱动程序:驱动程序 (/Driver)

高级

入口点:DriverEntry

无入口点:否

设置校验和:是 (/RELEASE)

基质:0x10000

随机基质:删除,不填写

数据执行保护:删除不填写





配置完之后我 的是可以运行的,不知道以后会不会出问题....
BoBo008 2011-05-10
  • 打赏
  • 举报
回复
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'
.......
引:http://www.cnblogs.com/wubiyu/archive/2010/05/17/1737420.html

21,599

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 驱动开发/核心开发
社区管理员
  • 驱动开发/核心开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧