Solved

cannot open afx.h

Posted on 1998-02-21
7
1,092 Views
Last Modified: 2013-11-20
I have used OWL and am now tryng to learn the MFC. This problem has me very frustrated. Just trying a "hello world" program from Windows MFC book by Jeff Prosise targeted at Visual C++. I use Borland 5.02. I use the include <mfc\afxwin.h> and get a compiler message "cannot open afx.h". afx.h is opened from afxwin.h which is obviously opened. any ideas???
0
Comment
Question by:dutch
  • 3
  • 3
7 Comments
 
LVL 32

Expert Comment

by:jhance
Comment Utility
I think the problem is in  your include path for the compiler.  You shouldn't have to use:

#include <mfc/afxwin.h>

but rather you should be using:

#include <afxwin.h>


Since the line in afxwin.h that includes afx.h says:

#include <afx.h>

you get an error because the compiler can't find afx.h.

Go to your compiler setup and add the directory where the mfc include files live to the path.  I don't have BC++ 5 so I can't tell you exactly where.
0
 

Author Comment

by:dutch
Comment Utility
Sorry but the paths to the library is correct. Borland supplies two class libraries, OWL and MFC. The libraries are in BC5\Include\Owl(or Mfc).To get to the OWL includes the entry would be;
 
#include <owl\combobox.h>

So, the Afxwin.h gets opened OK using <Mfc\Afxwin.h>. There is no message saying that the compiler can not open it, only the Afx.h file is the problem. If I try it your way, #include <afxwin.h>, then the message is "...cannot open Axfwin.h" The first thing the Afxwin.h include does is #include <Afx.h>. That is the problem. I checked and the Project is pointing to the correct include and library directories...
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
Comment Utility
Does the file exist? Where is the file? If the file does exist, make sure that you have that directory in your include path.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 32

Expert Comment

by:jhance
Comment Utility
dutch,

You didn't read what I said.  Please read it again!
0
 

Author Comment

by:dutch
Comment Utility
First, it is perfectly legal to point to a directory for an include file. Borland does this with both the OWL include files. The default directory for the project (I erroneously said "library" in my previous note) is f:\bc5\include. Beyond that, the OWL includes are in f:\bc5\include\owl and all the MFC (afx*.h) includes exist in f:\bc5\include\mfc. I have written several apps using OWL and the following syntax to access the OWL class include files (for example);

#include <owl\combobox.h>     //this always works

My assumption is that the same syntax should work for the mfc, for example;

#include <mfc\afxwin.h>         //fails opening include inside                                   afxwin.h

I went into the project and made the entry for the includes look as follows;

f:\bc5\include ; f:\bc5\include\mfc

The include line in my app is now;

#include <afxwin.h>

Now, the situation has improved. It compiles (and runs) but I get 11 warnings about virtual functions. The message from the help file is as follows;

'function1' hides virtual function 'function2'      
In this case, a declaration with the same name but different argument types makes the virtual functions inaccessible to further derived classes.

So, it looks like there is still something basically wrong???



0
 
LVL 32

Expert Comment

by:jhance
Comment Utility
You're right, it is perfectly legal to do:

#include <mfc/afxwin.h>

BUT IF "mfc/afxwin.h" has ANOTHER #include IN IT THAT DOES:

#include <afx.h>

(and it DOES!!)  Guess what?  It can't be found because Microsoft expects you to put mfc in the include path.

The virtual function warning is just that, a warning.  You haven't provided enough information about what is causing the problem.  If you were to post the function definition that is causing the problem, it would probably help.
0
 

Author Comment

by:dutch
Comment Utility
Boy this sure makes sense now!! Thanks

The warning messages are all the same. It looks like the warnings are coming from Create(NULL, "The Hello Application") in the CMainWindow constructor. The messages look like this;

AFXWIN.H 'CDialog::Create(const char*, CWnd)' hides function 'CWnd::Create(const char*, unsigned long, const tagRect&, CWnd*, unsigned int, CCreateContext*)'

The remaining 10 warnings are exactly the same except the class identified is CButton, CStatic, CDialog, CButton, etc.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
configuration management 2 99
GIF file bit manipulation for color change 5 104
List out all word 7 218
Fibonacci challenge 11 81
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now