Thanks to these tips from
http://archive.pfb.no/2010/10/13/systemc-ubuntu-1010/ and
http://noxim.sourceforge.net/pub/Noxim_User_Guide.pdf, I was able to install SystemC on 11.04 Natty Narwhal.
Begin borrowed material
Step 0: Prepare.
Obviously, you need to have a compiler. Do this step in case you haven't done so.
$ sudo apt-get install build-essential
Step 1: Download.
Next: register, and download from
http://www.systemc.org using your Web browser then unpack it....but the tgz file has wrong extension. Do these steps to unpack the file:
$ mv systemc-2.2.0.tgz systemc-2.2.0.tar
$ tar xvf systemc-2.2.0.tar
Alternatively, download the file using wget from another site with the correct extension:
$ wget http://panoramis.free.fr/search.systemc.org/?download=sc220/systemc-2.2.0.tgz
$ tar xvfz systemc-2.2.0.tgz
Ooops! Turns out you can't use wget. Copy the URL to your browser location bar, answer a simple a question and the file will be downloaded. In any case, no need to reveal you email for this option!
In any case, create a build directory and enter into it for the following steps:
$ cd systemc-2.2.0
$ sudo mkdir /usr/local/systemc
$ mkdir objdir
$ cd objdir
$ export CXX=g++
$ sudo ../configure --prefix=/usr/local/systemc CPPFLAGS=-fpermissive
Step 2: Patch.
Using new versions of GCC such as GCC 4.4, we will fail to compile because 2 lines of code were left out of systemc-2.2.0/src/sysc/utils/sc_utils_ids.cpp.
Method 1: You can just just open the file and add these includes at the top of the file (after the header comments):
#include "cstdlib"
#include "cstring"
#include "sysc/utils/sc_report.h"
Replace the " signs with less than and greater than signs (because this blog site treats the the pair of characters as HTML tags).
Method 2: You patch it using a prewritten patch file.
$ wget http://www.pfb.no/files/systemc-2.2.0-ubuntu10.10.patch
$ patch -p1 < ../systemc-2.2.0-ubuntu10.10.patch
Method 3: Patch it using sed:
$ sed -i '1 i #include "cstdlib"\n#include "cstring"' ../src/sysc/utils/sc_utils_ids.cpp
Step 3: Compile
$ make
$ sudo make install
$ make check
$ cd ..
$ rm -rf objdir
The command make check is optional. What is does is to compile SystemC source files to see if the files can run. I strongly suggest that you run it.
Step 4: Tell your compiler where to find SystemC
Since we do not install SystemC with a standard location we need to specifically tell the compiler where to look for the libraries. We do this with an environment variable.
$ export SYSTEMC=/usr/local/systemc/
This, however will disappear on the next login. To permanently add it to your environment, alter
~/.profile or
~/.bash_profile if it exists. For system wide changes, edit
/etc/environment. (newline with expression:
SYSTEMC_HOME=”/usr/local/systemc/“) To compile a systemC program simply use this expression:
$ g++ -I. -I$SYSTEMC/include -L. -L$SYSTEMC/lib-linux -o OUTFILE INPUT.cpp -lsystemc -lm
End borrowed material
I still could not get SystemC installed in Fedora. :(