Public Group

# Code::Blocks problem

This topic is 2555 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

Thnx

##### Share on other sites
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>.

##### Share on other sites
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..)

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

##### Share on other sites

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?

##### Share on other sites
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
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).

##### Share on other sites
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?

##### Share on other sites
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.

##### Share on other sites

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

##### Share on other sites

[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++ ?

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631712
• Total Posts
3001849
×