Thread: Run error

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    11

    Run error

    Hi

    I just installed Borland C++ , actually unzipped and copied over from floppies onto Windows 98, not sure which version but it sure is old, and has this kinda DOS interface (runs in a DOS window).

    As for my first lesson , I copied a few lines of code from a C++ book and tried to run (Ctrl + F9) after saving the file as C:\windows\desktop\codes\peas.cpp, but had the following errors.

    What gives?

    BTW, the path to bc.exe is C:\Borland C++\BORLANDC\BIN\. Is this fine?

    Code:
    Compiling C:\WINDOWS\DESKTOP\CODES\PEAS.CPP:
    Error C:\WINDOWS\DESKTOP\CODES\PEAS.CPP 1: Unable to open include file 'IOSTREAM.H'
    Error C:\WINDOWS\DESKTOP\CODES\PEAS.CPP 2: Undefined symbol 'cout' in function main( )
    Error C:\WINDOWS\DESKTOP\CODES\PEAS.CPP 3: Undefined symbol 'cin' in function main( )
    
    etc.
    
    Warning C:\WINDOWS\DESKTOP\CODES\PEAS.CPP 26: 'total_peas' is assigned a value that is never used in function main( )
    Thanx.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    1) Show us your code (make sure you use code tags)
    2) iostream shouldn't be capitalized. That's probably your problem.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    2
    Originally posted by Govtcheez
    1) Show us your code (make sure you use code tags)
    2) iostream shouldn't be capitalized. That's probably your problem.
    That's not a problem on Win 98.
    The problem most likely is he doesn't have include directory set.
    Somewhere in the menu should be the directoris entry. Just add C:\Borland C++\BORLANDC\INCLUDE\ to the include direcotris.
    Or you can do it by -I switch.

  4. #4
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    <- Too used to UNIX....

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    11
    Ok here's the code...too newbiesh

    Code:
    #include <iostream.h>
    
    int main( )
    {
    	int number_of_pods, peas_per_pod, total_peas;
    
    	cout << "Press return after entering a number\n";
    	cout << "Enter the number of pods:\n";
    	cin >> number_of_pods;
    	cout << "Enter the number of peas in a pod:\n";
    	cin >> peas_per_pod;
    
    	total_peas = number_of_pods * peas_per_pod;
    
    	cout << "If you have";
    	cout << number_of_pods;
    	cout << " pea pods\n";
    	cout << "and ";
    	cout << peas_per_pod;
    	cout << " peas in each pod, then\n";
    	cout << "you have ";
    	cout << total_peas;
    	cout << " peas in all pods.\n";
    
    	return 0;
    }
    I copied this verbatim from the example in that book. I fear that there's something not properly right w/ my installation of C++.

    The path is C:\Borland C++\Borlandc\ and everything else is under this.

    Just add C:\Borland C++\BORLANDC\INCLUDE\ to the include direcotris.
    I dont seem to quite understand the above. Might be helpful if you could explain more.

    Thanx.

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>I dont seem to quite understand the above. Might be helpful if you could explain more.
    Also might be good if you reviewed theFAQ Board
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    11
    Hi

    Under this directory C:\Borland C++\BORLANDC\BIN I created 2 files bcc32.cfg and ilink32.cfg as per instructions. (These files were saved as .cfg not .txt)

    bcc32.cfg

    Code:
    -I"C:\Borland C++\BORLANDC\INCLUDE"
    -L"C:\Borland C++\BORLANDC\LIB"
    -wall
    ilink32.cfg

    Code:
    -L"C:\Borland C++\BORLANDC\LIB"
    Respectively the path to these 2 files are :

    C:\Borland C++\BORLANDC\BIN\bcc32.cfg
    C:\Borland C++\BORLANDC\BIN\ilink32.cfg


    I also added the PATH=C:\Borland C++\Borlandc\BIN to autoexec.tsh so it looks like the following:

    Code:
    PATH="C:\Program Files\Mts";C:\Borland C++\BORLANDC\BIN;%PATH%
    The actual autoexec.bat contains these lines:

    Code:
    @ECHO OFF
    rem
    rem   *** DO NOT EDIT THIS FILE! ***
    rem
    rem   This file was created by the System Configuration Utility as
    rem   a placeholder for your AUTOEXEC.BAT file. Your actual
    rem   AUTOEXEC.BAT file has been saved under the name AUTOEXEC.TSH.
    rem
    Rebooted the machine but I'm still having the same error when running the above code.

    What did I do wrong? What else do I need to do?

    Thanx.
    Last edited by CodeFuse; 03-14-2003 at 07:33 AM.

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    2
    The advise about bcc32.cfg was for bc 5.5. As I undestand you have early version like 3.0 or less.
    Try to add
    SET INCLUDE = C:\Borland C++\BORLANDC\INCLUDE;
    SET LIB = C:\Borland C++\BORLANDC\LIB;
    to your autoexec.bat
    or try to finde place in IDE where you can set these directories.
    BTW you can download some newer compiles for free.

  9. #9
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    #include iostream not iostream.h

    Your compiler is no longer guaranteed to have iostream.h because it is no longer standard.

  10. #10
    Registered User
    Join Date
    Mar 2003
    Posts
    11
    <iostream> didnt work either.

    Well, guess I need to d/load something newer.

    Any compiler should do the job I think...

    Thanx.

  11. #11
    Registered User
    Join Date
    Mar 2003
    Posts
    11
    Hi

    Just installed Bloodshed Dev C++ 4. Looks cool w/ the Gnome icons, like working in Linux itself

    Installation was smooth and my sample program/code above ran ok except that after hitting the Return key to enter a second number, the DOS window immediately vanished w/o displaying the total peas and the DevC++ window instatntly maximized.

    The FAQ says to insert these lines at the end of my code. I did that, still same thing.

    Code:
    #include <stdlib.h>
    
    int main()
    {
    
    system(“PAUSE”);
    	return 0;
    
    }
    Where exactly do I need to include these lines? If I just copied the whole thing then there would be 2 lines of int main() and return 0; ???

    Need help!

    Thanx.

  12. #12
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    And which FAQ are you reading ?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  13. #13
    Registered User
    Join Date
    Mar 2003
    Posts
    11
    From DEV C++ help drop down menu.

    I got around the problem, by simply choosing compile and run. If I just choose run, seems to me like whatever changes I make to the code wont be read. Instead the "old" code gets run.

    Thanx for the links

  14. #14
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    > If I just choose run, seems to me like whatever changes I make to the code wont be read.
    That's because it doesn't compile the code. You have to choose compile and run in order to compile the code.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 05:44 PM