LNK2019 unresolved external symbol __imp__IoDeleteDevice 错误
使用ddk时链接出错信息:
sioctl.obj : error LNK2019: unresolved external symbol __imp__IoDeleteDevice referenced in function _DriverEntry
sioctl.obj : error LNK2019: unresolved external symbol __imp__IoCreateSymbolicLink referenced in function _DriverEntry
sioctl.obj : error LNK2019: unresolved external symbol __imp__IoCreateDevice referenced in function _DriverEntry
sioctl.obj : error LNK2019: unresolved external symbol __imp__IoDeleteSymbolicLink referenced in function _SioctlUnloadDriver
sioctl.obj : error LNK2019: unresolved external symbol __imp__MmUnlockPages referenced in function _SioctlDeviceControl
sioctl.obj : error LNK2019: unresolved external symbol __imp__MmMapLockedPagesSpecifyCache referenced in function _SioctlDeviceControl
sioctl.obj : error LNK2019: unresolved external symbol __imp__IoFreeMdl referenced in function _SioctlDeviceControl
sioctl.obj : error LNK2019: unresolved external symbol __imp__MmProbeAndLockPages referenced in function _SioctlDeviceControl
sioctl.obj : error LNK2019: unresolved external symbol __imp__IoAllocateMdl referenced in function _SioctlDeviceControl
解决方案:
1. Project Properties à C/C++ à Advanced,右边有个“Calling Convention”,默认是“__cdecl (/Gd)”,改成“__stdcall (/Gz)”
2. Project Properties à Linker à Input,右边的“Additional Dependencies”加上“ntoskrnl.lib”