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; 
    } 
} 

は、エラーの次のリストを生成します:

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の) - MSVCRT.DLLから(あるいは使用静的libcの場合 - それはからの依存関係を持っていますkernel32.dllなど)、カーネルモードでは使用できません。 "ostream s"を削除する必要があります - ログにはDbgPrintまたはZwCreateFile/ZwWriteFileを使用してください

関連する問題