Chapter 0: Start Here

Installation & Setup

How to download, compile, and link the Accellera SystemC library on Linux and Windows.

Downloading and Installing SystemC

Since SystemC is a C++ library, you do not install an "executable" or an "IDE". You must download the source code, compile it into a static library (.a or .lib), and then link your own C++ code against it.

The official reference implementation is maintained by the Accellera Systems Initiative.

Step 1: Download the Source Code

  1. Go to the Accellera Systems Initiative Download Page.
  2. Download the latest SystemC Core source code (e.g., SystemC 2.3.3 or 2.3.4).
  3. Extract the .tar.gz or .zip file to a permanent directory on your machine (e.g., /opt/systemc on Linux or C:\systemc on Windows).

Step 2: Compiling the Library

On Linux / macOS (Using CMake & GCC/Clang)

Modern SystemC provides a CMakeLists.txt making installation vastly easier than the old autotools method.

  1. Open your terminal and navigate to the extracted SystemC directory:
    cd /path/to/systemc-2.3.3
  2. Create a build directory and run CMake:
    mkdir build && cd build
    cmake .. -DCMAKE_CXX_STANDARD=14
  3. Compile and install (this usually installs to /usr/local/systemc by default, or the path specified via CMAKE_INSTALL_PREFIX):
    make -j4
    sudo make install

On Windows (Using Visual Studio)

  1. Open the extracted folder and navigate to the msvc10 or msvc14 directory (depending on your Visual Studio version).
  2. Open the SystemC.sln solution file in Visual Studio.
  3. Select your desired configuration at the top: Debug or Release, and x64.
  4. Right-click the SystemC project in the Solution Explorer and click Build.
  5. Once finished, the compiled .lib files will be located in the Debug or Release folder within the MSVC directory.

Step 3: Compiling Your First Program

Once the library is built, you can write a main.cpp file:

#include <systemc.h>
 
int sc_main(int argc, char* argv[]) {
    std::cout << "Hello, SystemC World!" << std::endl;
    return 0;
}

Compiling on Linux (g++)

You must tell the compiler where the SystemC headers (-I) and library files (-L) are located, and explicitly link the systemc library (-lsystemc).

g++ main.cpp -o hello_systemc \
    -I/usr/local/systemc/include \
    -L/usr/local/systemc/lib-linux64 \
    -lsystemc -lm

Compiling on Windows (Visual Studio)

In your own project properties:

  1. C/C++ -> General -> Additional Include Directories: Add C:\systemc\src.
  2. C/C++ -> Preprocessor -> Preprocessor Definitions: Add _CRT_SECURE_NO_WARNINGS.
  3. Linker -> General -> Additional Library Directories: Add C:\systemc\msvc14\SystemC\x64\Release.
  4. Linker -> Input -> Additional Dependencies: Add SystemC.lib.

Using CMake (Recommended)

Instead of typing out GCC flags or clicking through Visual Studio menus, the industry standard is to use CMake to build your projects. You can write a CMakeLists.txt based on the example in the previous step and use it for any future tutorials.

Comments and Corrections