Where are the headers of the C++ standard library

前端 未结 6 716
暖寄归人
暖寄归人 2021-02-01 02:58

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/inclu

相关标签:
6条回答
  • 2021-02-01 03:45

    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.

    0 讨论(0)
  • 2021-02-01 03:49

    In many IDE (e.g. NetBeans) you may use Ctrl+Click to className to go to definition

    0 讨论(0)
  • 2021-02-01 03:53

    The file location is actually compiler-dependent.

    You can use the bash tool "locate" to search for any of the files that you know are in the library. eg. "locate stl_multimap.h" for me yields:

    /usr/include/c++/5/bits/stl_multimap.h
    /usr/include/c++/6/bits/stl_multimap.h
    /usr/include/c++/7/bits/stl_multimap.h
    /usr/include/c++/8/bits/stl_multimap.h
    /usr/lib/gcc-snapshot/include/c++/9/bits/stl_multimap.h
    

    Once you have a look at the directories it should become pretty obvious where everything else is too.

    In each of those locations I'll find the different compiler versions of the file. For my computer, all the gcc 7.* files are in my /usr/include/c++/7 directory.

    If for some horrible reason you use Windows, I'm sure that you'll be able to find an equivalent command with Powershell.

    0 讨论(0)
  • 2021-02-01 03:57

    On my Debian Stable system vector is here:

    /usr/include/c++/4.4/vector
    
    0 讨论(0)
  • 2021-02-01 04:00

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

    0 讨论(0)
  • 2021-02-01 04:00

    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 !

    0 讨论(0)
提交回复
热议问题