title: Ubuntu 12.04 C++11 code not working
body: <p>This had been bending my mind in the last few days. I also wasn't sure whether to post this in ask ubuntu or here. I chose here to get a wider programmer-based audience.</p>
  
  <p>I am brand new to Ubuntu and GCC, however I've been programming C++ on windows for about 5 years. This simple C++11 code sample works fine on my Windows machine with VS2010.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  
  std::function&lt;void()&gt; func;
  
  int main() {
      std::cout &lt;&lt; "!!!Hello World!!!" &lt;&lt; std::endl; // prints !!!Hello World!!!
      return 0;
  }
  </code></pre>
  
  <p>With Eclipse CDT (Ubuntu 12.04), I get the error <code>Symbol 'function' could not be resolved</code>.</p>
  
  <p>I've made sure <code>build-essentials</code> is installed.</p>
  
  <p>I've added <code>/usr/include/c++/4.6.3</code> to my includes in eclipse.</p>
  
  <p>I've added <code>__GXX_EXPERIMENTAL_CXX0X__</code> to Paths and Symbols in eclipse.</p>
  
  <p>I've tried -std=c++11 on the command line.</p>
  
  <p>I've tried -std=c++0x on the command line.</p>
  
  <p>I've followed the Accepted answer here: <a href="https://askubuntu.com/questions/113291/how-do-i-install-gcc-4-7">https://askubuntu.com/questions/113291/how-do-i-install-gcc-4-7</a> and installed gcc 4.7</p>
  
  <p>Is this not supported with gcc? </p>
  
  <p>I've checked <code>auto</code> and it works, but things like <code>unique_ptr</code> don't work either, same error as above.</p>
  
  <p>Sorry again, I'm new to Linux.</p>
  
  <p><strong>Edit:</strong>
  As per n.m.'s request:</p>
  
  <pre><code>neil@ubuntu12:~/projects/Test/Test$ g++ -v;g++ -std=c++0x -o main main.cpp
  Using built-in specs.
  COLLECT_GCC=g++
  COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
  Target: i686-linux-gnu
  Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
  Thread model: posix
  gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
  neil@ubuntu12:~/projects/test$
  </code></pre>