Redhat Enterprise 4.3中静态编译perf

    注:编译中使用的perf源码和内核版本并不是标准版中的源码,是我们内部的一个版本。这篇文章主要是提供一些思路,在你的环境中编译遇到的问题可能和我这里的不同,源文件或者Makefile文件的内容也会不一致。如果有问题,欢迎交流。
     perf是在kernel 2.6.31中才加入到内核树中,较早的发行版本中内核版本都比较老,都没有带perf。如果要使用perf,需要自己去编译。这里进行的是静态编译,生成的可执行文件在运行的时候不依赖动态连接库,可以直接拷贝到其他机器上运行。

    1.编译环境

    编译环境说明:
        a.内核版本:  2.6.32
        b.系统发行版本:  Redhat Enterprise 4.3
        c.perf源码:  源码来自linux2-6-32版本中tools/perf目录

    2.安装依赖包

    在编译之前需要安装elfutils-libelf-devel rpm包,这个包要和系统中安装的elfutils-libelf包的版本一致,可以在 这里下载。如果没有安装,编译的时候会报下面的错误:
[root@RedHat_4_3 perf] #  make LDFLAGS=-static
Makefile : 402 :  No libdw.h found  or  old libdw.h found  or  elfutils is older than  0 . 138 , disables dwarf support. Please install new elfutils - devel / libdw - dev
Makefile : 419 :   * * *  No libelf.h / libelf found, please install libelf - dev / elfutils - libelf - devel.  Stop.
    在安装过程中可能会遇到其他的提示rpm包版本太旧的问题,这些都可以通过设置一些宏来解决。

    3.静态编译

    perf目录下的Makefile中有这样一段注释,详细介绍了编译时可以指定的一些宏及其作用,如下所示:
# Define V to have a more verbose compile.
#
# Define PYTHON to point to the python binary if the default
# `python' is not correct; for example: PYTHON=python2
#
# Define PYTHON_CONFIG to point to the python-config binary if
# the default `$(PYTHON)-config' is not correct.
#
# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
#
# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
#
# Define LDFLAGS=-static to build a static binary.
#
# Define EXTRA_CFLAGS=-m64 or EXTRA_CFLAGS=-m32 as appropriate for cross-builds.
#
# Define NO_DWARF if you do not want debug-info analysis feature at all.
#
# Define WERROR=0 to disable treating any warnings as errors.
     根据上面的注释,如果要静态编译,只需要定义LDFLGAS宏,并且把宏的值设置为-static即可。执行静态编译,命令如下所示:
[root@RedHat_4_3 perf] # make LDFLAGS=-static
Makefile : 402 :  No libdw.h found  or  old libdw.h found  or  elfutils is older than  0 . 138 , disables dwarf support. Please install new elfutils - devel / libdw - dev
Makefile : 443 :  newt  not  found, disables TUI support. Please install newt - devel  or  libnewt - dev
Makefile : 493 :  The path  'python'  is 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值