ubuntu系统安装systemc-2.3.4流程

发布于:2024-04-07 ⋅ 阅读:(128) ⋅ 点赞:(0)

背景:systemC编程在linux下的基础环境配置

1,下载安装包,并解压

(先下载了最新的3.0.0,安装时候显示sc_cmnhdr.h:115:5: error: #error **** SystemC requires a C++ compiler version of at least C++17 **** ,最后降级选择了2.3.4版本)

官网下载:SystemC

2,编译与安装

cd systemc-2.3.4/
mkdir build && cd build
../configure --prefix=/home/systemc-2.3.4

如果最后的configure指令出现报错config.status: error: cannot find input file: `src/Makefile.in',返回systemc-2.3.4/目录下,执行如下命令再返回build目录下。

(cannot find input file: `src/Makefile.in'这个错误是systemc-2.3.4版本带来的,据说2.3.3则没有这个错误)

cd ..
aclocal
automake --add-missing
cd build

继续编译

sudo make -j $(nproc)
make install

最后,在~/.bashrc文件中添加环境变量,既结束了安装

sudo vi ~/.bashrc
#写入如下内容
export SYSTEMC_HOME=/home/systemc-2.3.4/
export LD_LIBRARY_PATH=/home/systemc-2.3.4/lib-linux64/:$LD_LIBRARY_PATH

source ~/.bashrc

3,简单测试

写一个hello.cpp

#ifndef _HELLO_H
#define _HELLO_H
#include "systemc.h"
SC_MODULE(hello)
{
    SC_CTOR(hello)
    {
        cout<<"Hello, SystemC!"<<endl;
    }
};
#endif
 
//main.cpp
int sc_main(int i, char* a[])
{
    hello h("hello");
    return 0;
}

编译程序

g++ hello.cpp -I/home/systemc/include/ -L/home/systemc/lib-linux64 -o hello -lsystemc

执行生成的hello程序

./hello

得到如下输出,即表示systemC已经安装成功。


网站公告

今日签到

点亮在社区的每一天
去签到