阅读:2771回复:16
这个问题太怪了,你永远想不到!
wdm程序,功能很简单,看了几遍没问题,但是一编译,老是报下列错误
1>d:\driverprogram\first2\Driver.cpp(4) : error C2220: warning treated as error - no object file generated 1>d:\driverprogram\first2\Driver.cpp(4) : warning C4081: expected 'newline'; found ';' 1> 似乎说没有对象生成,但是明明是有的。和同学讨论半天,亦不知错在那里,太怪了。 还望高手出手相救。谢谢谢谢! 代码附在后面 |
|
|
沙发#
发布于:2010-04-09 10:15
你看一下警告文件,它会告诉。有可能是少续行符,或者说里面有不可识别的字符之类的
|
|
|
板凳#
发布于:2010-04-09 12:00
谢谢,不过,上面的编译错误就是来自警告文件。还是没办法
|
|
地板#
发布于:2010-04-09 13:10
标题纯粹是忽悠人,我觉得所有初学者应该先把MS的编译工具熟悉一下,要花大概1个月左右的时间吧-_-!!!!
|
|
地下室#
发布于:2010-04-09 14:43
那么,怎么熟悉呢?几乎很少有书来介绍这个,张帆的书也是一笔带过。我用的是build编译。
说实在话,我承认标题的确有些忽悠。但实属无奈之举啊。这个问题困扰我很长时间了,一直解决不了。你说,我一本书几乎都看完了,问题还是没发现。我能不急了。难道就这样被挡在大门之外了 |
|
5楼#
发布于:2010-04-09 21:19
检查一下 ,你的是否 定义了 PDEVICE_EXTENSON , 注意 大小写 问题
你的 错误 是 因 PDEVICE_EXTENSON 的错误 导致 后续无法正常编译 |
|
6楼#
发布于:2010-04-10 08:26
谢谢,不过应该不是这方面问题。因为你可能看错了,看成了相关话题的错误提示,我的错误提示在上面,是
1>d:\driverprogram\first2\Driver.cpp(4) : error C2220: warning treated as error - no object file generated 1>d:\driverprogram\first2\Driver.cpp(4) : warning C4081: expected 'newline'; found ';' 另外,我详细查了代码。都似乎没问题啊 老天爷,到底问题在那里呢?上面的提示是啥意思呢,为什么不能更准确一些呢 |
|
7楼#
发布于:2010-04-10 11:45
HelloDDK.rar
in you driver.h change your #define to #define PAGEDCODE code_seg("PAGE") #define LOCKEDCODE code_seg() #define INITCODE code_seg("INIT") #define PAGEDDATA data_seg("PAGE") #define LOCKEDDATA data_seg() #define PAGEDINIT data_seg("INIT") without ";" in the end! and your sources as below INCLUDES=$(BASEDIR)\inc;\ $(BASEDIR)\inc\ddk; SOURCES=Driver.cpp |
|
8楼#
发布于:2010-04-10 12:28
1>d:\driverprogram\first2\Driver.cpp(4) : error C2220: warning treated as error - no object file generated
1>d:\driverprogram\first2\Driver.cpp(4) : warning C4081: expected 'newline'; found ';' 把这个 waring 消了啊。。 |
|
9楼#
发布于:2010-04-10 12:30
error C2220: warning treated as error - no object file generated
警告当成错误 --》 没有生成目标文件 |
|
10楼#
发布于:2010-04-10 14:14
谢谢8楼,你说的不错,确实存在那些问题。惭愧惭愧。但是改了后又冒除了许多新问题。苦日子何时是个头啊
|
|
11楼#
发布于:2010-04-10 14:36
我是用
WinDDK\7600.16385.0 build -ceZ 改了我说的部分可以通过,你是否其它地方出问题? 什么新问题? |
|
12楼#
发布于:2010-04-10 16:42
我用的WINddk/2600,编译,出现问题13个:
1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) long __stdcall IoDeleteSymbolicLink(struct _UNICODE_STRING *)" (__imp_?IoDeleteSymbolicLink@@YGJPAU_UNICODE_STRING@@@Z) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) long __stdcall IoCreateSymbolicLink(struct _UNICODE_STRING *,struct _UNICODE_STRING *)" (__imp_?IoCreateSymbolicLink@@YGJPAU_UNICODE_STRING@@0@Z) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) struct _DEVICE_OBJECT * __stdcall IoAttachDeviceToDeviceStack(struct _DEVICE_OBJECT *,struct _DEVICE_OBJECT *)" (__imp_?IoAttachDeviceToDeviceStack@@YGPAU_DEVICE_OBJECT@@PAU1@0@Z) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) long __stdcall IoCreateDevice(struct _DRIVER_OBJECT *,unsigned long,struct _UNICODE_STRING *,unsigned long,unsigned long,unsigned char,struct _DEVICE_OBJECT * *)" (__imp_?IoCreateDevice@@YGJPAU_DRIVER_OBJECT@@KPAU_UNICODE_STRING@@KKEPAPAU_DEVICE_OBJECT@@@Z) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __stdcall RtlInitUnicodeString(struct _UNICODE_STRING *,unsigned short const *)" (__imp_?RtlInitUnicodeString@@YGXPAU_UNICODE_STRING@@PBG@Z) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __stdcall RtlAssert(void *,void *,unsigned long,char *)" (__imp_?RtlAssert@@YGXPAX0KPAD@Z) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "unsigned long __cdecl DbgPrint(char *,...)" (?DbgPrint@@YAKPADZZ) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned char __stdcall KeGetCurrentIrql(void)" (__imp_?KeGetCurrentIrql@@YGEXZ) referenced in function "long __stdcall hellowdmadddevice(struct _DRIVER_OBJECT *,struct _DEVICE_OBJECT *)" (?hellowdmadddevice@@YGJPAU_DRIVER_OBJECT@@PAU_DEVICE_OBJECT@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) long __fastcall IofCallDriver(struct _DEVICE_OBJECT *,struct _IRP *)" (__imp_?IofCallDriver@@YIJPAU_DEVICE_OBJECT@@PAU_IRP@@@Z) referenced in function "long __stdcall DefaultPnpHandler(struct _DEVICE_EXTENSION *,struct _IRP *)" (?DefaultPnpHandler@@YGJPAU_DEVICE_EXTENSION@@PAU_IRP@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __stdcall IoDeleteDevice(struct _DEVICE_OBJECT *)" (__imp_?IoDeleteDevice@@YGXPAU_DEVICE_OBJECT@@@Z) referenced in function "long __stdcall HandleRemoveDevice(struct _DEVICE_EXTENSION *,struct _IRP *)" (?HandleRemoveDevice@@YGJPAU_DEVICE_EXTENSION@@PAU_IRP@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __stdcall IoDetachDevice(struct _DEVICE_OBJECT *)" (__imp_?IoDetachDevice@@YGXPAU_DEVICE_OBJECT@@@Z) referenced in function "long __stdcall HandleRemoveDevice(struct _DEVICE_EXTENSION *,struct _IRP *)" (?HandleRemoveDevice@@YGJPAU_DEVICE_EXTENSION@@PAU_IRP@@@Z) 1>driver.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __fastcall IofCompleteRequest(struct _IRP *,char)" (__imp_?IofCompleteRequest@@YIXPAU_IRP@@D@Z) referenced in function "long __stdcall hellowdmdispatchroutine(struct _DEVICE_OBJECT *,struct _IRP *)" (?hellowdmdispatchroutine@@YGJPAU_DEVICE_OBJECT@@PAU_IRP@@@Z) 1>objchk\i386\HelloDDK.sys : fatal error LNK1120: 12 unresolved externals |
|
13楼#
发布于:2010-04-10 16:46
就是以上的问题,我再看看,恐怕是我后面自己改,哪儿又改错了。谢谢你
|
|
14楼#
发布于:2010-04-10 23:24
你的build环境似乎没有建立好!
|
|
15楼#
发布于:2010-04-11 12:56
那么,如何设置build环境呢?我直接在c盘安装了DDK,然后就用build工具来编译。编译其他程序是,都通过了,就是这个,死活通不过。惭愧惭愧,总是麻烦你,实在不好意思。
|
|
16楼#
发布于:2010-04-11 16:46
我是用 WinDDK\7600.16385.0 生成driver for win7
试一试用 7600.16385.0? |
|