1.11M Members

Beginner's question - Unable to open "include" file

 
0
 

I am working thru the Wrox book: [U]Beginning Programming[/U], and need some advice on getting a simple program to compile. I have Vista and use the free Borland C++ compiler. After entering in a simple C++ code, I was not able to get it to compile. When I attempted to compile the code, I received an E2209 error, the compiler was unable to open the include file 'iostream.h' In an attempt to troubleshoot the errors, I made some changes as follows using info from this site: http://dn.codegear.com/article/21205

A. Appended Environment Variables:
            1.  Opened Control Panel.
            2.  Navigated to System.
            3.  Clicked on "Advanced System Settings".
            4.  Clicked on the "Advanced" tab, to open the
                 "System Properties" window.
            5.  Clicked on the "Environment Variables" button.
            6.  Highlighted the "Path" System variable (bottom).
            7.  Clicked on the "Edit" button.
            8.  Appended the line with ";C:\BORLAND\BCC55\BIN;".
            9.  Clicked OK (3 clicks) and exited the System Properties
                 window.

B. Set up the configuration files:
            1.  From the command prompt, I changed directory to
                "C:\BORLAND\BCC55\BIN"

            2.  Created the file BCC32.CFG. as follows:
                a)  Typed "[B]edit bcc32.cfg[/B]" [Enter].
                b)  A blank window opened in the editor.
                c)  Entered the 2 lines below into the blank window.
                    [B]-I"c:\Borland\Bcc55\include"
                    -L"c:\Borland\Bcc55\lib"[/B]
                d)  Created ILINK32.CFG in the same manner as above.
                    [B]-L"c:\Borland\Bcc55\lib"[/B]
                e)  Saved the files and exited the command prompt.
                f)  Restarted Windows.

C.  From Chapter 7 of Beginning Programming, I entered the following  
    code into a text editor(EditPad Lite):

C++ code template

#include <iostream.h>
void main()
           {
    //code goes here
               }

-

D.  I saved the file as "Template.cpp" in C:\Progs.

E.  From the command prompt I entered the following:

     C:\borland\bcc55\bin\bcc32.exe C\Progs\Template.cpp

F.  The output was as follows:

Error:

C:\Users\Allen>c:\borland\bcc55\bin\bcc32.exe c:\progs\template.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
c:\progs\template.cpp:
Error E2209 c:\progs\template.cpp 2: Unable to open include file 'iostream.h'
*** 1 errors in Compile ***

-

G.  I have searched for the error and can't find it. My configuration
    files are properly located at C:\Borland\BCC55\Bin. I have tried
    experimenting with the appending in the Environment Variables
    window. I entered iostream with and without the "h", and get
    the same result.

Thanks in advance if you can help me out with this.

Allen

 
0
 

Well iostream.h isn't the standard name (it was in the old days, but not anymore).

Try

#include <iostream>
using namespace std;

Oh, and main returns int, not void.

 
0
 

Well iostream.h isn't the standard name (it was in the old days, but not anymore).

Try

#include <iostream>
using namespace std;

Oh, and main returns int, not void.

Thanks for your response Salem. I changed the code to:

// C++ code template
#include <iostream>
using namespace std;
int main()
{
// code goes here
}

And the output was:

C:\Users\Allen>c:\borland\bcc55\bin\bcc32.exe c:\progs\template.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
c:\progs\template.cpp:
Error E2209 c:\progs\template.cpp 2: Unable to open include file 'iostream'
Error E2282 c:\progs\template.cpp 3: Namespace name expected
*** 2 errors in Compile ***

I am not yet familiar with "namespace std;" but it appears the problem is with the include file, "iostream".

