Install gcc on linux with no root privilege

I have access to computer in a public library and I want to try out some C++ and maybe other code. Problem is that there is no g++ installed and I can't install it using packages because I have no root access. Is there a "smart" way to make a full environment for programming in a home folder?

I have gcc installed (I can compile C code). Also, I have a home folder that is consistent. I don't know where to find precompiled g++, I found only source but I don't know what to do with it. I tried to ask them to install this but it didn't work :)


Solution 1:

You can run the configure script with the --prefix parameter: ../gcc-4.5.0/configure --prefix=/home/foo/bar. Since it is very likely that the c++ standard library is different then the one on your system, you have to set export LD_LIBRARY_PATH=/home/foo/bar/lib before you can start a program compiled by this compiler.

Solution 2:

If you want to install it as a local user

GNU GSRC provides an easy way to do so

Link: http://www.gnu.org/software/gsrc/

After configuration, simply specify the following commands:

cd gsrc
make -C pkg/gnu/gcc 
make -C pkg/gnu/gcc install

The second step could also be changed to speed up for an N-core system:

make -C pkg/gnu/gcc MAKE_ARGS_PARALLEL="-jN"