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.
Subscribe to:
Post Comments (Atom)
Executed on Slackware14 64 bit : work fine except lib-linux which must be replaced by lib-linux64. Thanks
ReplyDeleteThanks for mentioning, I just updated it.
Deletewhere are we supposed to save the "hello.cpp" file??
ReplyDeletehaving the cpp file In home directory is fine.
Deletebut make sure when you are executing the command to compile and execute, the terminal is also in home directory.
I got the error:
ReplyDelete/usr/local/systemc230/include/systemc.h:118:16: error: ‘std::gets’ has not been declared
using std::gets;
^~~~
Hi,
DeleteTry to replace “ and ” with "
it will fix it.
This comment has been removed by the author.
DeleteThe problem was that the "std::gets" was removed in C++11. I already fixed with this post:
Deletehttp://stackoverflow.com/questions/38352801/systemc-error-with-the-library/
I created hello.cpp and it outputs this]
ReplyDeletehello.cpp:2:21: fatal error: systemc.h: No such file or directory
#include "systemc.h"
^
compilation terminated.
sorry for late response,
Deletethe problem seems to be related to the fact that you have not done this before compiling source code
export SYSTEMC_HOME=/usr/local/systemc230/
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.
DeleteI tried export=/usr/local/systemc-2.3.0 still the error is there.
DeleteAlso the directory we created /usr/local/systemc-2.3.0
DeleteWhat about it? We never did anything to it? It's completely empty.
This comment has been removed by the author.
DeleteKindly help me out. Thanks.
Deletenvm figured it out and the rest of the errors that came along the way. So much for being a guided tutorial.
DeleteHow did you solve the issue. Kindly help me out
DeleteEven i'm facing same problem...can anyone has solution of this one and what are the commands to complile any new program
ReplyDeleteremember to do
Deleteexport SYSTEMC_HOME=/usr/local/systemc230/
and then you should get the executable made without errors
g++ -I. -I$SYSTEMC_HOME/include -L. -L$SYSTEMC_HOME/lib-linux64 -Wl,-rpath=$SYSTEMC_HOME/lib-linux64 -o hello hello.cpp -lsystemc -lm
ReplyDeletePlease explain the above compilation step in detail
Good day sir,
ReplyDeleteId 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!
This comment has been removed by the author.
ReplyDeleteThank you very much for your guide. It is really helpful for me to debug my program.
ReplyDelete