一半君的总结纸

听话只听一半君

update: crosstool-ng 1.2.2 cross compile shadowsocks-libev 2.4.1 for 磊科q3 asus rt-n66u rt-n16

更新一下上一篇 CentOS 7下交叉编译tomato 1.2.8 v131路由器(磊科Q3)可以使用的shadowsocks 2.3.1 – 正/逆翻墙用

本文的内容已过时,请参考这篇: crosstool-ng 1.22.0 and shadowsocks 2.4.5 备忘录,有编译好的版本下载.

  1. 编译crosstools-ng 1.2.2 最后lz使用的还是上一篇中的1.21
    sudo yum install -y gperf texinfo glib* libstdc++* help2man ncurses-devel makedepend
    git clone https://github.com/crosstool-ng/crosstool-ng.git
    cd crosstool-ng
    git checkout tags/crosstool-ng-1.22.0
    ./bootstrap 
    ./configure
    make && make install
    
    
  2. 编译toolchain
    我的crosstools-ng 配置文件,uclibc 0.9.33配置文件

    前者是ct-ng list-samples之后找了最像的mips-unknown-linux-uclibc,选了他之后ct-ng arm-unknown-linux-gnueabi,然后手动改了一些选项ct-ng menuconfig,用的时候你得把uclibc的config文件的路径选成你自己的,lz打开了Save intermediate steps,万一你哪一步出错了你可以改下配置,从那里继续ct-ng LAST_SUCCESSFUL_STETP_NAME+

    后者的配置文件是从buildroot里来的,make uclibc-menuconfig,

    # 可以打开配置页面,然后load lz的配置文件
    ct-ng menuconfig
    
    # build
    ct-ng build.4
    
    # 如果中间出错 又不想完全从头开始
    # 虽然配置文件里已经设了保存每步,也可以这样在命令行启用
    CT_DEBUG_CT_SAVE_STEPS=1 ct-ng build
    # 显示有哪些steps
    ct-ng list-steps
    # 从指定的step恢复
    RESTART=libc_start_files ct-ng build
    
    # 弄好以后
    export PATH=/home/oglop/x-tools/mipsel-unknown-linux-uclibc/bin:$PATH
    

    关键版本号

    GCC Binutils GMP MPFR ISL MPC expat ncurses uclibc
    5.2.0 2.25.1 6.0.0a 3.1.3 0.12.2 1.0.3 2.1.0 6.0 0.9.33.2
  3. 编译zlib
    wget http://zlib.net/zlib-1.2.8.tar.gz
    cd zlib-1.2.8
    export PATH=/home/oglop/x-tools/mipsel-unknown-linux-uclibc/bin:$PATH
    tar xvf zlib-1.2.8.tar.gz 
    cd zlib-1.2.8/
    CC=mipsel-unknown-linux-uclibc-gcc CXX=mipsel-unknown-linux-uclibc-g++ AR=mipsel-unknown-linux-uclibc-ar RANLIB=mipsel-unknown-linux-uclibc-ranlib ./configure --prefix=/home/oglop/Downloads/zlib-install
    make && make install
    
  4. 编译openssl
    git clone https://github.com/openssl/openssl.git
    git checkout tags/OpenSSL_1_0_2d
    CC=mipsel-linux-uclibc-gcc CXX=mipsel-linux-uclibc-g++ AR=mipsel-linux-uclibc-ar RANLIB=mipsel-linux-uclibc-ranlib ./Configure no-asm shared --prefix=/home/oglop/Downloads/openssl-install linux-mips32
    make && make install
    
  5. 编译shadowsocks 2.4.1
    git clone https://github.com/shadowsocks/shadowsocks-libev.git
    cd shadowsocks-libev
    git checkout tags/v2.4.1
    CC=mipsel-unknown-linux-uclibc-gcc CXX=mipsel-unknown-linux-uclibc-g++ AR=mipsel-unknown-linux-uclibc-ar RANLIB=mipsel-unknown-linux-uclibc-ranlib ./configure --prefix=/home/oglop/Downloads/ss-install  --with-openssl=/home/oglop/Downloads/openssl-install --host=mipsel-uclibc-linux --with-zlib=/home/oglop/Downloads/zlib-install
    make V=99 && make install
    

    看看是不是dynamic的

    [oglop@t450s test]$ mipsel-unknown-linux-uclibc-ldd --root ~/x-tools/mipsel-unknown-linux-uclibc /home/oglop/Downloads/ss-install-static/bin/strip/ss-server
            libcrypto.so.1.0.0 not found
            libm.so.0 => /lib/libm.so.0 (0x8badf00d)
            libc.so.0 => /lib/libc.so.0 (0x8badf00d)
            ld-uClibc.so.0 => /lib/ld-uClibc.so.0 (0x8badf00d)
            libz.so.1 not found
            libdl.so.0 => /lib/libdl.so.0 (0x8badf00d)
            libpthread.so.0 => /lib/libpthread.so.0 (0x8badf00d)
    

    瘦身一下

    [oglop@t450s shadowsocks-libev]$ ll /home/oglop/Downloads/ss-install/bin/
    total 3172
    -rwxr-xr-x. 1 oglop oglop 725612 Dec  1 06:37 ss-local
    -rwxr-xr-x. 1 oglop oglop 406976 Dec  1 06:37 ss-manager
    -rwxr-xr-x. 1 oglop oglop 623444 Dec  1 06:37 ss-redir
    -rwxr-xr-x. 1 oglop oglop 856168 Dec  1 06:37 ss-server
    -rwxr-xr-x. 1 oglop oglop 622196 Dec  1 06:37 ss-tunnel
    
    [oglop@t450s test]$ mipsel-unknown-linux-uclibc-strip /home/oglop/Downloads/ss-install/bin/*
    [oglop@t450s test]$ upx /home/oglop/Downloads/ss-install/bin/*
                           Ultimate Packer for eXecutables
                              Copyright (C) 1996 - 2013
    UPX 3.91        Markus Oberhumer, Laszlo Molnar & John Reiser   Sep 30th 2013
    
            File size         Ratio      Format      Name
       --------------------   ------   -----------   -----------
        182412 ->     85636   46.95%  linux/mipsel   ss-local                      
        106480 ->     49364   46.36%  linux/mipsel   ss-manager                    
        162780 ->     77972   47.90%  linux/mipsel   ss-redir                      
        218064 ->     99912   45.82%  linux/mipsel   ss-server                     
        162764 ->     77440   47.58%  linux/mipsel   ss-tunnel                     
       --------------------   ------   -----------   -----------
        832500 ->    390324   46.89%                 [ 5 files ]
    

文件下载:
还是用上篇的ct-ng 1.21编译的
shadowsocks-libev_2.4.1_mipsel_OpenSSL_dynamic.tar.gz
mipsel-unknown-linux-uclibc-1.22.0.tar.gz
openssl-1.0.2d-dynamic-install.tar.gz

ps:lz在asus rt-n16上的tomato shibby版的v132上测试了下可用.

备注:
碰到过的错误

# 自己编译了zlib以后,加上--with-zlib=后没了
checking zlib.h usability... no
checking zlib.h presence... no
checking for zlib.h... no
configure: error: "zlib header files not found."

# 用了1.22的crosstools-ng和0.9.33的uclibc以后没了
checking for pthread-config... no
configure: error: Missing Pthread Library

Advertisements

8 responses to “update: crosstool-ng 1.2.2 cross compile shadowsocks-libev 2.4.1 for 磊科q3 asus rt-n66u rt-n16

  1. HOUZI 十二月 13, 2015 @ 9:11 下午

    您编译的这个运行不了哦!原因是使用了mispel不支持的epoll_create1函数编译,因为由于内核版本过低,所以便以的时候把epoll_create1改为epoll_create来编译,可能会出现一些函数重复的错误,但编译出来的可以正常运行!
    错误:
    /opt/bin/ss-redir: can’t resolve symbol ‘epoll_create1’ in lib ‘/opt/bin/ss-redir’.
    不知道您运行是否报错!可以使用entware_ng的工具链编译!

  2. HOUZI 十二月 15, 2015 @ 8:18 下午

    这个问题我已经解决了!我直接使用wl500g的toochain和tomato-shibby的内核源码来构建一个gcc 4.8.5的已经完美解决!这样构建更符合tomato内建的库文件!

  3. Terence 一月 5, 2016 @ 8:22 下午

    我在编译OpenSSL 0.9.8j的时候发现设置的CC等变量不起效果,后来发现这样就可以了
    ./Configure no-asm –prefix=/root/xxxx/ os/compiler:mipsel-unknown-linux-uclibc-gcc。
    shared参数提示arm平台不支持

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: