systemc-2.3.3的安装与测试排坑

2020-08-30  本文已影响0人  icfg66

参考:https://blog.csdn.net/Zhjzhh59421/article/details/104669436

1.准备

2.安装

tar xvf systemc-2.3.3.tar.gz
cd systemc-2.3.3
#创建临时文件夹
mkdir objdir
cd objdir

#规定systemc待安装文件夹位置
../configure -prefix=/想要安装的路径/systemc

make
make install

3.环境配置

sudo gedit ~/.bashrc

#在最下面添加
export SYSTEMC_HOME=/自己安装的路径/systemc
export LD_LIBRARY_PATH=/自己安装的路径/systemc/lib-linux64:$LD_LIBRARY_PATH
#保存退出

source ~/.bashrc

4.测试

写一个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/自己安装的路径/systemc/include/ -L/自己安装的路径/systemc/lib-linux64 -o hello -lsystemc
注意:不需要用g++-4.8,一直报错

undefined reference to `sc_core::sc_api_version_2_3_3_cxx199711L<&sc_core::SC_DISABLE_VIRTUAL_BIND_UNDEFINED_>::sc_api_version_2_3_3_cxx199711L(sc_core::sc_writer_policy)'
collect2: error: ld returned 1 exit status

5.运行

./hello
易出现错误:
error while loading shared libraries: libhello.so.1: cannot open shared object file: No such file or directory
分析原因:链接器ld提示找不到库文件。ld默认的目录是/lib和/usr/lib,如果放在其他路径也可以,需要让ld知道库文件所在的路径。
解决方案:

sudo vim /etc/ld.so.conf     
#在新的一行中加入库文件所在目录
 /自己安装的路径/system/lib-linux64  
#保存退出,并运行: 
sudo ldconfig  
上一篇下一篇

猜你喜欢

热点阅读