Open××× 2.4.3 -- released on 2017.06.21,目前已经是最近的版本。

在交叉编译open***-2.4.3时候遇到一些问题,分享一下。

依赖库 openssl , lzo,  pam,所有依赖库的交叉编译就不多少了。

/usr/local/include所有依赖的头文件路径

/root/mylib/ssl-lib所有依赖的库文件路径

[root@localhost ~]# tar  xzvf open***-2.4.3.tar.gz 

[root@localhost ~]# cd  open***-2.4.3

[root@localhost open***-2.4.3]# ./configure CC=mipsel-linux-gcc AR=mipsel-linux-ar BANLIB=mipsel-linux-ranlib --host=mipsel-linux LIBPAM_CFLAGS=-I/usr/local/include LIBPAM_LIBS=-L/root/mylib/ssl-lib OPENSSL_CFLAGS=-I/usr/local/include OPENSSL_LIBS=-L/root/mylib/ssl-lib  LZO_CFLAGS=-I/usr/local/include  LZO_LIBS=-L/root/mylib/ssl-lib --disable-lz4

checking for library containing __res_init... none required

checking net/if_tun.h usability... no

checking net/if_tun.h presence... no

checking for net/if_tun.h... no

checking net/tun/if_tun.h usability... no

checking net/tun/if_tun.h presence... no

checking for net/tun/if_tun.h... no

checking linux/if_tun.h usability... yes

checking linux/if_tun.h presence... yes

checking for linux/if_tun.h... yes

checking tlocalhost-windows.h usability... no

checking tlocalhost-windows.h presence... no

checking for tlocalhost-windows.h... no

checking whether TUNSETPERSIST is declared... yes

checking for setcon in -lselinux... no

checking for PKCS11_HELPER... no

checking for SSL_CTX_new... no

configure: error: openssl check failed

[root@localhost open***-2.4.3]# vim configure

16563行     LIBS="${LIBS} ${OPENSSL_LIBS} -lssl -lcrypto -llzo2 -ldl"

[root@localhost open***-2.4.3]# ./configure CC=mipsel-linux-gcc AR=mipsel-linux-ar BANLIB=mipsel-linux-ranlib --host=mipsel-linux LIBPAM_CFLAGS=-I/usr/local/include LIBPAM_LIBS=-L/root/mylib/ssl-lib OPENSSL_CFLAGS=-I/usr/local/include OPENSSL_LIBS=-L/root/mylib/ssl-lib  LZO_CFLAGS=-I/usr/local/include  LZO_LIBS=-L/root/mylib/ssl-lib --disable-lz4

checking that generated files are newer than configure... done

configure: creating ./config.status

config.status: creating version.sh

config.status: creating Makefile

config.status: creating build/Makefile

config.status: creating build/msvc/Makefile

config.status: creating build/msvc/msvc-generate/Makefile

config.status: creating distro/Makefile

config.status: creating distro/rpm/Makefile

config.status: creating distro/rpm/open***.spec

config.status: creating distro/systemd/Makefile

config.status: creating include/Makefile

config.status: creating src/Makefile

config.status: creating src/compat/Makefile

config.status: creating src/open***/Makefile

config.status: creating src/open***serv/Makefile

config.status: creating src/plugins/Makefile

config.status: creating src/plugins/auth-pam/Makefile

config.status: creating src/plugins/down-root/Makefile

config.status: creating tests/Makefile

config.status: creating tests/unit_tests/Makefile

config.status: creating tests/unit_tests/example_test/Makefile

config.status: creating tests/unit_tests/open***/Makefile

config.status: creating tests/unit_tests/plugins/Makefile

config.status: creating tests/unit_tests/plugins/auth-pam/Makefile

config.status: creating vendor/Makefile

config.status: creating sample/Makefile

config.status: creating doc/Makefile

config.status: creating tests/t_client.sh

config.status: creating config.h

config.status: creating include/open***-plugin.h

config.status: include/open***-plugin.h is unchanged

config.status: executing depfiles commands

config.status: executing libtool commands

[root@localhost open***-2.4.3]# make

tun.c: In function `tuncfg':

tun.c:2090: error: `TUNSETGROUP' undeclared (first use in this function)

tun.c:2090: error: (Each undeclared identifier is reported only once

tun.c:2090: error: for each function it localhostpears in.)

make[3]: *** [tun.o] 错误 1

make[3]: Leaving directory `/root/open***-2.4.3/src/open***'

make[2]: *** [all-recursive] 错误 1

make[2]: Leaving directory `/root/open***-2.4.3/src'

make[1]: *** [all-recursive] 错误 1

make[1]: Leaving directory `/root/open***-2.4.3'

make: *** [all] 错误 2

[root@localhost open***-2.4.3]# vim  src/open***/tun.h 

#ifndef TUNSETGROUP

#define TUNSETGROUP _IOW('T', 206, int)

#endif

[root@localhost open***-2.4.3]# make

ssl_verify_openssl.o(.text+0x1278):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:476: undefined reference to `X509_NAME_get_index_by_NID'

ssl_verify_openssl.o(.text+0x1294):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:479: undefined reference to `X509_NAME_get_entry'

ssl_verify_openssl.o(.text+0x12b0):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:482: undefined reference to `X509_NAME_ENTRY_get_data'

ssl_verify_openssl.o(.text+0x12c8):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:485: undefined reference to `ASN1_STRING_to_UTF8'

ssl_verify_openssl.o(.text+0x1304):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:488: undefined reference to `CRYPTO_free'

ssl_verify_openssl.o(.text+0x1328):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:494: undefined reference to `X509_get_ext_by_NID'

ssl_verify_openssl.o(.text+0x1348):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:497: undefined reference to `X509_get_ext'

ssl_verify_openssl.o(.text+0x1364):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:500: undefined reference to `BIO_s_mem'

ssl_verify_openssl.o(.text+0x137c):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:500: undefined reference to `BIO_new'

ssl_verify_openssl.o(.text+0x1398):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:503: undefined reference to `X509V3_EXT_print'

ssl_verify_openssl.o(.text+0x13bc):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:512: undefined reference to `BIO_free'

ssl_verify_openssl.o(.text+0x1434):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:505: undefined reference to `BIO_write'

ssl_verify_openssl.o(.text+0x1454):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:508: undefined reference to `BIO_ctrl'

ssl_verify_openssl.o(.text+0x1488):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:512: undefined reference to `BIO_free'

ssl_verify_openssl.o(.text+0x14d8): In function `x509_setenv':

/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:542: undefined reference to `X509_get_subject_name'

ssl_verify_openssl.o(.text+0x14f4):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:544: undefined reference to `X509_NAME_entry_count'

ssl_verify_openssl.o(.text+0x1514):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:547: undefined reference to `X509_NAME_get_entry'

ssl_verify_openssl.o(.text+0x1530):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:552: undefined reference to `X509_NAME_ENTRY_get_object'

ssl_verify_openssl.o(.text+0x154c):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:557: undefined reference to `X509_NAME_ENTRY_get_data'

ssl_verify_openssl.o(.text+0x1568):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:562: undefined reference to `OBJ_obj2nid'

ssl_verify_openssl.o(.text+0x1584):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:567: undefined reference to `OBJ_nid2sn'

ssl_verify_openssl.o(.text+0x15d8):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:573: undefined reference to `ASN1_STRING_to_UTF8'

ssl_verify_openssl.o(.text+0x16cc):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:586: undefined reference to `CRYPTO_free'

ssl_verify_openssl.o(.text+0x1760): In function `x509_verify_ns_cert_type':

/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:603: undefined reference to `X509_check_purpose'

ssl_verify_openssl.o(.text+0x1784):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:631: undefined reference to `X509_check_purpose'

ssl_verify_openssl.o(.text+0x17ac):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:614: undefined reference to `X509_get_ext_d2i'

ssl_verify_openssl.o(.text+0x1800):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:621: undefined reference to `ASN1_BIT_STRING_free'

ssl_verify_openssl.o(.text+0x181c):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:642: undefined reference to `X509_get_ext_d2i'

ssl_verify_openssl.o(.text+0x1874):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:649: undefined reference to `ASN1_BIT_STRING_free'

ssl_verify_openssl.o(.text+0x1964): In function `x509_verify_cert_ku':

/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:661: undefined reference to `X509_get_ext_d2i'

ssl_verify_openssl.o(.text+0x19a8):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:679: undefined reference to `ASN1_BIT_STRING_get_bit'

ssl_verify_openssl.o(.text+0x1a64):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:713: undefined reference to `ASN1_BIT_STRING_free'

ssl_verify_openssl.o(.text+0x1c40):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:672: undefined reference to `ASN1_BIT_STRING_free'

ssl_verify_openssl.o(.text+0x1d30): In function `x509_verify_cert_eku':

/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:724: undefined reference to `X509_get_ext_d2i'

ssl_verify_openssl.o(.text+0x1d94):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:734: undefined reference to `sk_num'

ssl_verify_openssl.o(.text+0x1db4):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:736: undefined reference to `sk_value'

ssl_verify_openssl.o(.text+0x1dcc):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:739: undefined reference to `OBJ_obj2txt'

ssl_verify_openssl.o(.text+0x1e4c):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:762: undefined reference to `sk_pop_free'

ssl_verify_openssl.o(.text+0x1e50):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:762: undefined reference to `ASN1_OBJECT_free'

ssl_verify_openssl.o(.text+0x1e94):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:748: undefined reference to `OBJ_obj2txt'

ssl_verify_openssl.o(.text+0x2058): In function `x509_write_pem':

/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:771: undefined reference to `PEM_write_X509'

ssl_verify_openssl.o(.text+0x214c): In function `tls_verify_crl_missing':

/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:787: undefined reference to `SSL_CTX_get_cert_store'

ssl_verify_openssl.o(.text+0x2198):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:794: undefined reference to `sk_num'

ssl_verify_openssl.o(.text+0x21b4):/root/open***-2.4.3/src/open***/ssl_verify_openssl.c:796: undefined reference to `sk_value'

collect2: ld returned 1 exit status

make[3]: *** [open***] 错误 1

make[3]: Leaving directory `/root/open***-2.4.3/src/open***'

make[2]: *** [all-recursive] 错误 1

make[2]: Leaving directory `/root/open***-2.4.3/src'

make[1]: *** [all-recursive] 错误 1

make[1]: Leaving directory `/root/open***-2.4.3'

make: *** [all] 错误 2

[root@localhost open***-2.4.3]# vim  config.status 

S["LIBS"]="-lssl -lcrypto -llzo2 -ldl"

[root@localhost open***-2.4.3]# make

libtool: link:  /opt/crosstool/mipsel-linux/bin/mipsel-linux-gcc -shared  -fPIC -DPIC  .libs/down-root.o   -lssl -lcrypto -llzo2 -ldl  -g -O2   -Wl,-soname -Wl,open***-plugin-down-root.so -Wl,-version-script -Wl,.libs/open***-plugin-down-root.ver -o .libs/open***-plugin-down-root.so

/opt/crosstool/mipsel-linux/bin/../lib/gcc/mipsel-linux/3.4.5/../../../../mipsel-linux/bin/ld: cannot find -lssl

collect2: ld returned 1 exit status

make[4]: *** [open***-plugin-down-root.la] 错误 1

make[4]: Leaving directory `/root/open***-2.4.3/src/plugins/down-root'

make[3]: *** [all-recursive] 错误 1

make[3]: Leaving directory `/root/open***-2.4.3/src/plugins'

make[2]: *** [all-recursive] 错误 1

make[2]: Leaving directory `/root/open***-2.4.3/src'

make[1]: *** [all-recursive] 错误 1

make[1]: Leaving directory `/root/open***-2.4.3'

make: *** [all] 错误 2

[root@localhost open***-2.4.3]# vim  config.status 

S["LDFLAGS"]="-L/root/mylib/ssl-lib"

[root@localhost open***-2.4.3]# make

编译通过。