?
Solved

cannot open afx.h

Posted on 1998-02-21
7
Medium Priority
?
1,133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1316466
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
ID: 1316467
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 300 total points
ID: 1316468
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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 32

Expert Comment

by:jhance
ID: 1316469
dutch,

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

Author Comment

by:dutch
ID: 1316470
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
ID: 1316471
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
ID: 1316472
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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 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