Code::Blocks problem

Started by
9 comments, last by Hoody 12 years, 9 months ago
Ok just started working my way through the book "Beginning C++ through game programming" The book say's to use Dev-C++ but after reading a thread the other day it seems this hasn't been updated in some time and code::blocks was more in favor. I have installed this and typed in the basic hello world program from the book and yet i have got 6 errors :s includeing one that claims there is an error with iostream (no such file exists) anyone have any ideas what i have done wrong? image of the errors here.

codeblocks.jpg



Thnx
Advertisement
Notice your file's name is "first.cpp.c". It should be "first.cpp". You are probably trying to compile it as a C program, and there is no <iostream> in C.

EDIT: Also, you misspelled "namespace", and you don't need to call `system'. People often call `system' to compensate for some flaw in their programming environment (the window where the program is run from the IDE closes when the program exits and you don't get to see the output), but I think it's better to fix the IDE, or just run the program from the command line. There are several problems with using `system', but If you still want to do it, you need to include <cstdlib>.
Thnx for the reply. I had originally saved the file as a c/c++ file, realised this may be wrong and tried to rename it as a .cpp file which obviously didn't work. i have fixed the namespace problem. and the "system" line i added so that i can see the program running without it running and instantly disapeering. Will try with this for a while longer. but if Code::Blocks is going to cause too much hassle i may just try using VS2008 (have a full copy somewhere that was supplied when i was at uni..)
right-click your file in project view, go to Properties -> Advanced, check the "Compiler variable", if it says "CC" replace it with "CPP"
OpenGL fanboy.

right-click your file in project view, go to Properties -> Advanced, check the "Compiler variable", if it says "CC" replace it with "CPP"


Thnx, i think i have done this right? but where do i check the compiler variable? as it seems greyed out?


cb2.jpg
Do you have a compiler installed?

http://wiki.codeblocks.org/index.php?title=Installing_the_latest_official_version_of_Code::Blocks_on_Windows


Install steps
  1. Download the Code::Blocks 10.05 installer. [color="#FF0000"]If you know you don't have MinGW installed, [color="#FF0000"]download the package which has MinGW bundled.
  2. Run the installer, it's a standard installer for Windows; just press Next after reading each screen.
  3. [color="#000000"]If you're planning installing a compiler after you've installed Code::Blocks, read the information provided in the installer.
  4. [color="#FF0000"]If you downloaded the installer which doesn't come with MinGW, you may have to configure the compiler manually (usually Code::Blocks' auto detects the compiler).
Believe so, i downloaded and installed the combined code::blocks and MinGW package and this seems to indicate it is set up as the compiler?

mingw.jpg
Why are you still calling the file .c? It is not a C program and therefore you should not use the .c extension, period. Call it a .cpp file like it belongs.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


Why are you still calling the file .c? It is not a C program and therefore you should not use the .c extension, period. Call it a .cpp file like it belongs.



Could well be me being a tard but i have tried all of the save as options within Code::Blocks and none of them at this time save as a .cpp file :s (honestly do not know why..) tried right clicking/renameing the file as a .cpp and this is how it became a .cpp.c

[quote name='ApochPiQ' timestamp='1310934223' post='4836475']
Why are you still calling the file .c? It is not a C program and therefore you should not use the .c extension, period. Call it a .cpp file like it belongs.



Could well be me being a tard but i have tried all of the save as options within Code::Blocks and none of them at this time save as a .cpp file :s (honestly do not know why..) tried right clicking/renameing the file as a .cpp and this is how it became a .cpp.c
[/quote]

Maybe you created a C project instead of C++ ?

This topic is closed to new replies.

Advertisement