lighttpd及pcre的交叉编译

来源:互联网 发布:自定义票据打印软件 编辑:程序博客网 时间:2024/06/05 06:50

lighttpd及pcre的交叉编译(不成熟)

    • lighttpd及pcre的交叉编译不成熟
      • A环境说明
      • B交叉编译思路
      • C编译pcre
        • 配置脚本设置编译工具等
        • 编译安装
        • 将库文件导入cache运行环境中的
        • 将路径导入环境变量运行环境的
      • D编译lighttpd
        • 配置脚本设置编译工具等
        • 编译安装
        • 文件结构设置与配置服务器
        • 服务器的启动和关闭

A.环境说明

  • 编译环境
    ubuntu12.04
    i686-pc-linux
  • 运行环境
    openwrt
  • 交叉编译工具
    mips-openwrt-linux

B.交叉编译思路

  • 在 lighttpd与相关依赖库的安装 基础下进行本次交叉编译
  • 通过config脚本配置编译环境中的编译工具为交叉编译工具
  • 安装目录设置为最终运行目录,使得移植之后能够正确匹配
  • 将需要的环境配置在运行设备上

C.编译pcre

1.配置脚本(设置编译工具等)

vim configure-opw.sh

#! /bin/shCXX=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-g++ CC=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc AR=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-ar LD=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-ld RANLIB=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-ranlib STRIP=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-strip ./configure  --prefix=/usr/pcre --host=mips-openwrt-linux --build=i686-pc-linux --enable-utf8 --enable-unicode-properties

将脚本复制到安装文件路径后,进行配置
./configure-opw.sh
注:
必须指定g++编译器,因为在本文件编译中需要通过CPP编译相关动态库,并且在之后会使用,若不指定,会出现如下错误:

  CXX      libpcrecpp_la-pcrecpp.lo  CXX      libpcrecpp_la-pcre_scanner.lo  CXX      libpcrecpp_la-pcre_stringpiece.lo  CXXLD    libpcrecpp.la./.libs/libpcre.so: could not read symbols: File in wrong formatcollect2: ld returned 1 exit status

2.编译安装

make && make install
提示:
可以在make编译完后可以执行make check进行测试

3.将库文件导入cache(运行环境中的)

  • 方法1:在/etc/ld.so.conf/中加入:
    /usr/local/lib/pcre,然后运行ldconfig
  • 方法2:在/etc/ld.so.conf.d/下新生成一个文件(或在其中的文件中加入同样内容),文件内容为:
    /usr/local/lib/pcre,然后运行ldconfig

4.将路径导入环境变量(运行环境的)

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$/usr/local/lib/pcre
export LD_LIBRARY_PATH
C_INCLUDE_PATH=/usr/include/libxml2:/usr/local/include/pcre
export C_INCLUDE_PATH

D.编译lighttpd

1.配置脚本(设置编译工具等)

vim configure-opw.sh

#! /bin/shCC=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc AR=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-ar LD=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-ld RANLIB=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-ranlib STRIP=/home/jeff/extfs/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-strip ./configure --prefix=/tmp/webserver/lighttpd-1.4.42-opw --host=mips-openwrt-linux --build=i686-pc-linux --disable-FEATURE --enable-shared --disable-static --disable-lfs --disable-ipv6 --without-PACKAGE --without-valgrind --without-openssl --without-kerberos5 --without-pcre --without-zlib --without-bzip2

将脚本复制到安装文件路径后,进行配置
./configure-opw.sh

2.编译安装

make && make install

3.文件结构设置与配置服务器

根据需要进行服务器功能模块裁剪

5.服务器的启动和关闭

  1. 设置执行文件权限
    chmod 777 [服务器路径]/sbin -R
  2. 启动服务器
    [服务器路径]/sbin/lighttpd -f [服务器路径]/config/lighttpd.conf
  3. 访问服务器
    在浏览器中输入ip:port,访问服务器主页
    主页路径在/webpages
  4. 关闭服务器
    killall lighttpd
0 0
原创粉丝点击