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
Solved

cannot open afx.h

Posted on 1998-02-21
7
1,108 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
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 100 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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