omg.. compiler hates me

This is a discussion on omg.. compiler hates me within the C++ Programming forums, part of the General Programming Boards category; Code: /* Quest Open RPG * Ryan Oldenburg * Completion: 15% * Version 1.0 */ #include <windows.h> #include <iostream> #include ...

  1. #1
    PHP
    PHP is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    41

    omg.. compiler hates me

    Code:
    /* Quest Open RPG
     * Ryan Oldenburg
     * Completion: 15%
     * Version 1.0
     */
    
    #include <windows.h>
    #include <iostream>
    #include <string>
    #include "class.h"
    
    using namespace std;
    using std::string;
    
    //Constructor
    player::player(int healthv, 
                   int weaponv, 
                   int shieldv, 
                   int arrowsv, 
                   int magicv, 
                   int bombsv, 
                   int goldv, 
                   int bowv) : health(healthv), 
                               weapon(weaponv), 
                               shield(shieldv), 
                               arrows(arrowsv), 
                               magic(magicv), 
                               bombs(bombsv), 
                               gold(goldv), 
                               bow(bowv)
    {
    
    }
    
    //Acual Program
    int main()
    {
    //Location Variables
    int x;
    int y;
    
    //Introduction
    string title = "Quest Open RPG";
    
    for(int a = 0; title[a] != '\0'; a++)
    {
         cout << title[a];
         Sleep(50);
    }
    
    return 0;
    }
    nothing wrong with that right? look at the errors i get:

    Linker Error unidentified refrence to 'cout'
    Linker Error unidentified refrence to 'ostream:perator<<(char)'
    Linker Error unidentified refrence to 'endl(ostream&)'
    Linker Error unidentified refrence to 'cerr'
    Linker Error unidentified refrence to 'ostream:perator<<(char const *);
    Linker Error unidentified refrence to '__out_of_range(char const *)'
    Linker Error unidentified refrence to '__length_error(char const *)'

    Build Error Project.exe Error 1

    but i dont get any when i remove windows.h from the include and remove Sleep(50); ..... what the hell is goin on?! thanx

  2. #2
    ! |-| /-\ +3 1337 Yawgmoth's Avatar
    Join Date
    Dec 2002
    Posts
    187
    Two things:
    1. Do you really need windows.h and sleep(50) in your program? If not, you could just remove them and compile peacefully.
    2. What compiler are you using?

  3. #3
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Talking

    Could be a namespace issue.

    Code:
    using namespace std;
    using std::string;
    Mr. C: Author and Instructor

  4. #4
    PHP
    PHP is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    41
    dev c++, im using Sleep(50) to make it a typing effect, if you have any other ideas, ill use it instead
    In order of learned:
    HTML - Mastered
    CSS - Enough to use
    SSI - Mastered
    PHP - Advanced
    C/C++ - Current Project

  5. #5
    ! |-| /-\ +3 1337 Yawgmoth's Avatar
    Join Date
    Dec 2002
    Posts
    187
    I used to use Dev-C++, but then it refused to compile anything with #include <iostream.h>, so I moved onto Borland's free compiler. You have to compile from the command line, but it isn't as bad as it sounds. The hardest part is getting it set up, as Borland's documentation is not that clear.


    EDIT:Fixed glaring typoes.

  6. #6
    PHP
    PHP is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    41
    hehe, what a pitiful compiler if it cant use the most basic of includes......
    In order of learned:
    HTML - Mastered
    CSS - Enough to use
    SSI - Mastered
    PHP - Advanced
    C/C++ - Current Project

  7. #7
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    This compiles and runs on mingw. Can you write out
    not just the warnings but the command line arguments
    used to invoke the compiler and linker?


    Code:
    /* Quest Open RPG
     * Ryan Oldenburg
     * Completion: 15%
     * Version 1.0
     */
    
    #include <windows.h>
    #include <iostream>
    #include <string>
    using namespace std;
    using std::string;
    
    class player {
        int health;
        int weapon;
        int shield;
        int arrows;
        int magic;
        int bombs;
        int gold;
        int bow;
    public:
        player(int healthv, 
    	   int weaponv, 
    	   int shieldv, 
    	   int arrowsv, 
    	   int magicv, 
    	   int bombsv, 
    	   int goldv, 
    	   int bowv);
    };
    
    //Constructor
    player::player(int healthv, 
                   int weaponv, 
                   int shieldv, 
                   int arrowsv, 
                   int magicv, 
                   int bombsv, 
                   int goldv, 
                   int bowv) : health(healthv), 
                               weapon(weaponv), 
                               shield(shieldv), 
                               arrows(arrowsv), 
                               magic(magicv), 
                               bombs(bombsv), 
                               gold(goldv), 
                               bow(bowv)
    {
    
    }
    
    int main()
    {
        int x;
        int y;
    
        string title = "Quest Open RPG";
    
        for(int a = 0; title[a] != '\0'; a++)
        {
    	cout << title[a];
    	Sleep(50);
        }
    
        return 0;
    }

  8. #8
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by PHP
    hehe, what a pitiful compiler if it cant use the most basic of includes......
    no, the moron just set it up wrong
    hello, internet!

  9. #9
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by Yawgmoth
    I used to use Dev-C++, but then it refused to compile anything with #include <iostream.h>, so I moved onto Borland's free compiler. You have to compile from the command line, but it isn't as bad as it sounds. The hardest part is getting it set up, as Borland's documentation is not that clear.


    EDIT:Fixed glaring typoes.
    no, the moron just set it up wrong
    I agree. You must have set up Dev-C++ wrong if you can't include iostream correctly.

  10. #10
    PHP
    PHP is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    41
    how can i set it up wrong, i just clicked next, next, next and poof done
    In order of learned:
    HTML - Mastered
    CSS - Enough to use
    SSI - Mastered
    PHP - Advanced
    C/C++ - Current Project

  11. #11
    lurker
    Guest
    If you go to the bloodshed forum, you'll see posts about problems with 4.9.7.0. Also, you should've had a choice between teh mingw compiler 2.95 or 3.2. It seems that 3.2 is much more compliant, so you cannot use iostream.h, you have to include <iostream> and then specify either 'using namespace std' or 'using std:cout' (my syntax may be incorrect, but you get the idea0. There have also been problems with the download, I'm not sure exactly what they are, something about files going into an incorrect folder/path. There are posts on how to fix it on the bloodshed forum. I haven't upgraded to 4.9.7, still using 4.9.6.9 which has none of these problems. Once you get all the stuff in the right place it should work quite well. Good luck!

  12. #12
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by PHP
    how can i set it up wrong, i just clicked next, next, next and poof done
    I was speaking to Yawgmoth.

    Anyways, the original code posted compiles and links correctly with mingw 3.2. Nevermind, just saw Nick's post, same thing I did.

  13. #13
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by lurker
    It seems that 3.2 is much more compliant, so you cannot use iostream.h
    i have 3.2 in front of me right here, and it allows <iostream.h> or <iostream>
    hello, internet!

  14. #14
    Lurker
    Guest
    Sorry for my mistake, I was just going by the posts I've been reading on the bloodshed forum. It seems that if you use
    <iostream.h> versus <iostream> that dev-cpp 4.9.7 spits out many, many errors. I am using 4.9.6.9 for now, as it is working without problems for me. Once I have some free time at home to thouroughly understand what I may need to do to get it to work correctly, I'll download 4.9.7. Thanks for the clarification.

  15. #15
    moi
    moi is offline
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by Lurker
    Sorry for my mistake, I was just going by the posts I've been reading on the bloodshed forum. It seems that if you use
    <iostream.h> versus <iostream> that dev-cpp 4.9.7 spits out many, many errors. I am using 4.9.6.9 for now, as it is working without problems for me. Once I have some free time at home to thouroughly understand what I may need to do to get it to work correctly, I'll download 4.9.7. Thanks for the clarification.
    a slight word of warning i do not use devc++, just mingw, so if there's any <iostream> vs <iostream.h> problem that is caused by devc++, then i won't know of it
    hello, internet!

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I think my compiler hates me
    By Matty_Alan in forum C Programming
    Replies: 4
    Last Post: 07-15-2007, 12:22 AM
  2. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  3. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  4. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 05:42 AM
  5. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 10:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21