Results 1 to 11 of 11

Thread: Borland Errors

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2002
    Posts
    22

    Borland Errors

    #include <iostream.h>

    int main()

    {

    cout<<"HEY, you, I'm alive! Oh, and Hello World!";

    return 0;

    }

    Been looking through Tutorial sites and just copy pasted the code over everything and I get two error's when I try to run the program...

    [Linker Error] Unresolved external '_Form1' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\PROJECT2.OBJ
    [Linker Error] Unresolved external 'TForm1::' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\PROJECT2.OBJ

    Any reason for this? Was there something I shouldn't have pasted over for it to run?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I don't know why you're getting the errors, but don't use <iostream.h>

    Code:
    #include <iostream>
    using namespace std;
    
    int main() {
    
        cout << "HEY, you, I'm alive! Oh, and Hello World!";
    
        return 0; 
    
    }
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Most people using C++ Builder have trouble. It's not setup for "normal" C++ use, it assumes you're using the GUI (which is, obviously, not what you want in this instance).

    Apparently there was a way, but I'd need a copy to work it out, and I can't be bothered to boot back into Windows again.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    Well see this is how I do it for a Simple Hello World Proggy:

    #include <iostream.h>

    main() //notice no int before main, you dont need it
    {
    cout << "Hello Wolrd" << endl;
    return(0); // notice brackets around 0
    }
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    6 mistakes:

    1. <iostream> not <iostream.h>, the latter is deprecated.

    2. No "using namespace std;" -- everything in the Standard C++ Library is within that namespace.

    3. You *do* need the int. Implicit int was dropped because it caused trouble, and was totally incompatible with the type checking. It's since been dropped from C as well.

    4. You misspelled "World".

    5. No return statement is necessary in main(), and the parentheses aren't necessary either.

    6. ( ) == Parentheses. [ ] = Brackets. { } = Braces.


    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by FunyBunyFartAHH
    Well see this is how I do it for a Simple Hello World Proggy:

    #include <iostream.h>

    main() //notice no int before main, you dont need it
    {
    cout << "Hello Wolrd" << endl;
    return(0); // notice brackets around 0
    }
    Why do you use iostream.h?

    And if you're going all gung ho about not needing int before main, perhaps you will take notice that there's no need for brackets around 0.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by parksie
    ...
    You beat me to the punch, but regarding #5, I get a compiler error when not returning anything from main (when declared as int). What compiler do you use?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by The Hobo
    You beat me to the punch, but regarding #5, I get a compiler error when not returning anything from main (when declared as int). What compiler do you use?
    I get that error in VC++. I just tried with Borland and no error.

    So hats off to you. Just compiler differences.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    GCC 3.2. VC++7 works as well.

    The non-requirement for a return statement is part of the C++ standard -- if you don't return anything, the compiler is obliged to insert the equivalent to "return 0".
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  10. #10
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44

    Red face

    My bad, its borland, I use visual, and my bad for the world spelling error ; /
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by FunyBunyFartAHH
    My bad, its borland, I use visual, and my bad for the world spelling error ; /
    Regardless of your compiler, the code is still...crap.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width