2016-07-09 6 views
0

저는 드라이버 개발의 초보자입니다.KMDF 드라이버에 fstream.h를 포함시킨 후 링커 오류가 발생했습니다.

#include <ndis.h> 
#include <fwpmk.h> 
#include <fwpvi.h> 
#include <fwpsk.h> 
#include <fstream.h> 
#pragma comment(lib, "libcpmtd.lib") 

extern "C" { 

    NTSTATUS DriverEntry(
     _In_ struct _DRIVER_OBJECT *DriverObject, 
     _In_ PUNICODE_STRING  RegistryPath 
    ) 
    { 
     ofstream s("D:\\somefile.txt"); 
     s << "driver initialized."; 
     return 0; 
    } 
} 

오류의 다음과 같은 목록을 생성합니다 : 이것은 내 코드입니다 - MSVCRT.DLL에서 (또는 사용 정적 libc의 경우 -

Severity Code Description Project File Line Suppression State 
Error LNK2019 unresolved external symbol "public: virtual __thiscall ios::~ios(void)" ([email protected]@[email protected]) referenced in function "public: void __thiscall ofstream::`vbase destructor'(void)" ([email protected]@QAEXXZ) KMDF Driver1 D:\Projects\C++\KMDF Driver1\KMDF Driver1\Source.obj 1 
Error LNK2019 unresolved external symbol "public: class ostream & __thiscall ostream::operator<<(char const *)" ([email protected]@[email protected]@Z) referenced in function [email protected] KMDF Driver1 D:\Projects\C++\KMDF Driver1\KMDF Driver1\Source.obj 1 
Error LNK2019 unresolved external symbol "public: __thiscall ofstream::ofstream(char const *,int,int)" ([email protected]@[email protected]@Z) referenced in function [email protected] KMDF Driver1 D:\Projects\C++\KMDF Driver1\KMDF Driver1\Source.obj 1 
Error LNK2019 unresolved external symbol "public: virtual __thiscall ofstream::~ofstream(void)" ([email protected]@[email protected]) referenced in function "public: void __thiscall ofstream::`vbase destructor'(void)" ([email protected]@QAEXXZ) KMDF Driver1 D:\Projects\C++\KMDF Driver1\KMDF Driver1\Source.obj 1 
Error LNK2001 unresolved external symbol "public: static int const filebuf::openprot" ([email protected]@@2HB) KMDF Driver1 D:\Projects\C++\KMDF Driver1\KMDF Driver1\Source.obj 1 
Error LNK1120 5 unresolved externals KMDF Driver1 D:\Projects\C++\KMDF Driver1\Debug\KMDFDriver1.sys 1 

답변

1

이 문자 (IOS, ofstream을)가에서 종속성이 예를 들어 kernel32.dll) 커널 모드에서는 사용할 수 없습니다. "ostream s"제거 - 로깅을 위해 DbgPrint 또는 ZwCreateFile/ZwWriteFile 사용