1. Edit the CPP file first.
// All systemc modules should include systemc.h header file #include "systemc.h" // Hello_world is module name SC_MODULE (hello_world) { SC_CTOR (hello_world) { // Nothing in constructor } void say_hello() { //Print "Hello World" to the console. cout << "Hello World.\n"; } }; // sc_main in top level function like in C++ main int sc_main(int argc, char* argv[]) { hello_world hello("HELLO"); // Print the hello world hello.say_hello(); return(0); }2. Then create a Makefile. This makefile is reusable for all SystemC projects.
SYSTEMC=/usr/local/systemc LDFLAGS= -L$(SYSTEMC)/lib-linux -lsystemc CXXFLAGS=-Wno-deprecated -I$(SYSTEMC)/include -fpermissive all: g++ $(CXXFLAGS) *.cpp $(LDFLAGS) ./a.out3. The command "make" compiles and runs the Hello World program.
$ make g++ -Wno-deprecated -I/usr/local/systemc/include *.cpp -L/usr/local/systemc/lib-linux -lsystemc ./a.out SystemC 2.2.0 --- Aug 25 2011 10:30:16 Copyright (c) 1996-2006 by all Contributors ALL RIGHTS RESERVED Hello World.
U're a savior man ^^ thanks.
ReplyDeleteAloha,
ReplyDeleteas I am trying to get SysC working on my system, I have tried almost every HelloWorldTutorial there is, also this one.
But I am getting an error when compiling (from shell, as well as from eclipse). Anyone having an idea?
error while loading shared libraries: libsystemc-2.3.0.so: cannot open shared object file: No such file or directory
make: *** [all] Error 127
I have the same problem like you. I guess this would be helpful for you. http://www.accellera.org/Discussion_Forums/helpforum/archive/msg?list_name=help_forum&monthdir=201202&msg=msg00003.html
DeleteThanks,
export LD_LIBRARY_PATH=\$HOME/SystemC/include:$LD_LIBRARY_PATH
Delete-static flag at compiling did solve the problem.
ReplyDeleteLooks like you solved your problem. Great.
ReplyDeleteI think that the best is use export LD_LIBRARY_PATH="completed route to lib-linux":
ReplyDeleteexport LD_LIBRARY_PATH="begining of route..."/systemc-2.3.0/lib-linux
if you want know the libraries that use your program, you can use:
ldd "program_name"
Below is an improved version of this program because the original has problems and is not strictly correct.
ReplyDelete// All systemc modules should include systemc.h header file
#include
using namespace sc_core;
// Hello_world is module name
SC_MODULE (hello_world) {
SC_CTOR (hello_world) {
SC_THREAD(say_hello);
}
void say_hello(void) {
//Print "Hello World" to the console.
SC_REPORT_INFO("Example","Hello World.\n");
sc_stop();
}
};
// sc_main in top level function like in C++ main
int sc_main(int argc, char* argv[]) {
hello_world hello("HELLO");
// Print the hello world
sc_start();
return(0);
}