Hi,

I recently started learning C++ and have decided to install it onto my computer to try writing some codes. So I chose Code Block as my IDE since it is free. I know, since I use Windows 7, you will probably recommend Visual C++. But I want to stick to Code Blocks since I have practice with it a few weeks back using my school's system.

So I installed code block. Now I try to type C++ but apparently it is not working. What I mean is I have the IDE but it would appear that I need the SDK as well.

Sorry I might be phrasing this incorrectly. Here is an analogy, when I install a Java IDE of my choice, I am also required to install the development kit of Java from Sun microsystem so that I actually "installed Java" correctly. Now I want to perform this step correctly in C++. Tried to keep it as brief but as clear as possible. Thank you for taking the time to help.

Sincerely,

Limiter

Edited 5 Years Ago by Limiter: n/a

To reach the point of being able to write and run a C++ program, you need three things. A text editor to write the code, a compiler to turn the text files into object files, and a linker to tie the object files together into an executable or library. If you have installed Code::Blocks, presumably from here:

http://www.codeblocks.org/downloads

and installed it, you have everything you need except the compiler/linker.

http://www.codeblocks.org/features

Note the list of supported compilers. You must get one of these and tell Code::Blocks which one you have chosen. They generally come with the linker as well, so you don't need to worry about that. You're not missing an SDK; you're missing the actually program that takes your text files and turns them into binary object files.

If you have correctly installed Code::Blocks and the compiler, you should be able to compile and build the following:

#include <iostream>

int main()
{
  std::cout << "Hello world" << std::endl;
  return 0;
}

There is no SDK or the like needed; this uses only functionality mandated in the C++ language. If you cannot build this code, there is something wrong in your Code::Blocks installation or settings.

Edited 5 Years Ago by Moschops: n/a

Okay, for the linker, sorry I am really new to how C++ does stuff.

What do you recommend if my purpose is just to work on homework assignments?

No, I would not recommend Visual C++. M$ has a free version of it, (Visual C++ Express Edition), but I dislike VC because it is slow and ugly.
The IDE is called IDE, but there is no "SDK". There is a compiler, that IDE uses to produce the .exe files.
Download CodeBlocks with mingw compiler packaged with it. Code::Blocks website has Windows Installer and 2 versions, one small, about 23 MB and a big one 70+ MB. Download and install the bigger one and tell us your results.

Hello, so I installed the larger file and made sure to check GNU compiler during setup.

After, I tried to compile Moschops sample code and right from line 1, it says error: iostream: No such file or directory. Therefore, as expected, line 5 also has an error because without iostream, the compiler won't know what is the ":" inside std::

PS: How do I stop a code block program from running if I accidentally ran a program with an infinite loop, I mean is there a short key to kill a running code?

Edited 5 Years Ago by Limiter: n/a


PS: How do I stop a code block program from running if I accidentally ran a program with an infinite loop, I mean is there a short key to kill a running code?

A code::blocks program is just an ordinary regular program. You kill it like you would any other program. CTRL-C is a good first try, and failing that on windows you've always got the task manager to find and kill the process.

As for include directories; Code::Blocks has an option somewhere near the choice of compiler to dictate include paths to search for headers. Make sure that the MinGW directory containing the standard header files is on it.

Edited 5 Years Ago by Moschops: n/a

Hello, so I installed the larger file and made sure to check GNU compiler during setup.

After, I tried to compile Moschops sample code and right from line 1, it says error: iostream: No such file or directory. Therefore, as expected, line 5 also has an error because without iostream, the compiler won't know what is the ":" inside std::

PS: How do I stop a code block program from running if I accidentally ran a program with an infinite loop, I mean is there a short key to kill a running code?

UPDATE:

Sorry, the edit post button disappeared on me.

Anyways, I found out my first problem, if I download an empty .cpp file and do it from there, it works. The reason why I had the problem was because Code blocks saved the file in .c even though it says that the extension is c/c++.

So two question here, one old, one new. How to stop a running program with an infinite loop as specified above (like on Linux)and how to create a .cpp file in windows?

Edited 5 Years Ago by Limiter: n/a

I use Bloodshed to create .cpp in Windows:
http://www.bloodshed.net/download.html
Works pretty well so far.

I don't know if I'm understanding your infinite loop question though. If your program is running an infinite loop, just force close it. If you're asking how to catch where the infinite loop is coming from, you could use the debugging feature of the IDE I've provided. Just put in a break point and step through the program.

how to create a .cpp file in windows?

Make a text file and name it something.cpp and it's now a cpp file.

A cpp file and a c file are identical in filetype; they're just plain text.

Edited 5 Years Ago by Moschops: n/a

So two question here, one old, one new. How to stop a running program with an infinite loop as specified above (like on Linux)and how to create a .cpp file in windows?

<sarcasm>
Question one: There is a small red square at the top of every Window. On Windows it is on the right side of the screen and on Linux usually on left. It has a small X on it. Do you see it? It is magical button that stops the program. If that does not work, check your computer, for a big button, which usually used to turn on the computer. If you hold it for a while, computer will turn off. If that does not work there is always the power plug ;)

Question two: Right click on desktop -> new text document -> change the extension to .cpp and you have a .cpp file!
</sarcasm>

Edited 5 Years Ago by sergent: n/a

This article has been dead for over six months. Start a new discussion instead.