This post was updated on 26th April,2018 for the latest systemc release: version 2.3.2.
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 (April 2018), systemc-2.3.2 is the most recent systemc version. It provides several improvements over systemc-2.3.1, including bug fixes and several new features that are disabled by default. On this post, we will be installing systemc2.3.2 “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/Muriukidavid/systemc-2.3.2.git
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 head to the download page and download the latest version of the library.
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 build-essential automake libtool
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
Run autoreconf command in the base directory to prepare for configuration, check for dependancies according to the system you have.
../autoreconf -f -i
Create a folder where the installation will be made under /usr/local
sudo mkdir /usr/local/systemc-2.3.2
While at ‘objdir’ folder, run the command
This configures the installation folder and generates the makefiles, among other things…. Last few lines output:
configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating src/systemc.pc config.status: creating src/tlm.pc config.status: creating src/sysc/Makefile config.status: creating src/sysc/packages/boost/Makefile config.status: creating src/sysc/packages/qt/Makefile config.status: creating src/tlm_core/Makefile config.status: creating src/tlm_utils/Makefile config.status: creating examples/Makefile config.status: creating examples/sysc/Makefile config.status: creating examples/tlm/Makefile config.status: creating examples/tlm/common/Makefile config.status: creating docs/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 --------------------------------------------------------------------- Configuration summary of SystemC 2.3.2 for x86_64-unknown-linux-gnu --------------------------------------------------------------------- Directory setup (based on classic layout): Installation prefix (aka SYSTEMC_HOME): /usr/local/systemc-2.3.2 Header files : /include Libraries : /lib-linux64 Documentation : /docs Examples : /examples Architecture : linux64 Compiler : /usr/bin/g++ (C/C++) Build settings: Enable compiler optimizations : yes Include debugging symbols : no Coroutine package for processes: QuickThreads Enable VCD scopes by default : yes Disable async_request_update : no Phase callbacks (experimental) : no ---------------------------------------------------------------------
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.2/lib-linux64/ libsystemc-2.3.2.so libsystemc.a libsystemc.la libsystemc.so pkgconfig
Note: for a 32-bit system, the library folder is /usr/local/systemc-2.3.2/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.2/lib-linux64/libsystemc-2.3.2.so /usr/lib/libsystemc-2.3.2.so
You can check the path is correct:
ls -l /usr/lib/libsystemc-2.3.2.so lrwxrwxrwx 1 root root 56 Apr 26 12:31 /usr/lib/libsystemc-2.3.2.so -> /usr/local/systemc-2.3.2/lib-linux64/libsystemc-2.3.2.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.2/lib-linux/” or “/usr/local/systemc-2.3.2/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.2/include/ by browsing File System. Note: The path in the image is actually different as it was added in 2014 when the latest version was still 2.3.0
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.2/lib-linux64 for 64-bit or /usr/local/systemc-2.3.2/lib-linux for 32-bit systems. Note: The path in the image is for systemc version 2.3.0, but we are using 2.3.2
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: