Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install gcc on linux with no root privilege

Tags:

c++

linux

gcc

g++

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 :)

like image 825
Matthew Murdock Avatar asked Jul 09 '10 11:07

Matthew Murdock


People also ask

Can I install GCC without root?

If you have no gcc there, you need to find a pre-compiled binary of gcc/g++ and install it somewhere. If you have no header files there, you need to find copies of those and put them on the system. There is no 'standard' way of installing gcc in your home folder though.

Does Linux have GCC by default?

No. A C-compiler (any C-compiler, GCC is just an example, it might just as well be clang/lvm, or something else) is just incredibly handy to have.


2 Answers

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.

like image 193
Rudi Avatar answered Sep 20 '22 13:09

Rudi


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" 
like image 38
DanielY Avatar answered Sep 20 '22 13:09

DanielY