Chinaunix首页 | 论坛 | 博客
  • 博客访问: 537078
  • 博文数量: 119
  • 博客积分: 3391
  • 博客等级: 中校
  • 技术积分: 981
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-12 11:49
文章分类

全部博文(119)

文章存档

2014年(3)

2013年(1)

2011年(18)

2010年(27)

2009年(70)

我的朋友

分类: LINUX

2009-03-12 21:20:23

[假设你的交叉编译工具安装在/usr/arm目录下的哈]


step1:下载并解压jpeg源代码包


step2:
#cd ./jpeg-6b
#./configure --prefix=/usr/arm/arm-linux --exec-prefix=/usr/arm/arm-linux \
               --enable-shared --enable-static
下面分别介绍这几个参数的作用:

--prefix=/usr/arm/arm-linux : 执行make install 后,会将与体系无关的文件拷贝到此目录下,具体如下:
/usr/arm/arm-linux .....................................
        |
       +---include........................................
             |
             ---jconfig.h
             |
             ---jerror.h
             |
             ---jmorecfg.h
             |
             ---jpeglib.h
       +---man............................................
             |
            +---man1.......................................
                  |
                  ---cjeg.1
                  |
                  ---djpeg.1
                  |
                  ---jpegtran.1
                  |
                  ---rdjpgcom.1
                  |
                  ---wrjpgcom.1
               
--exec-prefix=/usr/arm/arm-linux : 执行make install 后,会将与体系无关的文件拷贝到此目录下,即将一些可执行程序、动态链接库和静态链接库拷贝到此目录的相应目录下,具体如下:
/usr/arm/arm-linux ........................................
        |
       +---bin............................................
             |
             ---cjeg
             |
             ---djpeg
             |
             ---jpegtran
             |
             ---rdjpgcom
             |
             ---wrjpgcom
       +---lib...........................................
             |
             ---libjpeg.la
             |
             ---libjpeg.so
             |
             ---libjpeg.so.62
             |
             ---libjpeg.so.62.0.0
           
--enable-shared : 用GNU libtool编译成动态链接库
。下面分别对应有无此参数所生成的Makefile的比较:
       --------------------------------------------------------------------------------------
              无--enable-shared参数             |               有--enable-shared参数
       --------------------------------------------------------------------------------------
                    LIBTOOL =                   |            LIBTOOL = ./libtool
       --------------------------------------------------------------------------------------
                   O = o  A = a                 |            O = lo    A = la
       -------------------------------------------------------------------------------------
                   LN= $(CC)                    |      LN= $(LIBTOOL) --mode=link $(CC)
       --------------------------------------------------------------------------------------
     INSTALL_PROGRAM= ${INSTALL}     |  INSTALL_PROGRAM= $(LIBTOOL) --mode=install ${INSTALL}
        INSTALL_LIB= ${INSTALL} -m 644  |  INSTALL_LIB= $(LIBTOOL) --mode=install ${INSTALL}
      ---------------------------------------------------------------------------------------
           无参数:
              # .c.lo:
              #  $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c
           有参数:
              .c.lo:
              $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$*.c
   ------------------------------------------------------------------------------------------
          无参数:
             install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom
          有参数:
             install: cjpeg djpeg jpegtran rdjpgcom wrjpgcom install-lib
    -----------------------------------------------------------------------------------------


step3:修改生成的Makefile文件:
       # The name of your C compiler:
       CC= gcc  该成  CC=/usr/arm/bin/arm-linux-gcc (根据你自己交叉编译器的位置修改)
       # library (.a) file creation command
       AR= ar rc 该成  AR= /usr/arm/bin/arm-linux-ar rc  (同上)
       # second step in .a creation (use "touch" if not needed)
       AR2= ranlib 该成  AR2= /usr/arm/bin/arm-linux-ranlib (同上)


step4:#make
      #make install
      
这样JPEG库就交叉编译成功了,相应的库和头文件都在/usr/arm/arm-linux/include 和/usr/arm/arm-linux/lib目录下了



安装好以后就在这2个目录下增加了如下文件:
/usr/arm/arm-linux/include
jerror.h
jmorecfg.h
jconfig.h
jpeglib.h
/usr/arm/arm-linux/lib
libjpeg.a
libjpeg.la
libjpeg.so
libjpeg.so.62
libjpeg.so.62.0.0
编译程序的时候记得加上 -ljpeg
不然大概就有下面这些
/tmp/cc4aJtAS.o: In function `write_JPEG_file':
/tmp/cc4aJtAS.o(.text+0x20): undefined reference to `jpeg_std_error'
/tmp/cc4aJtAS.o(.text+0x3c): undefined reference to `jpeg_CreateCompress'
/tmp/cc4aJtAS.o(.text+0x88): undefined reference to `jpeg_stdio_dest'
/tmp/cc4aJtAS.o(.text+0xbc): undefined reference to `jpeg_set_defaults'
/tmp/cc4aJtAS.o(.text+0xd0): undefined reference to `jpeg_set_quality'
/tmp/cc4aJtAS.o(.text+0xe0): undefined reference to `jpeg_start_compress'
/tmp/cc4aJtAS.o(.text+0x140): undefined reference to `jpeg_write_scanlines'
/tmp/cc4aJtAS.o(.text+0x168): undefined reference to `jpeg_finish_compress'
/tmp/cc4aJtAS.o(.text+0x17c): undefined reference to `jpeg_destroy_compress'
阅读(876) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~