Menu

compiling doesn't work (noob)

miva2
2008-09-04
2012-09-26
  • miva2

    miva2 - 2008-09-04

    okay, first of all i'm a noob. both on this website and at programming C++ and programming in general (except those weird things i got at school but those don't count xD)
    i have read (well more like looked through) the FAQ and the "PLEASE READ BEFORE POSTING A QUESTION" thread. i've also searched a bit with google, that's how i got here. but i have not seen what i need.
    i'm (trying to start) learning C++ with a book called "Beginning C++ Game programming" by Michael Dawson. it has a cd in the back with Dev-C++ on t + the source codes for the programs. so there are no typos in the source code. i have had Dev-C++ before too and it didn't work either. the same problem i think but i don't remember the logs.

    i'll start with the 'basic 3' (proof that i've read those stuff haha)
    1) i am using windows vista and have Dev-C++ 4.9.9.2
    2) this example program is actually the whole thing lol. it's the first program in the book. same as a "hello world" program.

    // Game Over
    // A first C++ program

    include <iostream>

    int main()
    {
    std::cout << “Game Over!” << std::endl;
    return 0;
    }

    3) compile log:

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Users\Michael\Documents\C++ boek\game_over.cpp" -o "C:\Users\Michael\Documents\C++ boek\game_over.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
    C:\Users\Michael\Documents\C++ boek\game_over.cpp: In function int main()': C:\Users\Michael\Documents\C++ boek\game_over.cpp:6: error: stray '\147' in program C:\Users\Michael\Documents\C++ boek\game_over.cpp:6: error:Game' undeclared (first use this function)
    C:\Users\Michael\Documents\C++ boek\game_over.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
    C:\Users\Michael\Documents\C++ boek\game_over.cpp:6: error: expected `;' before "Over"
    C:\Users\Michael\Documents\C++ boek\game_over.cpp:6: error: stray '\148' in program

    Execution terminated

    i have done as instructed in the book but it gives errors while compiling. when i tried to make something before i had the book it gave errors about iostream.h. apparently this code does not put ".h" behind iostream but i guess it's the same. could it be that i don't have that file or something like that?
    when i was folowing the book and i put the code in dev i somehow managed to make it run. i even did it multiple times because the console window dissapeared automatically and i couldn't read it that fast xD. i have peeked a bit further in the book and i have to make a V2 of it so that it stays but that's for later, when it compiles.
    and then suddenly it didn't work anymore. i didn't really change any options, and it's not the code either. i closed and restarted the program but it was the same. i uninstalled and re-installed it but stil the same. i tried to update it but i think i have the latest version. it could be because i am using vista but it gave the same results when i opened it in compability modus of windows XP. i do not have SP1 though. maybe i should install that, but it takes so much time lol and i don't like closing my other applications, haha :p

    there is a thread named "Errors Compiling in new Windows VISTA" here http://sourceforge.net/forum/message.php?msg_id=4156252
    i don't know if this got anything to do with it.

    is there someone here who can help me with this? :)
    any help is greatly appreciated.
    if you need more to solve this then just ask

     
    • Wayne Keen

      Wayne Keen - 2008-09-06

      One note on posting technique. One had to read through the bulk of your post to get to:

      "oh wait...i just tried copypasting it in a new source file...and it works now -_- "

      In other words, they had to read almost all of your post to find that you really didn't
      have a question.

      Have a definitive question. Be clear about what it is. Be clear about what the data
      is (Basic 3 etc.). Avoid excessive narrative accounts that wait until the end of the
      post to get to the point of what your question is.

      Remember, the complete strangers you are asking for help for free are providing you
      something of value. Respect that by the way you ask your question.

      Wayne

       
      • cpns

        cpns - 2008-09-06

        Indeed. I started writing an answer before I got to that last part! What a waste.

         
    • Wayne Keen

      Wayne Keen - 2008-09-04

      Your problem is right here:

      std::cout << “Game Over!” << std::endl;
      -------------^----------^

      You are using the wrong quotes - they should look like this "

      Wayne

       
    • cpns

      cpns - 2008-09-04

      > so there are no typos in the source code.

      That's a bold statement. You mean you added no typos. You overestimate the quality assurance of the publisher.

      I imagine that the author composed his text in Microsoft Word and allowed 'Intelli(non)sense' to convert quote marks to left and right glyphs. Unfortunately it would appear that he then used this rather than the original code (if there ever was any).

      I usually suggest checking the publisher's website for errata and downloads, but I did that, and there do not appear to be any. Which perhaps suggests something about the publisher.

      Congratulations BTW on a clearly posed question, with all necessary information. You might have saved yourself a lot of time however, since in most cases, the code, log, OS, and Dev version are all that is necessary. Apart from the fact that it is just polite, you almost need not have actually asked the question explicitly! If more information is necessary it will be asked for.

      Unrelated, but important; you have read the "PLEASE READ BEFORE POSTING A QUESTION" but have not applied the advice about spaces in project paths.

      Clifford

       
    • miva2

      miva2 - 2008-09-06

      thank you for your fast response and useful messages.

      Wayne, i'll try changing the quote signs then :) i didn't knew it made any difference

      Clifford, i thought it was correct. i looked in the book and checked if the code was correct. but like i just said, i thought the kind of quotes made no difference. thanks for congratulating me lol. i'm sorry for not having applied the spaces thing but i don't even know what project paths are. i'll check it out again then :p

      i will post another message once i have tried it. although i think it won't make any difference since i had a similar problem before and i got my codes from another resource.

       
    • miva2

      miva2 - 2008-09-06

      i started Dev-C++ again and took the code from the CD. but it seems to be a bit different then that i had copypasted here. "game over" is written in red now and does have the correct quotes. i copypasted my codes from Dev-C++ last time. but i had saved them somewhere in a folder and i think something went wrong there or whatever. well here is the code like i got it from the CD

      // Game Over
      // A first C++ program

      include <iostream>

      int main()
      {
      std::cout << "Game Over!" << std::endl;
      return 0;
      }

      compile log:
      Compiler: Default compiler
      Executing g++.exe...
      g++.exe "F:\source\chapter01\game_over.cpp" -o "F:\source\chapter01\game_over.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
      C:\Dev-Cpp\Bin..\lib\gcc\mingw32\3.4.2........\mingw32\bin\ld.exe: cannot open output file F:\source\chapter01\game_over.exe: Permission denied
      collect2: ld returned 1 exit status

      Execution terminated

      i got this message
      [URL=http://imageshack.us][IMG]http://img78.imageshack.us/img78/4230/sfpic1za2.jpg[/IMG][/URL]
      By [URL=http://profile.imageshack.us/user/miva2]miva2[/URL]
      i pressed no.
      do i first have to save the source code in a different folder (like i did before) and then open that file or open the file on the cd and copypaste the code in a new source file?
      oh wait...i just tried copypasting it in a new source file...and it works now -_-
      i'm sorry to have wasted your time gentlemen. i retried it many times in different ways. i wonder why i didn't try this before.
      well thanks for help anyway. maybe the same problem will reoccur later? let's hope not :)

       
    • cpns

      cpns - 2008-09-06

      > i don't even know what project paths are.
      It's where you saved your project files. In this case: C:\Users\Michael\Documents\C++ boek\

      > although i think it won't make any difference since
      > i had a similar problem before and i got my codes from
      > another resource.
      The “...” are quite definitely wrong. C and C++ use only a subset of ASCII code, and neither of those characters are valid in any C code.

      > i got this message http://img78.imageshack.us/img78/4230/sfpic1za2.jpg
      Compiling code involves writing files to the disk. You cannot perform the compile on a CD!

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.