因爲要在動態庫中添加一個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前面。