I am writing this step by step tutorial to make it easy for anyone who is trying to install systemC library because I was able to do that after struggling with it for long time and searching through numerous web pages. If anybody knows a simpler way then his/her help will be appreciated. And before we proceed I want to thank all those people who have given their contribution in parts through their posts/web pages in helping me. After all as they say “sharing is caring”….. 🙂
These steps apply for systemc-2.2.0 and I have tried this on ubuntu 10.04, 11.04, 11.10, 12.04 and also in fedora 13, 14, 15. All are 32-bit OS. For 64-bit OS some updates have been mentioned in the bottom of the post.
STEP 1:
First of all open terminal (ctrl+alt+T), and type:
:~$ sudo apt-get install build-essential
this will download and install all the necessary compiler tools in your system.
STEP 2:
Now download systemC package from http://www.systemc.org/downloads/standards/ (a free registration is required) or any other source about which you know better than me. The downloaded package will be available in Download directory of your home folder. Extract the package using any of the following two methods:
1. right click on the .tar.gz file and select extract here option.
or
2. start terminal (ctrl+alt+T) type following code:
cd Downloads (if that .tar.gz file is in Download directory else give wherever you have kept it)
mv systemc-2.2.0.tgz systemc-2.2.0.tar
tar xvf systemc-2.2.0.tar
Using any of the above two methods, you will get a folder named systemc-2.2.0 in the same folder where .tar.gz file was present (in my case it was in Download folder).
STEP 3:
Now following two steps will avoid any problems in further installation so follow them carefully:
1. go to systemc-2.2.0/src/sysc/utils and open file “sc_utils_ids.cpp” and add these two headers
#include <cstdlib>
#include <cstring>
along with other header files and save it before closing.
2. go to systemc-2.2.0/src/sysc/datatypes/bit and open file “sc_bit_proxies.h” and search for keyword “mutable”. It appears 5 times in the file. Delete it from all 5 locations and save the file.
STEP 4:
Now we are ready to install the package.
open terminal again and use following codes:
:~$ cd systemc-2.2.0
:~$ sudo mkdir /usr/local/systemc-2.2
:~$ mkdir objdir
:~$ cd objdir
:~$ sudo ../configure –prefix=/usr/local/systemc-2.2
:~$ sudo make
:~$ sudo make install
STEP 5:
Now as we have not installed the package in usual place. So we need to tell the system where to find the package when required.
For this type this in terminal:
:~$ export SYSTEMC_HOME=/usr/local/systemc-2.2/
Now whatever we have done will work until we log out. So to make it permanent we need to change the path variables. For this open terminal and type:
:~$ sudo gedit /etc/environment
This will open a text file in gedit. In that file add following line in the end:
:~$ SYSTEMC_HOME=”/usr/local/systemc-2.2/”
before saving please check that the double inverted comma used above should be proper.
Now restart the system once. That’s all 😀
STEP 6:
Now to check please download sample systemC code from http://www.asic-world.com/systemc/first1.html
To compile it from terminal use this code:
:~$ g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux -o out sample.cpp -lsystemc -lm
:~$ ./out
It will print hello world as output.
If this compilation and execution of code is throwing some error regarding linking of libraries viz, “-lsystemc not found” etc, then please read following two additional things which I have added after feedback of other systemc users who were very humble while giving these useful suggestions and time.
EDITED: (Courtesy-Dhiraj):
While executing the code if some problem occurs like: cannot find -lsystemc etc then don’t worry it is because of linking error. To get rid of it you need to set path in LD_LIBRARY_PATHS which can be done as follows:
Two solutions:
For setting your LD_LIBRARY_PATH.
export LD_LIBRARY_PATH=/usr/local/systemc-2.2/lib-linux:$LD_LIBRARY_PATH
or, if your default LD_LIBRARY_PATH is empty
export LD_LIBRARY_PATH=/usr/local/systemc-2.2/lib-linux
And for this fix don’t thank me but do thank the the guy who commented this suggestion below in comments. 🙂
EDITED: (Courtesy-Tianyang):
For Ubuntu 64-bit version, the lib-linux should be lib-linux64.
Thank you
22.330400
87.318108