2011-05-31 77 views
3

我已經使用了adxdb.h麻煩:的Visual C++ 2008,而錯誤的#include 「AFXDB.H」

我試圖

#include "afxdb.h" 

但我收到此錯誤:

C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afx.h(24) : fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

然後我說

#define _AFXDLL 

爲Error我ssage告訴,並得到了那麼多的錯誤:

C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxole.h(1455) : error C2504: 'CControlBar' : base class undefined
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxole.h(1470) : error C2146: syntax error : missing ';' before identifier 'm_tracker'
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxole.h(1470) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxole.h(1470) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxpriv.h(590) : error C2504: 'CControlBar' : base class undefined

任何想法如何使這個權利? P.S.我是新來的Visual C++

回答

5

不要直接添加#define _AFXDLL,而是通過項目配置設置間接添加:轉到您的項目屬性頁|配置屬性|一般|使用MFC,並確保將其設置爲在共享DLL中使用MFC。

+0

如果我喜歡你說的話,我會得到相同的錯誤信息。 – mindmaster 2011-05-31 21:41:46

+0

嘗試一個乾淨的,然後重建您的項目。另外,你在哪裏添加了#include ?我只是在一個控制檯應用程序中試過,在預編譯頭文件中的其他'#include '行旁邊插入它,它工作得很好。 – 2011-05-31 21:48:53

+0

試圖做到這一點 - 同樣的事情( – mindmaster 2011-05-31 22:09:12

0

我有同樣的問題,解決它,我必須確保:

#include <afxcmn.h> 

是前:

#include <afxcmn.h> 
#include <afxdb.h> 

是好的,:

#include <afxdb.h> 

所以:

#include <afxdb.h> 
#include <afxcmn.h> 

不好。

1

要解決該問題,需要打開Projects-> Proprties-> Configuration Properties> Generation->使用MFC:在共享DLL中使用MFC。

(Visual Studio 2013) 你會很高興!

+0

上面的問題並沒有解決我的問題但是萬一它可以幫助別人,菜單路徑應該是...->配置屬性> **常規**>使用MFC ... – 2015-07-17 07:35:17