Skip to content

Instantly share code, notes, and snippets.

@jclosure
Created August 4, 2017 00:17
Show Gist options
  • Save jclosure/36d437911b56f8f6a6e1c48550f495a2 to your computer and use it in GitHub Desktop.
Save jclosure/36d437911b56f8f6a6e1c48550f495a2 to your computer and use it in GitHub Desktop.
Find the locations of your gcc/g++ header files

Ubuntu 14.04 Examples of finding GCC/G++ support libs

# default in trusty
g++ -xc++ -E -v -

/usr/include/c++/4.8 /usr/include/x86_64-linux-gnu/c++/4.8 /usr/include/c++/4.8/backward /usr/lib/gcc/x86_64-linux-gnu/4.8/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/include

g++-6 -xc++ -E -v -

/usr/include/c++/6 /usr/include/x86_64-linux-gnu/c++/6 /usr/include/c++/6/backward /usr/lib/gcc/x86_64-linux-gnu/6/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/6/include-fixed /usr/include/x86_64-linux-gnu /usr/include

g++-7 -xc++ -E -v -

/usr/include/c++/7 /usr/include/x86_64-linux-gnu/c++/7 /usr/include/c++/7/backward /usr/lib/gcc/x86_64-linux-gnu/7/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed /usr/include/x86_64-linux-gnu /usr/include

Note

This shows the default output of different versions of g++ I have installed. These directories will need to be targeted by projects based on the version of the language being used. See this page for a list of versions of gcc and the versions of cpp they map to: cxx-status

@jclosure
Copy link
Author

jclosure commented Aug 20, 2017

There are a few recommended ways to use a different version of gcc than the default.

For a single shell or invocation:

export CC=gcc-7
export CXX=g++-7

To permanently retarget:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment