Sign in to follow this  
Hoody

Code::Blocks problem

Recommended Posts

Hoody    170
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.

[img]http://i45.photobucket.com/albums/f60/sidthesexist/codeblocks.jpg[/img]



Thnx

Share this post


Link to post
Share on other sites
alvaro    21247
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 [url="http://www.cplusplus.com/forum/articles/11153/"]several problems[/url] with using `system', but If you still want to do it, you need to include <cstdlib>.

Share this post


Link to post
Share on other sites
Hoody    170
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 this post


Link to post
Share on other sites
Hoody    170
[quote name='i_luv_cplusplus' timestamp='1310920768' post='4836404']
right-click your file in project view, go to Properties -> Advanced, check the "Compiler variable", if it says "CC" replace it with "CPP"
[/quote]

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


[IMG]http://i45.photobucket.com/albums/f60/sidthesexist/cb2.jpg[/IMG]

Share this post


Link to post
Share on other sites
J*A*G    100
Do you have a compiler installed?

[url="http://wiki.codeblocks.org/index.php?title=Installing_the_latest_official_version_of_Code::Blocks_on_Windows"]http://wiki.codeblocks.org/index.php?title=Installing_the_latest_official_version_of_Code::Blocks_on_Windows[/url]


[b] Install steps [/b]
[list=1][*] [url="http://www.codeblocks.org/downloads/26"]Download the Code::Blocks 10.05 installer[/url]. [color="#FF0000"]If you know you don't have MinGW installed,[/color] [color="#FF0000"]download the package which has MinGW bundled[/color].[*] Run the installer, it's a standard installer for Windows; just press Next after reading each screen.[*] [color="#000000"]If you're planning installing a compiler after you've installed Code::Blocks, read the information provided in the installer. [/color][*] [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)[/color].[/list]

Share this post


Link to post
Share on other sites
Hoody    170
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?

[IMG]http://i45.photobucket.com/albums/f60/sidthesexist/mingw.jpg[/IMG]

Share this post


Link to post
Share on other sites
Hoody    170
[quote name='ApochPiQ' timestamp='1310934223' post='4836475']
Why are you still calling the file .c? [i]It is not a C program and therefore you should not use the .c extension, period[/i]. Call it a .cpp file like it belongs.
[/quote]


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 this post


Link to post
Share on other sites
J*A*G    100
[quote name='Hoody' timestamp='1310934776' post='4836479']
[quote name='ApochPiQ' timestamp='1310934223' post='4836475']
Why are you still calling the file .c? [i]It is not a C program and therefore you should not use the .c extension, period[/i]. Call it a .cpp file like it belongs.
[/quote]


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

Share this post


Link to post
Share on other sites
Hoody    170
[quote name='J*A*G' timestamp='1310937899' post='4836501']
Maybe you created a C project instead of C++ ?
[/quote]

Was originally created by clicking file/new/empty file.


Thnx for the help anyway everyone. Think i'm just gonna give up on this ide and use another instead. At least Dev-C++ works without this hassle..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this