Skip to content
This repository has been archived by the owner on Mar 12, 2019. It is now read-only.

Standalone Installation

Bob W. Hogg edited this page Jul 24, 2016 · 1 revision

Standalone Installation of Linuxbrew

Deprecated

These instructions are deprecated, since installing GCC, glibc, and binutils "just works".

==========

Install Linuxbrew with a new GCC compiler, binutils and glibc tool chain so that it does not use the compiler or libraries of the host system.

Docker

Standalone Linuxbrew has a Docker image, sjackman/linuxbrew-standalone.

docker pull sjackman/linuxbrew-standalone
docker run sjackman/linuxbrew-standalone sh -c 'brew install hello && hello'

Also see the Dockerfile at sjackman/docker-linuxbrew.

Dependencies

  • Ruby 1.8.6 or newer
  • GCC 4.2 or newer
  • Linux 2.6.16 or newer
  • 64-bit x86 or 32-bit ARM platform

Paste at a Terminal prompt:

Debian or Ubuntu

sudo apt-get install -y curl g++ gawk m4 make patch ruby tcl

Fedora, CentOS or Red Hat

sudo yum groupinstall 'Development Tools' && sudo yum install curl irb m4 ruby

RHEL5/Centos5: Notice that Ruby 1.8.5 is too old. You will have to build a new Ruby, which fortunately is straightforward.

Install Linuxbrew (tl;dr)

Paste the following at a Terminal prompt:

PATH=~/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin
unset LD_LIBRARY_PATH PKG_CONFIG_PATH
yes | ruby -e "$(curl -fsSL https://raw.github.com/Linuxbrew/linuxbrew/go/install)"
brew doctor

brew install gcc --with-glibc
brew tap homebrew/dupes
brew install git
brew install coreutils findutils gawk gnu-sed gnu-which grep make ruby

PATH=$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin
brew install hello && brew test hello; brew remove hello

If something goes wrong, see below for detailed instructions that will help with troubleshooting.

Sanitize the environment

PATH=/usr/bin:/bin
unset LD_LIBRARY_PATH PKG_CONFIG_PATH

Set other environment variables

Building the GCC toolchain requires a large amount of temporary disk space. If your default temporary volume is small, set the HOMEBREW_TEMP environment variable.

export HOMEBREW_TEMP=/var/tmp

Install Linuxbrew

Set the PATH environment variable.

PATH="~/.linuxbrew/bin:~/.linuxbrew/sbin:$PATH"

Download Linuxbrew.

ruby -e "$(curl -fsSL https://raw.github.com/Linuxbrew/linuxbrew/go/install)"

Or use git if you prefer.

git clone https://github.com/Linuxbrew/linuxbrew.git ~/.linuxbrew

Create symlinks for gcc

Skip this section on Ubuntu, Debian, or if your preferred compiler already has GCC executables named gcc-X.X found in your path, such as gcc-4.8.

ln -s $(which gcc) `brew --prefix`/bin/gcc-$(gcc -dumpversion |cut -d. -f1,2)
ln -s $(which g++) `brew --prefix`/bin/g++-$(g++ -dumpversion |cut -d. -f1,2)
ln -s $(which gfortran) `brew --prefix`/bin/gfortran-$(gfortran -dumpversion |cut -d. -f1,2)
brew install hello && brew test hello; brew remove hello

To use GCC 4.4 on CentOS 5

sudo yum install gcc44 gcc44-c++
ln -s /usr/bin/gcc44 `brew --prefix`/bin/gcc-4.4
ln -s /usr/bin/g++44 `brew --prefix`/bin/g++-4.4
ln -s /usr/bin/gfortran44 `brew --prefix`/bin/gfortran-4.4
brew install --cc=gcc-4.4 hello && brew test hello; brew remove hello

Install the compiler tool chain

Install binutils and glibc

brew install glibc
brew test glibc binutils
brew install hello && brew test hello; brew remove hello

Fix up patchelf

On a system with an older version of gcc, you may get the error:

patchelf: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

To fix this error, run

brew reinstall patchelf
brew test patchelf

Fix up binutils

On a system with an older version of glibc, you may get the error:

error while loading shared libraries: ~/.linuxbrew/lib/libc.so.6: ELF file OS ABI invalid

To fix this error, run

brew patchelf binutils
brew test binutils

Install gcc

brew install gcc --with-glibc -v
brew install hello && brew test hello; brew remove hello

Install core libraries and utilities

brew install git
brew tap homebrew/dupes
brew install coreutils findutils gawk gnu-sed gnu-which grep make ruby
PATH=`brew --prefix`/bin:`brew --prefix`/sbin
brew install hello && brew test hello; brew remove hello

Ubuntu 14.04 specific tl;dr setup script

Download the linked linuxbrew-standalone.sh and run:

sh linuxbrew-standalone.sh

It is tested and working in 14.04 with a couple of small caveats listed below in the TODO comments.

#!/bin/bash
set -eux

cd $HOME

# TODO: The next ln -s line breaks cross compiling with multiarch, need an alternative!
#       source: http://stackoverflow.com/a/9004026/99379
if [! -d "/usr/lib64" ]; then
  # Control will enter here if $DIRECTORY exists.
  sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64 
fi
sudo apt-get update -y
sudo apt-get update --fix-missing -y
sudo apt-get install build-essential curl g++ git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev gawk make patch tcl -y

unset LD_LIBRARY_PATH PKG_CONFIG_PATH HOMEBREW_CC
PATH=$HOME/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin

if [! -d "$HOME/.linuxbrew" ]; then
  yes | ruby -e "$(curl -fsSL https://raw.github.com/Linuxbrew/linuxbrew/go/install)"
  # note that even if brew doctor is a little unhappy we want to keep going
  brew doctor || true
fi
brew install gcc --with-glibc
brew install git
brew tap homebrew/dupes
brew install coreutils findutils gawk gnu-sed gnu-which grep make ruby
PATH=$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin
brew install hello && brew test hello; brew remove hello