3

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++

3 Answers 3

5

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.

2
  • Try a clean, then rebuild on your project(s). Also, where have you added the #include <afxdb.h>? I just tried this in a console app, stuck in it next to the other #include <afx...> lines in the precompiled header file, and it works just fine.
    – Chris O
    May 31, 2011 at 21:48
  • Did this project start life as an MFC project, or did you just add MFC support? Rather, do other MFC includes work fine? This is starting to sound like header file confusion. If you did recently add MFC support to this project, you might want to create another MFC project from scratch and compare project settings and headers, to make sure nothing was missed.
    – Chris O
    Jun 1, 2011 at 13:02
1

To solve the problem, you need to open Projects-> Proprties-> Configuration Properties> Generation-> Use of MFC: Use MFC in the Shared DLL.

(Visual Studio 2013) And you will be happy!

1
  • The above does not fix my problem. But in case it may help others, the menu path should be ...->Configuration Properties> **General**>Use of MFC... Jul 17, 2015 at 7:35
0

I had the same problem and to solve it I had to make sure that:

#include <afxcmn.h>

is before:

#include <afxdb.h>

So:

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

Is good and:

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

Is bad.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.