Setting Eclipse to Compile with C++11

C++11 Linux Terminal Compile

A few days ago I was writing a program that required the use of new syntax from a newer standard of C++. I looked around trying to figure out where to tick a setting or add a line somewhere on Eclipse, but just couldn’t find where to do so! Now, I knew how to compile under the new standards on the Linux command line, but with the way my project was designed, being able to compile under Eclipse would be wayy more convenient. In this page, I will be going over how to compile C++11 under both the terminal and Eclipse.

Compiling under Ubuntu Terminal

Starting from the command line (I am running Ubuntu Linux 12.04), to compile a project under C++11, all you have to do is type:

g++ -std=c++0x *.cpp

Where *.cpp is replaced by the name of your driver file.

And run via


C++11 Linux Terminal Compile

All this is under the assumption that you already have the latest gcc installed. If you do not have them, here is a great tutorial by Colin Clark that explains how to do so. The version of Ubuntu he uses is 12.04 LTS (Long Term Support). That is also the version that I am using.

Compiling in Eclipse

To compile in Eclipse:

  1. Under the project explorer on the left sidebar, find your project and right click into Properties.
    Properties setting in Eclipse for C++11
  2. In properties, find C/C++ Build and expand it.

    Setting Eclipse to Compile C++11 C++0x

    C/C++ Build >> Settings >> GCC C++ Compiler >> Miscellaneous >> “Other flags”

  3. Navigate settings and under GCC C++ Compiler, click into Miscellaneous.
  4. Add “-std=c++0x” onto the end of the line under “Other flags“.

And that is all. Congratulations, now go use the new auto function!

Kevin Lin

I am a senior at Wake Forest University currently pursuing my BS in Computer Science, and I love technology! To learn a little more about me, please visit the "Meet Kevin" widget on the top right on the screen!
Posted in C++, Programming. Tagged with , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *