版本:
libxml2-2.9.1
openssl-1.0.1e
libssh2-1.4.3
linux下的开源软件的编译比较统一,一般分为如下几步
./configure;make;make install
如果是交叉编译需要考虑,1.指定交叉编译工具的PATH 2.指定交叉编译工具CC
3.交叉编译的架构host 4.编译输出目录
如下脚本:
#!/bin/bash
export PATH=$PATH:/opt/ppc/eldk4.2/usr/bin
PREPATH=${PWD}
rm ${PREPATH}/Output -rf
mkdir ${PREPATH}/Output
chmod +x configure
./configure \
CC=ppc_85xxDP-gcc \
--host=powerpc-linux \
--prefix=${REPATH}/Output
make
make install
所以会找不到库和头文件
一、libxml2编译
按照上面脚本,改好相关参数,没有出现问题
二、openssl编译
这套软件就没有按套路出牌,出现了Configure和config两个脚本
1.配置
./Configure \
--prefix=/opt/ppc/eldk4.2/ppc_85xxDP/usr \
os/compiler:ppc_85xxDP-gcc \
shared
./config \
linux-ppc \
--prefix=/opt/ppc/eldk4.2/ppc_85xxDP/usr \
--openssldir=/opt/ppc/eldk4.2/ppc_85xxDP/usr/openssl \
CC=ppc_85xxDP-gcc \
AR=ppc_85xxDP-ar \
RANLIB=ppc_85xxDP-ranlib \
shared \
no-asm
虽然有两个脚本,但还是不完善,所以指定了一大堆工具和路径
os/compiler:ppc_85xxDP-gcc 指定交叉编译器和架构类型
虽然加了shared参数,但最终还是没生成动态库2.修改Makefile
添加如下定义来指定交叉编译
CROSS_COMPILE= ppc_85xxDP-
经过这两步才可以make和make install,还是说的,这个库的编译为什么感觉这么low?
三、libssh2
这个源码包里有configure,编译结果仿佛呼之欲出...
1.配置
./configure \
CC=ppc_85xxDP-gcc \
--host=powerpc-linux \
--prefix=/opt/ppc/eldk4.2/ppc_85xxDP/usr \
--includedir=/opt/ppc/eldk4.2/ppc_85xxDP/usr/include \
--libdir=/opt/ppc/eldk4.2/ppc_85xxDP/usr/lib \
--disable-examples-build
# --with-libssl-prefix=/opt/ppc/eldk4.2/ppc_85xxDP/usr
# --without-libgcrypt \
make
make install
经过一些乱七八糟的错误后,建立了上面的配置
我觉得已经无懈可击了,但我还是卡在了下面的错误上
make[1]: Entering directory `/home/kevin/works/projects/ACCUMULATION/xml2_openssl/libssh2-1.4.3/tests'
/bin/bash ../libtool --tag=CC --mode=link ppc_85xxDP-gcc -g -O2 -o ssh2 ssh2.o ../src/libssh2.la
libtool: link: ppc_85xxDP-gcc -g -O2 -o ssh2 ssh2.o ../src/.libs/libssh2.a -L/opt/ppc/eldk4.2/ppc_85xxDP/usr/lib -lssl -lcrypto -lz
../src/.libs/libssh2.a(openssl.o): In function `aes_ctr_cleanup':
/home/kevin/works/projects/ACCUMULATION/xml2_openssl/libssh2-1.4.3/src/openssl.c:306: undefined reference to `EVP_CIPHER_CTX_get_app_data'
../src/.libs/libssh2.a(openssl.o): In function `aes_ctr_do_cipher':
/home/kevin/works/projects/ACCUMULATION/xml2_openssl/libssh2-1.4.3/src/openssl.c:267: undefined reference to `EVP_CIPHER_CTX_get_app_data'
../src/.libs/libssh2.a(openssl.o): In function `aes_ctr_init':
/home/kevin/works/projects/ACCUMULATION/xml2_openssl/libssh2-1.4.3/src/openssl.c:257: undefined reference to `EVP_CIPHER_CTX_set_app_data'
../src/.libs/libssh2.a(openssl.o): In function `_libssh2_cipher_crypt':
/home/kevin/works/projects/ACCUMULATION/xml2_openssl/libssh2-1.4.3/src/openssl.c:192: undefined reference to `EVP_Cipher'
collect2: ld returned 1 exit status
make[1]: *** [ssh2] Error 1
make[1]: Leaving directory `/home/kevin/works/projects/ACCUMULATION/xml2_openssl/libssh2-1.4.3/tests'
make: *** [install-recursive] Error 1
提示未定义的函数,于是查找了一下库里的内容
kevin@fzs:~/works/projects/ACCUMULATION/xml2_openssl/libssh2-1.4.3$ readelf -s /opt/ppc/eldk4.2/ppc_85xxDP/usr/lib/libssl.a |grep EVP_Cipher
20: 00000000 0 NOTYPE GLOBAL DEFAULT UND EVP_Cipher
36: 00000000 0 NOTYPE GLOBAL DEFAULT UND EVP_CipherInit_ex
45: 00000000 0 NOTYPE GLOBAL DEFAULT UND EVP_Cipher
38: 00000000 0 NOTYPE GLOBAL DEFAULT UND EVP_CipherInit_ex
52: 00000000 0 NOTYPE GLOBAL DEFAULT UND EVP_Cipher
18: 00000000 0 NOTYPE GLOBAL DEFAULT UND EVP_Cipher
明明有啊,为什么提示找不到,为什么?
莫名其妙的卡了一整天
最后我发现在/opt/ppc/eldk4.2/ppc_85xxDP/usr/lib下面有个libssl.so
原来,工具链里面有个老的libssl动态库,感觉到恶意后,删除
编译通过了,又学到了一点,程序编译的时候默认链接动态库