MFC的dll引用導致的error

因爲要在動態庫中添加一個HTTP下載的函數。所以使用了 CInternetSession類。引用了#include <afxinet.h>

在編譯的時候報錯,報錯內容爲 :


    afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H already included,MFC apps must not #include <windows.h>

        然後,刪除了所有的<windows.h> 之後編譯,報錯變成了

error LNK2005: _DllMain@12 已經在 dllmain.obj 中定義
        然後按照這個鏈接更改的

        http://www.cnblogs.com/profession/p/5849440.html

         在dllmain.cpp中添加了

#ifdef _X86_
extern "C" { int _afxForceUSRDLL; }
#else
extern "C" { int __afxForceUSRDLL; }
#endif
       

       並在 stdafx.h 中添加了

#include "afx.h"
#include <afxinet.h>
#include <windows.h>
      完美編譯通過。因爲afx.h的引用 要求在 windows.h前面。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章