Jan 05

想利用 DD-WRT 支持 Buffalo WZR-1750DHP 全部 512M 内存的固件来做编译机,安装了 Tomatoware。

编译一些无需通过 automake/autoconf 生成 Makefile 的源程序都没啥问题,但是一旦编译通过 autogen.sh (应该调用 automake 等程序)生成的 Makefile 就会直接出错,信息类似:

[goflex@GoFLEX:/home/local/goflex/work/shairport-sync_git 35%] ~ make
make all-recursive
make[1]: Entering directory '/home/local/goflex/work/shairport-sync_git'
Making all in man
Makefile:518: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/local/goflex/work/shairport-sync_git'
Makefile:371: recipe for target 'all' failed
make: *** [all] Error 2
[goflex@GoFLEX:/home/local/goflex/work/shairport-sync_git 36%] ~

参考:

https://forum.openwrt.org/viewtopic.php?id=60605

https://github.com/lancethepants/tomatoware/issues/18#issuecomment-168871785

目前没什么好的解决办法,好在出错的地方有些规律,就是在 Makefile 中 dot_seen=no; 这句上面的反斜杠“\”需要去掉;写了个脚本做提示:

#!/bin/sh

curr_dir=`pwd`

bad_makefile=""
bad_makefile_line=""

bad_makefile_line=$(sed -n '/dot_seen=no;/=' `grep -lr 'dot_seen=no;' $curr_dir`)
bad_makefile=$(grep -lr 'dot_seen=no;' $curr_dir)

for bfile in $bad_makefile; do
    echo $bfile
done

for line in $bad_makefile_line; do
    fi_line="$(($line - 1))"
    echo $fi_line
done

echo "sed -i 'LINEs/\//' FILE"

它会列出需要修改的文件,所在行数,提示用:

sed -i 'LINEs/\//' FILE

去修改。

参考上面的帖子链接,最终确认是 DD-WRT 自带 /bin/bash 的问题,解决方法是:在 ./configure 之前建立一个环境变量:

export CONFIG_SHELL=/mmc/bin/bash

用来覆盖配置文件建立时默认使用的 /bin/bash 即可。


Dec 30

先配置下选项,我这里以 PolarSSL 为例:
./configure --prefix=/opt --with-crypto-library=polarssl --with-polarssl=/mmc/lib --with-polarssl-include=/mmc/include

为了解决编译时出现的 epoll 相关错误(应为 uClibc 版本低的原因),需要:
sed -i "s/epoll_create1/epoll_create/g" ./libev/ev_epoll.c

使用 ldtools 的话,可以在编译二进制文件时指定 -all-static:
sed -i "s/LDFLAGS = /LDFLAGS = -all-static/g" ./src/Makefile

然后就可以:

make
strip ./src/ss-*
make install

Nov 24

下载编译 libsodium:

git clone https://github.com/jedisct1/libsodium.git
cd libsodium
./autogen.sh
./configure --enable-minimal --enable-static --disable-shared --prefix=/mmc
make && make install

静态编译 dnscrypt-proxy:

git clone https://github.com/jedisct1/dnscrypt-proxy.git
cd dnscrypt-proxy
./autogen.sh
./configure LDFLAGS='-Wl,-static -static -static-libgcc -s -Wl,--gc-sections' --prefix=/opt
#1.7.0+
LDFLAGS='-Wl,-static -static -static-libgcc -s' ./configure --prefix=/opt --with-included-ltdl && make -j2
make

:twisted: :twisted: :twisted:


Nov 05

使用 Tomato 固件,先下载 tomatoware:

CMake:
./bootstrap --prefix=/mmc && make && make install

libsodium:
./configure --prefix=/mmc && make && make install

然后静态编译 DNSProxy" title="Pcap_DNSProxy GITHUB" rel="external">Pcap_DNSProxy ,需要修改下源码的 /Pcap_DNSProxy/Source/Pcap_DNSProxy/CMakeLists.txt 文件:

Executable file name
#static
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
SET(CMAKE_EXE_LINKER_FLAGS "-static -pthread -Wl,--whole-archive 
-lpthread -Wl,--no-whole-archive")
#static
add_executable(Pcap_DNSProxy ${MAIN_SRC_FILES})
IF(PLATFORM_OPENWRT)
INSTALL(TARGETS Pcap_DNSProxy RUNTIME DESTINATION sbin)
ENDIF(PLATFORM_OPENWRT)

注意:单独使用 -static 编译出来的文件执行会出错,要结合后面那堆参数:

terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted

Pcap_DNSProxy

当然还是希望作者加一个静态编译的开关选项。

已提交,作者已添加:

* 使用 ./Linux_Build.sh 执行编译程序
* 添加参数 --enable-static 即 ./Linux_Build.sh --enable-static 可启用静态编译


Apr 17

直接编译会出错:

/opt/lib//libcrypto.a(c_zlib.o): In function zlib_stateful_expand_block': c_zlib.c:(.text+0x54): undefined reference toinflate'
/opt/lib//libcrypto.a(c_zlib.o): In function zlib_stateful_compress_block': c_zlib.c:(.text+0xd8): undefined reference todeflate'
/opt/lib//libcrypto.a(c_zlib.o): In function bio_zlib_free': c_zlib.c:(.text+0x128): undefined reference toinflateEnd'
c_zlib.c:(.text+0x144): undefined reference to deflateEnd' /opt/lib//libcrypto.a(c_zlib.o): In functionzlib_stateful_finish':
c_zlib.c:(.text+0x194): undefined reference to inflateEnd' c_zlib.c:(.text+0x19c): undefined reference todeflateEnd'
/opt/lib//libcrypto.a(c_zlib.o): In function zlib_stateful_init': c_zlib.c:(.text+0x224): undefined reference toinflateInit_'
c_zlib.c:(.text+0x26c): undefined reference to deflateInit_' /opt/lib//libcrypto.a(c_zlib.o): In functionbio_zlib_ctrl':
c_zlib.c:(.text+0x4a0): undefined reference to deflate' c_zlib.c:(.text+0x56c): undefined reference tozError'
/opt/lib//libcrypto.a(c_zlib.o): In function bio_zlib_write': c_zlib.c:(.text+0x708): undefined reference todeflate'
c_zlib.c:(.text+0x794): undefined reference to zError' c_zlib.c:(.text+0x824): undefined reference todeflateInit_'
/opt/lib//libcrypto.a(c_zlib.o): In function bio_zlib_read': c_zlib.c:(.text+0x900): undefined reference toinflate'
c_zlib.c:(.text+0x954): undefined reference to zError' c_zlib.c:(.text+0x9e0): undefined reference toinflateInit_'
collect2: error: ld returned 1 exit status
Makefile:94: recipe for target 'redsocks2' failed
make: *** [redsocks2] Error 1

解决方法,修改 Makefile:
override LIBS += -lssl -lcrypto -ldl

改成:
override LIBS += -lssl -lcrypto -ldl -lz

然后:
CCFLAGS=-static make

或者(tomatoware)
LDFLAGS="-Wl,-static -static -static-libgcc" make

编译成功。


[2/2]  < 1 2