Where are the headers of the C++ standard library

73,760

Solution 1

GCC typically has the standard C++ headers installed in /usr/include/c++/<version>/. You can run gcc -v to find out which version you have installed.

At least in my version, there is no vector.h; the public header is just vector (with no extension), and most of the implementation is in bits/stl_vector.h.

That's the case on my Ubuntu distribution; your distribution may differ.

Solution 2

Running g++ -v -v -v outputs lots of things, including all the include directories searched. vector is in one of those.

Solution 3

On my Debian Stable system vector is here:

/usr/include/c++/4.4/vector

Solution 4

On a "plain" ubuntu install you have to install

libstdc++-version-dev

to get the header files.

then cheking the installed files you'll get the path !

Share:
73,760
Thomas
Author by

Thomas

I'm a mathematician working in Magdeburg, Germany.

Updated on December 27, 2020

Comments

  • Thomas
    Thomas over 3 years

    I wonder where on my file system I find the headers of the C++ Standard library. In particular I am looking for the definition of the vector template. I searched in /usr/include/ and various subdirectories. I also tried 'locate vector.h' which brought up many implementations of vectors, but not the standard one. What am I missing? (The distribution is Gentoo)

    Background: I'm profiling a library that iterates over vector's most of the time and gprof shows that most of the time is spent in

    std::vector<int, std::allocator<int> >::_M_insert_aux(
      __gnu_cxx::__normal_iterator<int*, std::vector<
          int, std::allocator<int> > >, int const&)
    

    Probably this is what happens internally on a std::vector::push_back, but I'm not sure.

  • Thomas
    Thomas almost 12 years
    Is it vector.h ? Which package provides it? gcc?
  • Thomas
    Thomas almost 12 years
    Thanks, the missing .h ws the essential hint. On Gentoo it's in /usr/lib64/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4/vect‌​or