Here is some more information that could be relevant. I downloaded the compiler in Oct 2005 (just now getting around to learn how to program. I saved it to a directory in C:\;
I am using a new computer now with Vista. I copied the 2005 downloaded compiler from the old computer drive to the hard drive in my new computer, running Vista. I simply placed it in its own directory in C:\, just as I had done with the original download.

Typing C:\borland\bcc55\bin\bcc32.exe brings up the compiler. However, when I enter C:\borland\bcc55\bin\bcc32.exe C:\progs\template.cpp to compile the source code, I get the "unable to open include file error.

 
0
 

I found the error. It was not it the code or in the setup of the compiler. The error occurred at the command prompt level. I was not in the right directory when I entered the commands. Problem solved, now I need to study up on the command prompt protocols.

Allen

 
0
 

Yay Good for you!

 
0
 

Read Me
You'll also need to set the PATH environment variable as well, so you can run the compiler from any directory and just bcc32\bin

Also, you should begin by creating say c:\projects which will contain all your code projects. Don't be tempted to try and develop code within the compiler installation directory structure.

 
0
 

Read Me
You'll also need to set the PATH environment variable as well, so you can run the compiler from any directory and just bcc32\bin

Also, you should begin by creating say c:\projects which will contain all your code projects. Don't be tempted to try and develop code within the compiler installation directory structure.

Thanks, the Read Me link is enlightening.

Regarding the Environment Variables, you mention I need to set the PATH environment variable. in Vista, there is a User Variable window and a System Variable window . The System Variable window contains the variable "Path" and the User Variable window contains the variable "PATH". The instructions say to append the System Variable "Path"with ;C:\BORLAND\BCC55\BIN. I noticed that the string I appended consisted of ;C:\BORLAND\BCC55\BIN;C:\Borland\BCC55\Include. I added the "Include" portion after noticing the E2209 include errors.

About the User Variable window, the value for PATH was empty when I first checked it. What should be the value for the User PATH variable? Should this be appended as well?

Thanks for your suggestions,
Allen

 
0
 

You should only need the \bin directory in your path, as that also helps it locate the .cfg file where the include path information is also stored.

system or user?
The system path is what all user's of your machine will see. The user path is of course unique to you. If it's only you using the machine, it's a fairly moot point.

You can check the result by opening a new cmd.exe and typing 'path' to display the current path. If that shows the \bin directory, you should be good to go.

 
0
 

Thanks, you've been very helpful.

 
0
 

You should only need the \bin directory in your path, as that also helps it locate the .cfg file where the include path information is also stored.

system or user?
The system path is what all user's of your machine will see. The user path is of course unique to you. If it's only you using the machine, it's a fairly moot point.

You can check the result by opening a new cmd.exe and typing 'path' to display the current path. If that shows the \bin directory, you should be good to go.

Salem, Sorry to trouble you again with something that should be obvious, but I am still having some trouble with the command prompt. I did get the code to compile and the resulting (.exe), (.obj), and (.tds) files all ended up in the folder that contained the source code. This happened as it was supposed to. But the problem is that the only way it works is if I set the command prompt to C:\Borland\Bcc55\Bin>, the directory for the compiler. I have since written some more source code and succesfully compiled it, but only by doing so with the cmd prompt set to the Borland directory. I have made the necessary changes in the environment variables and have created the bcc32 and ilink32 files and made sure that they are located in the Bin folder. Where is the error?

Thanks for your help,
Allen

 
0
 

Did you update the PATH environment variables via the system settings dialogs?
From a new cmd.exe, does the 'PATH' command show the compiler install directory?

 
0
 

Did you update the PATH environment variables via the system settings dialogs?
From a new cmd.exe, does the 'PATH' command show the compiler install directory?

Yes, Path was updated in System(lower window), I appended ;C:\BORLAND\BCC55\BIN. User Path (upper window)value is %PATH%;C:\;C:\Users\Allen

Typing Path at a new cme.exe, a long string of paths results and at the end is ;C:\BORLAND\BCC55\BIN;C:\;C:\Users\Allen

I have been able to compile from cme.exe using bcc32 and also using the C:\01Projects>, this is the new directory that I store the source code files in. Can not compile from any other cme.exe. I get various error messages depending on which prompt I use, if other than the 2 that work.

 
0
 

> Can not compile from any other cme.exe.
Well the new PATH only takes effect in new cmd.exe files you run. Instances which were running before you updated the settings will not see the change.

 
0
 

Can not compile from any other cme.exe.
Well the new PATH only takes effect in new cmd.exe files you run. Instances which were running before you updated the settings will not see the change.

I don't know why the code won't compile from my default cmd.
It only does so when I set the cmd prompt to either the compiler directory or the source code directory. Typing "path" from any cmd prompt shows the same result, and ;C:\BORLAND\BCC55\BIN is appended to the end of the path string in each case. I created another file with a different source code and started over from scratch, even deleting and re-creating the cfg files in the \bin folder. Below is the latest round of attempts.

File name: hworld
Located at C:\01proj\hworld


// C++ code template
#include <iostream.h>
void main()
{
cout << "Hello, World!" << endl
}



Attempt to compile from this cmd line:


C:\Users\Allen>bcc32.exe c:\01proj\hworld.cpp



Output


C:\Users\Allen>bcc32.exe c:\01proj\hworld.cpp
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
c:\01proj\Hworld.cpp:
Error E2209 c:\01proj\Hworld.cpp 5: Unable to open include file 'iostream.h'
Error E2451 c:\01proj\Hworld.cpp 8: Undefined symbol 'cout' in function main()
Error E2451 c:\01proj\Hworld.cpp 8: Undefined symbol 'endl' in function main()
*** 3 errors in Compile ***

I don't get this error message if I compile from C:\01proj> (my source code directory)
or from C:\bcc32> The code will compile properly from these 2 cmd prompt lines.

What am I missing? Why won't it compile from my default cmd prompt?

 
0
 

Problem: Can't compile code from cmd.exe even though logged on as administrator.

Solution: Set properties, 'Run as administrator'. In Vista, the requested operation requires elevation.

Question Answered as of 6 Years Ago by Salem and timonsinger
 
-2
 

As far as I know sir, in command prompt it does not link files. But when you execute you will get your answer. I will try to come out with some more improved reply. I am telling this because in my experience.

 
-3
 

I found the error. It was not it the code or in the setup of the compiler. The error occurred at the command prompt level. I was not in the right directory when I entered the commands. Problem solved, now I need to study up on the command prompt protocols.

Allen

I meet same problem, can you please tell me which command prompt level is right level, tks

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article