Can't compile

As some other threads I have looked at stated, I am a very new member, working on my very first C++ program as we speak.

I would be much further on with my new career in C++ if only my code would compile.

Using this program:
1
2
3
4
5
6
7
8
9
//This is my first C++ program
#include <iostream>
using namespace std;

main()
{
    cout << "Hello world!";
    return 0;
}


When I try to compile it it says this: ""HelloWorld - Debug" uses an invalid compiler. Skipping...
Nothing to be done."

Now my only prior experience with programming is in Java with Eclipse.
Code::Blocks and Visual C++ are apparently very different IDEs and I really have no idea what is going on.

So my main issue is that I can't compile. If anyone knows what is wrong, go ahead and tell me!
Thanks!

I'm using Visual C++ as a compiler through Code::Blocks (I hope) if that helps.
Last edited on
1
2
3
4
5
6
7
8
9
10
//This is my first C++ program
#include <iostream>
using namespace std;

int main() // always int main()
{
    cout << "Hello world!";

    return 0;
}
Oh my god I feel like a moron.
Hours (not litterally) of scouring the interwebz for something so obvious.

EDIT: Well I did that and I am still getting the same problem... but thanks for the tip.

Is is possibley because I didn't set it to either "debug" or "release"? (Whatever those mean)
Last edited on
Things to check:
1. Your filename is ends with ".cpp". Most C++ compilers also come with C compilers. If the filename matches the C pattern (.c), the compiler will automatically choose the C compiler.
2. You created a C++ project, not a C project.

Debug and release are compilation methods. There are differences between compilers, but basically it's like this: debug doesn't optimize and leaves debugging information so a debugger can run the program and provide information such as the values of variables. Release optimizes and doesn't leave debugging information.
what helios said,
make sure that your source code is a .cpp (c ++) not .c ( standard C)
It is .cpp.
closed account (z05DSL3A)
"...uses an invalid compiler" suggests that Code::Blocks is not configured properly.
I've gone to file > properties > advanced > and saw that it (for some reason) had "GNU GCC Compiler", and not Visual C++'s compiler.

I've tried to change it and it seems to not let me.
I'm sorry that this is becomming more of a support question instead of a programming one.

Went to Settings > Compiler and debugger > selected the correct compiler (Visual C++), and it still doesn't seem to be doing anything.

EDIT: Now I'm getting this "fatal error LNK1169: one or more multiply defined symbols found"

EDIT EDIT: I fixed it! (had a second file in there, didn't realize it)
Last edited on
Topic archived. No new replies allowed.