Search code examples
visual-studio-2008afx

Visual C++ 2008, errors while #include "afxdb.h"


I've got trouble using adxdb.h:

I tried to

#include "afxdb.h"

But I recieved this error:

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]

Then I added

#define _AFXDLL

As error message told, and got that dozen of errors:

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

Any ideas on how to make this right? P.S. I'm new to Visual C++


Solution

  • Don't directly add the #define _AFXDLL, instead that gets added indirectly by a project configuration setting: go to your project property pages | Configuration Properties | General | Use of MFC, and make sure that is set to Use MFC in a Shared DLL.