ubuntu 9.10 移植安装systemc-2.3.1笔记

此文只是我的学习笔记,不做其它使用。移植方法、测试和问题的处理参考了相应博文,已做出标注,感谢博主的分享。


ubuntu 9.10 安装systemc-2.3.1



1 解压systemc-2.3.1.tgz


  #tar xzvf systemc-2.3.1.tgz
 
2 然后进入解压缩后生成的systemc-2.3.1文件夹,建立一个临时文件夹objdir:


  cd systemc-2.3.1


  mkdir objdir
  
3 然后进入这个临时文件夹,运行SystemC的配置程序来生成安装文件:


  cd objdir


  ../configure -prefix=/home/user/systemc


  prefix参数后面这个路径是你希望安装SystemC的目标路径,你也可以改为其他路径的。
  但是注意不要使用VMware和Windows共享的虚拟分区,我一开始就是安装在虚拟分区里面了,
  结果总是报错,说属性错误。


4 等安装文件生成完毕后,在当前目录运行make程序进行安装:


   make


   make install


  至此在/home/user/systemc下安装好了systemc的安装环境
 
5 测试:


/***********hello.h********************/
#ifndef _HELLO_H
#define _HELLO_H
#include "systemc.h"
SC_MODULE(hello){
SC_CTOR(hello){
cout<<"Hello, SystemC!"<<endl;
}
};   //此处分号";"不要漏掉
#endif

/***********hello.cpp********************/
#include "hello.h"
int sc_main(int i, char* a[]){
hello h("hello");
return 0;

/***********Makefile********************/
LIB_DIR=-L/home/user/systemc/lib-linux
INC_DIR=-I/home/user/systemc/include
LIB=-lsystemc


APP=hello


all:
g++ -o $(APP) $(APP).cpp $(LIB_DIR) $(INC_DIR) $(LIB)  #Tab键开头


clean:
rm -rf $(APP)                                          #Tab键开头
/***********Makefile********************/

Makefile参数说明:
-I/home/user/systemc/include  告诉g++编译器去/home/user/systemc/include下去寻找所需的头文件即systemc.h


-L/home/user/systemc/lib-linux  告诉ld连接器去/home/user/systemc/lib-linux下去寻找所需的库文件声明


-o hello  标准的输出参数,生成的可执行文件名为hello


-lsystemc  告诉ld连接器最终的库文件是libsystemc.a


执行make命令生成名为main的可执行文件显示如下:
#./hello
SystemC 2.3.1-Accellera --- Oct 29 2014 09:47:43
Copyright (c) 1996-2014 by all Contributors,
ALL RIGHTS RESERVED
Hello, SystemC!


6  可能产生的错误:
(1) 编译文件make时,可能出现下面的错误,
hello.h:5: error: new types may not be defined in a return type
hello.h:5: note: (perhaps a semicolon is missing after the definition of 'hello')
hello.cpp:3: error: two or more data types in declaration of 'main'
问题原因:
不要以为是sc_main参数有问题,或是回传值有问题,其实真正的问题很有可能是沒有加分号";"!
比如:
SC_MODULE(hello){
SC_CTOR(hello){
cout<<"Hello,SystemC!"<<endl;
}
}
就是在最后的"}"后面,还必需接一个";",才不会有错误。
(2)执行生成的可执行文件时产生如下提示:
./hello: error while loading shared libraries: libsystemc-2.3.1.so: cannot open shared object file: No such file or directory

解决方法:
该问题是链接库文件没有找到的问题,我解决的方法如下:
执行命令  #sudo gedit /etc/ld.so.conf 
另起一行,添加systemc共享库的绝对路径:/home/user/systemc/lib-linux/
然后执行  #ldconfig   
ldconfig 命令主要是为了更新 /etc/ld.so.cache 文件,为了加快程序执行时对共享库的定位速度,避免使用收索路径查找共享库的低效率

7  参考的博客,感谢博主:
http://blog.csdn.net/funeryoung/article/details/1874515
http://www.eetop.cn/blog/html/22/6222-13529.html
http://www.shangxueba.com/jingyan/1607667.html
http://blog.csdn.net/leo115/article/details/7671819
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值