2

如何在终端 mac OS X 中使用和安装SystemC ?
我尝试了逻辑诗人应用程序,但我使用的是 os x 10.10,所以它不起作用。
所以我想知道如何在终端中编译和执行 SystemC。
我在终端中找不到 SystemC 的详细信息。

谢谢

4

3 回答 3

3

The other answer is correct and perfectly fine, however, I thought I'd also answer and provide a little more detail.

Install Apple's "Command Line Tools"

You have two options: install Xcode (a big download), or just the command line tools (a much smaller download). If your goal is simply building SystemC applications at the command line, then I recommend the latter.

Install Apple's "Command Line Tools" by launching Terminal, entering

$ xcode-select --install

then clicking Install. After that, you'll have make, clang and more available at the command line.

Build and install Accellera's SystemC implementation

Download the latest release from the Accellera Downloads page (annoyingly, you'll have to provide a few personal details) and extract the contents of the .zip file.

I like to keep a copy of the SystemC source code available, because it can be useful for debugging or understanding how something works. Therefore, I move the extracted folder (systemc-2.3.1) into ~/Work/Other. That's where I keep source code for third party libraries. However, you can put it wherever you like.

Open Terminal, change into the extracted folder (systemc-2.3.1), and execute:

$ mkdir build
$ cd build
$ export CXX=clang++
$ ../configure --with-arch-suffix=
$ make install

The --with-arch-suffix= option prevents a -macosx64 suffix being add to the lib folder name, allowing your build scripts to be simpler.

After that process, the salient include and lib folders should be available within the systemc-2.3.1 folder.

Configure your build environment

There are many ways you can do this; I have a simple approach that I believe is close to what the SystemC maintainers envisioned. I define two environment variables in my .bash_profile (which is executed for every new Terminal session on OS X):

export CXX="clang++ -fcolor-diagnostics"
export SYSTEMC_HOME=~/Work/Other/systemc-2.3.1

Build a SystemC application

You could use Make, the quintessential build tool, which you get with Apple's "Command Line Tools", or any one of the plethora of other options. I use SCons with SConstruct files that look something like this:

import os
env = Environment(CXX=os.environ["CXX"],
                  SYSTEMC_HOME=os.environ["SYSTEMC_HOME"],
                  CPPPATH="$SYSTEMC_HOME/include",
                  LIBPATH="$SYSTEMC_HOME/lib")
env.Program("main.cpp", LIBS="systemc")

View trace (VCD) files

Scansion is a nice tool for this. GTKWave is another option, but it's a bit clunky.

于 2014-12-06T03:53:50.843 回答
3

确保您已安装xcode 命令行工具

按照官方存储库中提供的说明进行操作。


从个人经验。

每次我将库包含到我的代码中时,编译 SystemC 库都会clang导致错误。为了避免这种使用,而不是。segmentation fault: 11systemcgcc

请注意,我使用的是 gcc-8,与homebrew一起安装。

$ cd path/to/systemc-2.3.3
$ mkdir objdir
$ cd objdir
$ export CXX=g++-8
$ ../configure
$ make
$ make install

用于$ make check启动示例编译和单元测试。

编译并运行hello world 示例

$ export SYSTEMC_HOME=path/to/systemc-2.3.3
$ g++-8 hello.cpp -o hello.o -L $SYSTEMC_HOME/lib-macosx64 -I $SYSTEMC_HOME/include/ -l systemc
$ ./hello.o

在 macOS 10.13.6 上测试;gcc 版本 8.2.0;系统c-2.3.3

于 2019-01-02T11:42:56.247 回答
0

安装

去这里点击第一个链接并填写您的信息以获取源代码

http://www.accellera.org/downloads/standards/systemc

然后cd到文件夹

然后运行以下命令

./configure --with-unix-layout
gmake
sudo gmake install
gmake clean

在你这样做之后,它应该全部保存在你的 use/local/(lib&include) 目录中

使用

在代码中执行此 #include "systemc.h"

我通常使用单个makefile。但是您可以编写以下内容来链接库。鉴于您的 cpp 文件称为 main.cpp 文件。

g++ -o main main.cpp -I/usr/local/include -L/usr/local/lib -lsystemc
于 2014-09-24T10:49:01.050 回答