Do I need to do something to compile my C ++ program using gcc?

Why does my program compile beautifully without warning when I type g++ program_name , but when I type gcc program_name , I get undefined screen errors.

I use the standard library quite a bit, here my includes:

 #include<string> #include<vector> #include<fstream> #include<sstream> #include<iomanip> #include<iostream> #include<algorithm> using namespace std; 

I ask that I have been developing a solution all the time to solve the codeeval.com problem. It works great when compiling with g ++, but will not compile with gcc.

In short, when codeeval tries to run my stuff, I get a score of 0 (!), Although I have no idea how they go to test the materials ... They just say: Your program did not pass all the test cases or there may have been warnings printed out at runtime .

Of course, I have no idea how they compile them ... They say:

You submissions are executed in a *NIX type environment. Assume softwares/shells etc are in their standard locations. Nothing else.

(since they have a typo in their shipping instructions, can other things come up?)

They also say that they make decisions for C ++ 4.3.4. I am running cywin, and 4.3.4 is the version of my gcc.

Has anyone else had a problem sending code in C ++ to codeeval.com?

I try not to be super disappointed, but at the moment they seem more like codeevil.com to me ...

+4
source share
2 answers

gcc does not reference the standard C ++ libraries by default. Either add -lstdC ++ to the link line, or simply compile with g ++.

+5
source

Strictly speaking, "gcc" is the Gnu C compiler, and "g ++" is the corresponding C ++ compiler. Personally, I prefer to use the former for C, the latter for C ++, rather than relying on file suffixes or command line arguments.

+1
source

All Articles