Where can I download the source code to the GNU C++ Standard Library? - c++

I downloaded the GNU Standard C Library (glibc) source code at http://ftp.gnu.org/gnu/glibc/. Where can I find a similar download for their C++ Library?
I have googled around a bit and cannot seem to find it.
The only reason I need it is I want to see how it is implemented. So please don't give me links to binaries or to just the header files because it is the implementation source files that I am looking for.

It's in the libstdc++-v3 directory in the g++ (gcc-c++) sources.

GCC mirror sites:
https://gcc.gnu.org/mirrors.html
Looking for what you want.

Related

GNU GSL where do I find the source code?

I'm writing some code in which I use some of the GNU GSL functions.
And out of pure interest I wonder how these functions have been implemented, therefore I would like to have a look at the source code.
The problem is that I seem to be unable to find the directory at which it is located.
I know that I can find the headers in "/usr/local/include/gsl/", but where is the matching ".c" file?
Sorry if this is n00bing it, but i hope that someone can help me.
Just download a source package from their ftp, for example the latest version.
This contains all files to build this library, so not just the header files, but also the c files, together with a makefile, which specifies what is compiled in which order.
You can find the implementation on their Github page. An example of their implementation of computing mean https://github.com/ampl/gsl/blob/master/statistics/mean_source.c

Which files contains the implementations for malloc() and new()?

On Linux (Ubuntu) what is the path and file name where I can see the C/C++ code used in the malloc() and new() implementations?
I have looked in /usr/include but started to lose my way around. Does it depend on which version of gcc/g++ I have installed?
If someone could also give a general answer which would help me understand how Linux stores all the "native" functions it would be most appreciated and I wouldnt ever have to ask again for a different function.
One thing: new is a C++ keyword that uses malloc.
The source for malloc is in the source for your version of libc, which is probably glibc. Look at their source.
Other built in functions that are system calls only have shell implementations in glibc that call the underlying syscall.
The GIT of the GNU standard C lib implementation can be found here.
From this point in the tree you should be able to find the rest as well.
The "implementation" is a library you can link (an "a" file or an "so" file) plus an header that contains the declaration (an "h" file).
The C and CPP files sits on the computer that created those libraries before they had been used to build-up your system. And since their source is not required for your programs to work (you just link the binaries, not the sources) they are not distributed together with the system build.
That's why you have to download those files from the source repositories, jut like if you want yourself to rebuild the system.
You find this in the implementation of the C Standard Library the compiler uses.
I'm not sure for Ubunta. Debian's gcc uses eglibc, which's sources could be found here.

gtksourceview compiling in code blocks

i want to use gtksourceview in my c++ project. I dig around the IDE of code::blocks and really find it helpfull. i specify gtkmm directory in linker and include options but as i look for gtksourceview i found a libgtksourceview-2.0-0.dll file i really don't know how to add this in code::blocks and use gtksourceview. I am have programming experience in C for microcontrollers just and now i have not really idea about the compilation process of gcc and g++. and can i able to add the file directives as
#include <gtksourceview/gtksourceview.h>
please help
sorry if it seems so basic question for someone but i really stuck of to compile the code and then asking.
I am using windows by the way.
Thanks in advance
There are two different things: the runtime libraries and the development headers. The former allows you to run the applications (also to link them), the later to compile them. Either you are missing the header files (gtksourceview.h in your example) or setting the PATH in your IDE to find the header files.
Check the manual for 'Including libraries'.

where is the source code for the standard library in OCaml?

when looking at the standard library of OCaml I want to see the source code for the functions described, where can i find the code for these functions?
http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html this link shows the standard library for list, where can I find the code used for each of these?
just type as follows in your shell:
$ cd `ocamlc -where`
And you can see *.mli files, which has documentations.
The source code is available to browse from the OCaml Subversion repository:
http://caml.inria.fr/ocaml/anonsvn.en.html
For example, the stdlib code for the latest in-development OCaml version is here:
http://caml.inria.fr/cgi-bin/viewcvs.cgi/ocaml/trunk/stdlib/
There is a read-only mirror on github:
https://github.com/ocaml/ocaml
The standard library code is also available from an OCaml source tarball if you would prefer to download everything:
http://caml.inria.fr/download.en.html
As ymotongpoo pointed out, the interface files of the standard library are part of a normal OCaml isntallation. To see the actual source code, you have to download the source of the OCaml compiler from caml.inria.fr. The implementation of the standard library can be found in directory "stdlib/".
Install ocamlbrowser, then look for the module your are interested
into, then click the implementation button.

Where can I see the code used in C++ standard libraries?

When I compile a program with #include
where can I see the contents of that file, and also since that file contains declarations, where can I see the actual code used in those functions?
Is it open to everyone or is it not available to the public?
The actual code is in the platform-specific standard libraries that come with your compiler, you can see it by looking at the standard library implementation source.
Here's the documentation (and source) for libstdc++ by GNU (it comes with gcc): http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/index.html.
Download the source from one of these mirrors: http://gcc.gnu.org/mirrors.html
Generally the #included file is readable, but the library it implements is generally not readable. The include files on a mac are in /usr/include/c++.
The library code depends on the compiler. For Gnu C++ used in linux and Mac you can definitely see the code. You might have to download it. It is available at http://gcc.gnu.org/libstdc++/
I don't think Windows C++ library code is available.
It depends on what toolchain you are using, not every vendor is making his implementation public. You can have a look at the GNU C library for starters: http://www.gnu.org/software/libc/
Dinkumware, the company behind the C++ standard template library that is used in Visual Studio for example, is offering a commercial product, thus the code is not available to everyone - it really depends on your license. Some versions of Visual Studio indeed ship with the source code of the runtime included.
As for the STL, there is also STLport, an open source STL implementation.
Your best bet will indeed be the projects that gcc/g++ depend on.
The C++ standard itself is just this: a standard. The implementation of which is done by many vendors. STLport and GNU libstdc++ are both open source and can be looked at as a whole. Visual Studio ships with Dinkumware C++ standard library. It is closed source.
Nevertheless, you can always see the source of the headers by opening the include directory of your C++ standard lib. The files are named just like you include them. Much of it is implemented in headers anyway. But are pretty much unreadable to the untrained eye.
But when it comes to using the C++ library don't depend on the exact source code of it, but rather on what the C++ standard says. Don't program to an implementation, but rather to the standard.
Run this command from your command line:
find /usr -name iostream
That will tell you the directory you want.
If you use something like Visual Studio, you can put a break point and then start line-by-line stepping through your code and it will open the included files as you go along. Quickest way into a file in my opinion. Otherwise you can find the code somewhere on your PC ... on mine its in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\ostream for example, replacing ostream with iostream, sstream, etc (note that those are file names without extensions) but also if you look at the directory you'll see a lot of .h and .c files
All system headers ship with your compiler. On Linux systems, these can normally be found under /usr/include . On other platforms, the will normally live where you installed the compiler.
Commercial libraries do not normally ship source code. On linux, these can normally be found in the source pacakges.