Build Notes - MortezaRamezani/gem5 GitHub Wiki

This note is valid on Ubuntu 16.04, using g++ (4.8) and protobuf (2.6.1), probably working on other versions (except protobuf, because of gem5 limitation) with few changes.

Prerequisite:

sudo apt-get install scons

sudo apt-get install protobuf-compiler libprotobuf-dev libgoogle-perftools-dev

Protobuf version 2.X, doesn't support version 3, you might need to build it from source. If your Linux comes with GCC 5.0+, probably the default repo's protobuf is not compatible with lower version of GCC, so you need to build this version, however you need to do some modification for compilation: https://github.com/google/protobuf/releases/tag/v2.6.1

If you install it in /usr/local/ (on Ubuntu 14.04+ at least) it will mess up with current installation. Better idea to install it somewhere else /opt/protobuf/ just for gem5 compilation and add it during compile:

then to compile gem5 do this:

export PATH=/opt/protobuf/bin/:$PATH

export LD_RUN_PATH=/opt/protobuf/lib/

export LIBRARY_PATH=/opt/protobuf/lib/

export LD_LIBRARY_PATH=/opt/protobuf/lib

Building (for x86):

scons -j 4 build/x86/gem5.opt

For different version of gcc/g++:

CC=gcc-4.8 CXX=g++-4.8 scons -j 4 build/X86/gem5.opt


In case you need to build/install everything from scratch (like me, on an old CentOS servers, with no root access!) including GCC/G++, SWIG, Python, PROTOBUF, LIBBOOST ,SCONS and ..., compiler everything with --prefix=<dir> (where <dir> is the directory you want to install all of them into it).Examples:

Python 2.7.X:

./configure CC=gcc-xxx CXX=g++-xxx --prefix=<dir>/opt/ --enable-shared

LIBBOOST:

./configure --prefix=/home/csl/mfr5226/opt/

PROTOBUF:

./configure CC=gcc-xxx CXX=g++-xxx --prefix=<dir>/opt/

SCONS (don't install 3.x version, stick with 2.4.x):

(after installing newer version of python and add it to PATH)

python setup.py install --prefix=/home/csl/mfr5226/opt/

Also you may need this environment variable to be set as well before building gem5:

export PKG_CONFIG_DIR=<dir>/opt/lib/pkgconfig/

export PKG_CONFIG_PATH=<dir>/opt/lib/pkgconfig/

⚠️ **GitHub.com Fallback** ⚠️