Saturday, December 8, 2012

Install SystemC 2.3.0 on Linux


1. Download SystemC source from Accellera.

2. Decompress the package using the command
tar -xvf systemc-2.3.0.tgz

3. Change to the top level directory systemc-2.3.0
$cd systemc-2.3.0

4. Make a directory  systemc-2.3.0 for installation in your /usr/local/ path.
$mkdir /usr/local/systemc-2.3.0

5. Make a directory “objdir” in the directory systemc-2.3.0
$mkdir objdir

6. Change to objdir
$cd objdir

7. now type:
export CXX=g++

8. Run configure from objdir:
../configure --prefix=/usr/local/systemc230

9. And then:
make

10. Install by typing command:
sudo make install

At this Point we are done with installation of SystemC 2.3.0. This version is packed with TLM package also. Here we can run our first Hello World! program.

Open your favourite "text editor" and enter the following program:


#include <systemc.h>

SC_MODULE (hello_world) {
  SC_CTOR (hello_world) {
  }

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

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


Save the file as hello.cpp

Use following command to export variable SYSTEMC_HOME.
export SYSTEMC_HOME=/usr/local/systemc230/

Now you can use following command to compile the program:

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

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

Once the program has compiled type following to run your program:
./hello

and you should get output:

SystemC 2.3.0-ASI --- Dec 8 2012 20:50:24
Copyright (c) 1996-2012 by all Contributors,
ALL RIGHTS RESERVED


Hello World system 2.3.



23 comments:

  1. Executed on Slackware14 64 bit : work fine except lib-linux which must be replaced by lib-linux64. Thanks

    ReplyDelete
  2. where are we supposed to save the "hello.cpp" file??

    ReplyDelete
    Replies
    1. having the cpp file In home directory is fine.

      but make sure when you are executing the command to compile and execute, the terminal is also in home directory.

      Delete
  3. I got the error:

    /usr/local/systemc230/include/systemc.h:118:16: error: ‘std::gets’ has not been declared
    using std::gets;
    ^~~~

    ReplyDelete
    Replies
    1. Hi,

      Try to replace “ and ” with "
      it will fix it.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. The problem was that the "std::gets" was removed in C++11. I already fixed with this post:

      http://stackoverflow.com/questions/38352801/systemc-error-with-the-library/

      Delete
  4. I created hello.cpp and it outputs this]
    hello.cpp:2:21: fatal error: systemc.h: No such file or directory
    #include "systemc.h"
    ^
    compilation terminated.

    ReplyDelete
    Replies
    1. sorry for late response,
      the problem seems to be related to the fact that you have not done this before compiling source code
      export SYSTEMC_HOME=/usr/local/systemc230/

      Delete
    2. I executed the export variable command as well but I'm receiving the same error "fatal error: systemc.h: No such file or directory" also the directory that you specify (/usr/local/systemc230) does not exist neither did we create it at any point in the tutorial.

      Delete
    3. I tried export=/usr/local/systemc-2.3.0 still the error is there.

      Delete
    4. Also the directory we created /usr/local/systemc-2.3.0
      What about it? We never did anything to it? It's completely empty.

      Delete
    5. This comment has been removed by the author.

      Delete
    6. nvm figured it out and the rest of the errors that came along the way. So much for being a guided tutorial.

      Delete
    7. How did you solve the issue. Kindly help me out

      Delete
  5. Even i'm facing same problem...can anyone has solution of this one and what are the commands to complile any new program

    ReplyDelete
    Replies
    1. remember to do
      export SYSTEMC_HOME=/usr/local/systemc230/
      and then you should get the executable made without errors

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


    Please explain the above compilation step in detail

    ReplyDelete
  7. Good day sir,
    Id like to thank you ALOT for this awesome quick guide it took me some hours to get linux and systemc running and this guide made me succesful.
    Much appreciated!

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Thank you very much for your guide. It is really helpful for me to debug my program.

    ReplyDelete