How to Install G++ on Centos Without Root

Is it possible to install g++ on CentOS without root?

You could use EasyBuild, which will allow you to very easily install a particular GCC version without requiring root, see http://hpcugent.github.com/easybuild .

Disclaimer: I'm an EasyBuild developer.

How to install packages in Linux (CentOS) without root user with automatic dependency handling?

It is possible to use yum and rpm to install any package in the repository of the distribution. Here is the recipe:

Find the package name

Use yum search.

Download

Download the package and all of its dependencies using yumdownloader (which is available on CentOS by default). You'll need to pass it --resolve to get dependency resolution. yumdownloader downloads to the current directory unless you specify a --destdir.

mkdir -p ~/rpm
yumdownloader --destdir ~/rpm --resolve vim-common

Choose a prefix location

It might be ~, ~/centos, or ~/y. If your home is slow because it is on a network file system, you can put it in /var/tmp/....

mkdir ~/centos

Extract all .rpm packages

Extract all .rpm packages to your chosen prefix location.

cd ~/centos && rpm2cpio ~/rpm/x.rpm | cpio -id
  • rpm2cpio outputs the .rpm file as a .cpio archive on stdout.
  • cpio reads it from from stdin
  • -i means extract (to the current directory)
  • -d means create missing directory

You can optionally use -v: verbose

Configure the environment

You will need to configure the environment variable PATH and LD_LIBRARY_PATH for the installed packages to work correctly. Here is the corresponding sample from my ~/.bashrc:

export PATH="$HOME/centos/usr/sbin:$HOME/centos/usr/bin:$HOME/centos/bin:$PATH"

export MANPATH="$HOME/centos/usr/share/man:$MANPATH"

L='/lib:/lib64:/usr/lib:/usr/lib64'
export LD_LIBRARY_PATH="$HOME/centos/usr/lib:$HOME/centos/usr/lib64:$L"

Edited note (thanks to @AmitNaidu for pointing out my mistake):

According to bash documentation about startup files, when connecting to a server via ssh, only .bashrc is sourced:

Invoked by remote shell daemon

Bash attempts to determine when it is being run with its standard input connected to a network connection, as when executed by the remote shell daemon, usually rshd, or the secure shell daemon sshd. If Bash determines it is being run in this fashion, it reads and executes commands from ~/.bashrc, if that file exists and is readable.


Now if you want to install a lot of packages that way, you might want to automate the process. If so, have a look at this repository.


Extra note: if you are trying to install any of gcc, zlib, make, cmake, git, fish, zsh or tmux , you should really consider using conda, see my other answer.

Compiling geos without root CentOS

I'm fairly certain the path to your PHP installation does not start with a . - not from inside the geos-3.4.2 folder anyway, and certainly not from inside an arbitrary source folder.

You should make that path absolute.

I'm assuming the opt folder is in your user folder, so the full path would be $HOME/opt/alt/php53/usr/. Thanks for the clarification, the full path should then be /opt/alt/php53/usr/.

You need to add the bin folder to your PATH variable, the include folder to CPPFLAGS and the lib folder to LDFLAGS.

With $HOME/local/ this is not necessary, since that is the PREFIX, and will be added automatically.

Also note that when adding stuff to your PATH variable, you should add it to the beginning instead of the end, so that it will take precedence over system binaries.

I also suggest you undo the changes you made to ~/local/share/config.site (or remove the file, if it didn't exist), as options there will affect all automake-based projects.

You should rather pass CPPFLAGS and LDFLAGS as arguments to configure.

After all that, your command block should look something like:

wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
tar jxf geos-3.4.2.tar.bz2
cd geos-3.4.2
export PATH="/opt/alt/php53/usr/bin:$PATH"
./configure --enable-php --prefix="$HOME/local" CPPFLAGS="-I/opt/alt/php53/usr/include" LDFLAGS="/opt/alt/php53/usr/lib" && make clean && make

installing GCC-4.9 without root - adding paths and binaries and extra

If you build your compiler with --prefix=/home/myname/gcc4.9 (adjust to match your system, obviously), then the compiler should "know" that the include paths etc.

All you need beyond that is to make sure your path has /home/myname/gcc4.9/bin before /usr/bin or wherever your other gcc is installed, and everything should work just like normal. On my machine, I have gcc 4.8.2 installed from my own build and gcc 4.6.3 from the linux installer for gcc (because it's a fairly old distro). And as long as I have the paths set in the right order, it works "automagically".

You will need to set LD_LIBRARY_PATH, but include-paths and static libraries should be handled by gcc itself.

Install gcc-c++ on CentOS without yum

Yum will install rpm from it's repository.

So I don't understand why you want to avoid yum, it will solve dependencies and install them as well.

However, here is official RPM repository mirror (one of many):
http://centos.arminco.com/5/os/i386/CentOS/

Here is list of all mirrors : http://www.centos.org/modules/tinycontent/index.php?id=30

You will need at least 3 RPMs:

  • gcc-4.4.6-3.el6.i686.rpm
  • gcc-c++-4.4.6-3.el6.i686.rpm
  • libgcc-4.4.6-3.el6.i686.rpm

For compilation of C/C++ you will also need libstdc++, glibc, etc

When you run

yum install gcc

Everything is done

As you did not specified architecture I assume i386, but URL is very similar for x86_64:

http://centos.arminco.com/6/os/x86_64/Packages/

Installing Git with non-root user account

You can download the git source and do ./configure --prefix=/home/user/myroot && make && make install to install git to your home directory provided you have the build tools. If you don't have the build-essential package installed (dpkg --list|grep build-essential), you will need to install those to your home directory as well.



Related Topics



Leave a reply



Submit