Chinaunix首页 | 论坛 | 博客
  • 博客访问: 495194
  • 博文数量: 135
  • 博客积分: 3010
  • 博客等级: 中校
  • 技术积分: 905
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-24 19:31
文章分类

全部博文(135)

文章存档

2010年(135)

我的朋友

分类: LINUX

2010-02-07 10:30:50

由于OProfile需要在目标机上,所以需要交叉编译OProfile工具

源码包:
        oprofile-0.9.3.tar.gz
编译工具:
        arm-9tdmi-linux-gnu-gcc  
        arm-9tdmi-linux-gnu-g++
步骤:
        Cp oprofile-0.9.3.tar.gz  workdir
        Tar zxvf oprofile-0.9.3.tar.gz
        Cd oprofile-0.9.3
        
        CC=arm-9tdmi-linux-gnu-gcc
        CXX=arm-9tdmi-linux-gnu-g++
        
        ./configure --with-kernel-support --target=arm-9tdmi-linux-gnu --host=arm-9tdmi-linux-gnu --build=i686-pc-linux-gnu --prefix=/work/OProfile/myOProfile
        
        
        现象:
        创建Makefile文件,但是出现如下错误(缺少popt库):
        [root@localhost oprofile-0.9.3]# ./configure --with-kernel-support --target=arm-linux --host=arm-9tdmi-linux-gnu   --build=i686-pc-linux-gnu --prefix=/work/OProfile/myOProfile   
        checking for a BSD-compatible install... /usr/bin/install -c
        checking whether build environment is sane... yes
        checking for gawk... gawk
        checking whether make sets $(MAKE)... yes
        checking for arm-9tdmi-linux-gnu-strip... arm-9tdmi-linux-gnu-strip
        checking for arm-9tdmi-linux-gnu-ranlib... arm-9tdmi-linux-gnu-ranlib
        checking for arm-9tdmi-linux-gnu-gcc... arm-9tdmi-linux-gnu-gcc
        checking for C compiler default output file name... a.out
        checking whether the C compiler works... yes
        checking whether we are cross compiling... yes
        checking for suffix of executables... 
        checking for suffix of object files... o
        checking whether we are using the GNU C compiler... yes
        checking whether arm-9tdmi-linux-gnu-gcc accepts -g... yes
        checking for arm-9tdmi-linux-gnu-gcc option to accept ANSI C... none needed
        checking for style of include used by make... GNU
        checking dependency style of arm-9tdmi-linux-gnu-gcc... gcc3
        checking how to run the C preprocessor... arm-9tdmi-linux-gnu-gcc -E
        checking for arm-9tdmi-linux-gnu-g++... arm-9tdmi-linux-gnu-g++
        checking whether we are using the GNU C++ compiler... yes
        checking whether arm-9tdmi-linux-gnu-g++ accepts -g... yes
        checking dependency style of arm-9tdmi-linux-gnu-g++... gcc3
        checking for ld... ld
        checking for kernel OProfile support... yes
        checking whether malloc attribute is understood... yes
        checking whether __builtin_expect is understood... yes
        checking for sched_setaffinity... yes
        checking for perfmonctl... no
        checking for poptGetContext in -lpopt... no
        configure: error: popt library not found

        [root@localhost oprofile-0.9.3]# 
        
        
        解决方法:
        
        可以知道交叉编译oprofile-0.9.3需要popt库,于是下载popt-1.7.tar.tar源码包
        按下步骤
        
        cd /root/projects/commen
        tar xfz /root/tar/tools/popt-1.7.tar.gz
        cd popt-1.7
        CC=arm-linux-gcc ./configure ./configure --with-kernel-support --target=arm-9tdmi-linux-gnu --host=arm-9tdmi-linux-gnu --build=i686-pc-linux-gnu --prefix= /work/popt/poptinstall/
        新手注意,当你看到源码目录下有configure文件时,都能使用这个方式来配置。
        make
        make install
        
        cp  /work/popt/poptinstall/lib/*  /opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-9tdmi-linux-gnu/arm-9tdmi-linux-gnu/lib
        
        cp /work/popt/poptinstall/include/*   /opt/crosstool/gcc-3.4.1-glibc-2.3.3/arm-9tdmi-linux-gnu/arm-9tdmi-linux-gnu/include
        
        具体参照:
        http://blog.csdn.net/wasid/archive/2005/12/22/559306.aspx
        
        
        
        
        现象:
        然后再使用开始的配置命令为oprofile生成Makefile,popt库可以找到,但是这次缺少了bfd库        
        
        CC=arm-9tdmi-linux-gnu-gcc
        CXX=arm-9tdmi-linux-gnu-g++
        
        [root@localhost oprofile-0.9.3]# ./configure --with-kernel-support --target=arm-9tdmi-linux-gnu  --host=arm-9tdmi-linux-gnu   --build=i686-pc-linux-gnu --prefix=/work/OProfile/myOProfile   
        checking for a BSD-compatible install... /usr/bin/install -c
        checking whether build environment is sane... yes
        checking for gawk... gawk
        checking whether make sets $(MAKE)... yes
        checking for arm-9tdmi-linux-gnu-strip... arm-9tdmi-linux-gnu-strip
        checking for arm-9tdmi-linux-gnu-ranlib... arm-9tdmi-linux-gnu-ranlib
        checking for arm-9tdmi-linux-gnu-gcc... arm-9tdmi-linux-gnu-gcc
        checking for C compiler default output file name... a.out
        checking whether the C compiler works... yes
        checking whether we are cross compiling... yes
        checking for suffix of executables... 
        checking for suffix of object files... o
        checking whether we are using the GNU C compiler... yes
        checking whether arm-9tdmi-linux-gnu-gcc accepts -g... yes
        checking for arm-9tdmi-linux-gnu-gcc option to accept ANSI C... none needed
        checking for style of include used by make... GNU
        checking dependency style of arm-9tdmi-linux-gnu-gcc... gcc3
        checking how to run the C preprocessor... arm-9tdmi-linux-gnu-gcc -E
        checking for arm-9tdmi-linux-gnu-g++... arm-9tdmi-linux-gnu-g++
        checking whether we are using the GNU C++ compiler... yes
        checking whether arm-9tdmi-linux-gnu-g++ accepts -g... yes
        checking dependency style of arm-9tdmi-linux-gnu-g++... gcc3
        checking for ld... ld
        checking for kernel OProfile support... yes
        checking whether malloc attribute is understood... yes
        checking whether __builtin_expect is understood... yes
        checking for sched_setaffinity... yes
        checking for perfmonctl... no
        checking for poptGetContext in -lpopt... yes
        checking for egrep... grep -E
        checking for ANSI C header files... yes
        checking for sys/types.h... yes
        checking for sys/stat.h... yes
        checking for stdlib.h... yes
        checking for string.h... yes
        checking for memory.h... yes
        checking for strings.h... yes
        checking for inttypes.h... yes
        checking for stdint.h... yes
        checking for unistd.h... yes
        checking libiberty.h usability... no
        checking libiberty.h presence... no
        checking for libiberty.h... no
        checking for cplus_demangle in -liberty... yes
        checking for xcalloc... yes
        checking for xmemdup... yes
        checking for dlopen in -ldl... yes
        checking for main in -lintl... no
        checking for bfd_openr in -lbfd... no
        configure: error: bfd library not found

        [root@localhost oprofile-0.9.3]# 
        
        解决方法:
        
        找不到bfd源码包     郁闷
        待解决……
        
        阅读Oprofile manual, 确实是存在缺库的现象。 奇怪了,他们发现了怎么不给解决,苦了我了 :(
        
        System requirements
                Linux kernel 2.2/2.4 
                        OProfile uses a kernel module that can be compiled for 2.2.11 or later and 2.4. Versions 2.4.10 or above are recommended, and required if you use the boot-time kernel option nosmp. AMD Hammer support requires a recent (>= 2.4.19) kernel with the line EXPORT_SYMBOL(do_fork); present in kernel/ksyms.c. Such a kernel is present in the x86-64.org CVS repository. 2.5 kernels are supported with the in-kernel OProfile driver. 
                modutils 2.4.6 or above 
                        You should have installed modutils 2.4.6 or higher (in fact earlier versions work well in almost all cases). 
                Supported architecture 
                        For Intel IA32, a CPU with either a P6 generation or Pentium 4 core is required. In marketing terms this translates to anything between an Intel Pentium Pro (not Pentium Classics) and a Pentium 4 / Xeon, including all Celerons. The AMD Athlon, Duron, and Hammer CPUs are also supported. Other IA32 CPU types only support the RTC mode of OProfile; please see later in this manual for details. Hyper-threaded Pentium IVs are not supported in 2.4. For 2.4 kernels, the Intel IA-64 CPUs are also supported. For 2.5 kernels, there is additionally support for Alpha processors, and sparc64, ppc64, and PA-RISC in timer mode. 
                Uniprocessor or SMP 
                        SMP machines are fully supported. 
                Required libraries 
                        These libraries are required : popt, bfd, liberty (debian users: libiberty is provided in binutils-dev package), dl, plus the standard C++ libraries. 
                
                                Bash version 2 
                        The opcontrol script requires bash version 2 at least to be installed as /bin/bash or /bin/bash2 
                OProfile GUI 
                        The use of the GUI to start the profiler requires the Qt 2 library. Qt 3 should also work. 
                ELF 
                        Probably not too strenuous a requirement, but older A.OUT binaries/libraries are not supported. 
                K&R coding style 
                        OK, so it's not really a requirement, but I wish it was... 
        
        源文档 <>
阅读(2370) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~