This post was updated on 20th Sep,2015 for the latest systemc release: version 2.3.1.
This is a step by step guide to setting up systemc library based on an edit of instructions that come with the source and configuring and running an eclipse-IDE C++ Project. As of now (September 2015), systemc-2.3.1 is the most recent systemc version. It provides several improvements over systemc-2.3.0, including bug fixes and several new features that are disabled by default. On this post, we will be installing systemc2.3.1 “as is” without enabling any new experimental features, for learning purposes.
1. May the source be with you
There are two ways to get the source:
First and easiest is cloning the github repository
Get into the source/dev’t directory
clone the repo
git clone https://github.com/johnniechan/systemc-2.3.1.git systemc-2.3.1
Get into the systemC source directory, ready to build.
Second method is getting the latest from the developer community:
To get the source code from accellera systems, you need to register as a community participant and then head to the download page after login.
Place and Extract the source in your home folder and cd there
Most Linux installations have the required tools by default, just make sure you have make installed. If not, install it:
sudo apt-get install make, build-essential
To check that you have these already, use the which command:
Then you have to set some environmental variables:
If you have a custom compiled gcc, you have the /usr/local/bin/gcc and its g++ as default compiler, probably an older version for building something, then you need to be more specific with the system installed gcc path like so:
export CXX=/usr/bin/g++ export CC=/usr/bin/gcc
Then create a working directory, where you will build the library before installing it
get into that directory
Create a folder where the installation will be made under /usr/local
sudo mkdir /usr/local/systemc-2.3.1
While at ‘objdir’ folder, run the command
This configures the installation folder and generates the makefiles, among other things…. Last few lines output:
config.status: creating examples/tlm/Makefile config.status: creating docs/sysc/doxygen/Doxyfile config.status: creating docs/tlm/doxygen/Doxyfile config.status: executing depfiles commands config.status: executing libtool commands
4. make the library
Assuming configuration went on finishing smoothly, build the library
If you want it to run faster, make use of multiple threads with the -j option, I used
5. Install the library in your system
sudo make install
After this command, you can check that the library was properly installed:
ls /usr/local/systemc-2.3.1/lib-linux64/ libsystemc-2.3.0.so libsystemc.a libsystemc.la libsystemc.so
For both systemc-2.3.0 and systemc-2.3.1, the library names are named exactly the same. i.e libsystemc-2.3.0.so
Note: for a 32-bit system, the library folder is /usr/local/systemc-2.3.1/lib-linux/. you can type while using tab to auto-complete paths 🙂
To configure the library with the standard Linux library path, which will ease up linking stage of project build:
sudo ln -s /usr/local/systemc-2.3.1/lib-linux64/libsystemc-2.3.0.so /usr/lib/libsystemc-2.3.1.so
You can check the path is correct:
ls -l /usr/lib/libsystemc-2.3.1.so lrwxrwxrwx 1 root root 56 Feb 21 12:25 /usr/lib/libsystemc-2.3.1.so -> /usr/local/systemc-2.3.1/lib-linux64/libsystemc-2.3.0.so
This library path problem has of late been persistent and the solution is to add a config file under /etc/ld.so.conf.d/ as follows:
sudo gedit /etc/ld.so.conf.d/systemc.conf
add the path information to that file, i.e “/usr/local/systemc-2.3.1/lib-linux/” or “/usr/local/systemc-2.3.1/lib-linux64/” depending on your system.
6. Get Eclipse
If you already have eclipse, go to step 7. If not, go to Eclipse.org and download the Eclipse IDE for C/C++ developers. Choose 32-bit/64-bit Linux version and the closest mirror… Extract under the home folder and optionally set up a .desktop shortcut
7. Create a new eclipse project
Open Eclipse and create a new C++ project, under New menu
Create a new source folder src in your project
and inside it a new file main.cpp
8. Configure systemc library Path for the project
At this point, your project isn’t configured with the library path:
Right Click on the project root folder in the project explorer view and click on properties, alternatively, go to the Project menu and click properties.
Expand the C/C++ Build entry, and click on settings. Under tool settings tab, expand GCC C++ Compiler and click on includes. On the right under include paths(-l), click the + icon and add a path to /usr/local/systemc-2.3.1/include/ by browsing File System
Now expand GCC C++ Linker and under Libraries, at the top Libraries(-l) entry, click on the + icon and add the library name “systemc”
then at the bottom Library search path, click on the + icon and on the pop-up, add the path to the installation directory /usr/local/systemc-2.3.1/lib-linux64 for 64-bit or /usr/local/systemc-2.3.0/lib-linux for 32-bit systems.
9. Build and run
Click on the build symbol, the hummer, and if everything is ok in terminal: saying finished building target,
click on the Run icon(like play icon) the one to the right of the IDE, not the one on the left side.
At this point its hard to tell what the output of the terminal will be 🙂 depends on how much you have learnt systemc and implemented in your main.cpp file.
10. Working Example
You should try a simple working example to begin with: