Installing SystemC 2.3.1

Welcome to installing SystemC version 2.3.1 on Linux. This article with show you how to quickly and easily install SystemC-2.3.1 on your computer running linux. This article is based on Ubuntu Linux 16.04, other versions based on debian linux should work as well.

Prerequisites

Run the following command from your terminal or console to make sure you have all the tools necessary compile SystemC files.

$ sudo apt-get install build-essential

Download

Download the SystemC-2.3.1a by clicking here.

The downloaded file is named as systemc-2.3.1a.tar.gz, unzip it using the following command. Make sure you are in the same directory as the downloaded file.

$ tar -xvf systemc-2.3.1a.tar.gz

screenshot_20161127_211715

Now, goto the directory just created by the tar command, and create a directory called objdir there.

screenshot_20161127_212051

Now, get into the objdir and create a directory systemc-2.3.1 in the folder

/usr/local/

Notice you will need to use sudo to be able to create directory in that folder.

screenshot_20161127_213732

Now, we need to issue the following command from the objdir folder

$ sudo ../configure --prefix=/usr/local/systemc-2.3.1/

And if everything went on well you should see output like this.

screenshot_20161127_213333

Now, issue the following command from within the objdir. Be patient it takes some time.

$ sudo make

sudo-make

If everything went well you should see something like this.

sudo-make-done

Finally, its time to issue the install command,

$ sudo make install

on success you should see output like this

screenshot_20161127_215225

If you see something like this and not error messages, then SystemC has been installed successfully. Let’s check it by running a hello_world program.

Type or copy paste the following in a text editor and save it as hello.cpp in home directory.

#include <systemc.h>

SC_MODULE (hello_world) {
  SC_CTOR (hello_world) {
  }

  void say_hello() {
    cout << "Hello World SystemC-2.3.1.\n";
  }
};

int sc_main(int argc, char* argv[]) {
  hello_world hello("HELLO");
  hello.say_hello();
  return(0);
}

screenshot_20161127_221327

Now, use following command to export variable SYSTEMC_HOME

export SYSTEMC_HOME=/usr/local/systemc-2.3.1/

Now in order to create executables run the following command based on your computer architecture (i.e. 64 bit or 32 bit)

For 64 bit: (notice command is long, scroll to see more on the right)

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -o hello hello.cpp -lsystemc -lm

For 32 bit: (notice command is long, scroll to see more on the right)

g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux -Wl,-rpath=$SYSTEMC_HOME/lib-linux -o hello hello.cpp -lsystemc -lm

After you have run this command an executable file called hello should have been created in the same directory.

Execute the hello program/executable file with the following command

./hello

And you should see the following output, which verifies you have installed SystemC-2.3.1 successfully. Congratulations.

screenshot_20161127_221136

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s