尝试在 SUSE Linux Enterprise Server 11 (x86_64) 上从源代码编译 Apache 2.4.16 时出现 OpenSSL 1.0.1g 错误

尝试在 SUSE Linux Enterprise Server 11 (x86_64) 上从源代码编译 Apache 2.4.16 时出现 OpenSSL 1.0.1g 错误

服务器信息:

# cat /etc/*-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 0
LSB_VERSION="core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64"

首先我安装了 OpenSSL 1.0.1g:

# tar -zxf openssl-1.0.1g.tar.gz
# cd /usr/src/openssl-1.0.1g
# make clean
# ./config --prefix=/usr --openssldir=/usr/local/openssl enable-tlsext no-shared no-zlib -fPIC no-gost
# make depend
# make
# make test
# make install
# mv /usr/bin/openssl /root/
# ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
# openssl version
  OpenSSL 1.0.1g 7 Apr 2014

然后我安装了 APR 和 APR-UTIL

# cd /usr/src

# tar -zxf apr-1.5.2.tar.gz
# cd /usr/src/apr-1.5.2
# ./configure
# make
# make test
# make install

# tar -zxf apr-util-1.5.4.tar.gz
# cd /usr/src/apr-util-1.5.4/
# ./configure --with-apr=/usr/local/apr --with-ldap=ldap  --with-crypto 
# make
# make test
# make install

# cp /usr/local/apr/bin/* /usr/bin

然后我安装Apache 2.4.16:

# tar -zxf httpd-2.4.16.tar.gz
# cd /usr/src/httpd-2.4.16/

# make clean

# env LDFLAGS=-ldl
# export LIBS=-ldl

# CFLAGS="-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables  -g -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED"; export CFLAGS

# CPPFLAGS="-DSSL_EXPERIMENTAL_ENGINE -DMAX_SERVER_LIMIT=200000 -DLDAP_DEPRECATED -DMAXLINE=4096"; export CPPFLAGS

# ./configure  --prefix=/usr/sbin/httpd \
--enable-shared \
--enable-layout=SuSE \
--with-apr=/usr/bin/apr-1-config \
--with-apr-util=/usr/bin/apu-1-config \
--enable-exception-hook \
--with-pcre \
--enable-pie \
--enable-ssl \
--with-ssl=/usr/local/ssl \
--enable-ssl-staticlib-deps \
--enable-mods-static=ssl \
--enable-mod_php5 \
--enable-mod_fcgid \
--enable-mod_perl \
--enable-mod_session_crypto \
--disable-isapi \
--enable-deflate \
--enable-echo \
--enable-filter \
--enable-ext-filter \
--enable-charset-lite \
--enable-file-cache \
--enable-logio \
--enable-dumpio \
--enable-bucketeer \
--enable-case_filter \
--enable-case_filter_in \
--with-ldap \
--enable-ldap \
--enable-authnz_ldap \
--enable-proxy \
--enable-proxy-connect \
--enable-proxy-ftp \
--enable-proxy-http \
--enable-cache \
--enable-disk-cache \
--enable-mem-cache \
--enable-VERSION \
--enable-dav-lock \
--enable-authn-alias \
--enable-optional-hook-export \
--enable-optional-hook-import \
--enable-optional-fn-import \
--enable-optional-fn-export \
--enable-suexec \
--with-suexec-bin=/usr/sbin/suexec2 \
--with-suexec-caller=wwwrun \
--with-suexec-docroot=/srv/www \
--with-suexec-logfile=/var/log/apache2/suexec.log \
--with-suexec-userdir=public_html \
--with-suexec-uidmin=96 \
--with-suexec-gidmin=96 \
--with-suexec-safepath=/usr/local/bin:/usr/bin:/bin 

配置似乎没有任何错误

然后我发出:

# make

我收到这些错误:

/usr/local/apr/build-1/libtool --silent --mode=link gcc -std=gnu99  -pthread  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -g -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED -L/usr/local/ssl/lib -lssl -lcrypto -ldl -luuid -lrt -lcrypt -lpthread -pie \
                 -o ab  ab.lo        /usr/local/apr/lib/libaprutil-1.la -lexpat /usr/local/apr/lib/libapr-1.la -luuid -lrt -lcrypt -lpthread -lm
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: /usr/local/ssl/lib/libssl.a(s2_clnt.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libssl.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [ab] Error 1
make[2]: Leaving directory `/usr/src/httpd-2.4.16/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/httpd-2.4.16/support'
make: *** [all-recursive] Error 1

我在 config.log 中收到以下错误

133  conftest.c:9:28: error: ac_nonexistent.h: No such file or directory

147  conftest.c:59: error: expected ';', ',' or ')' before 'text'

148-157
conftest.c: In function 'main':
conftest.c:111: warning: implicit declaration of function 'test_restrict'
conftest.c:113: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'newvar'
conftest.c:113: error: 'newvar' undeclared (first use in this function)
conftest.c:113: error: (Each undeclared identifier is reported only once
conftest.c:113: error: for each function it appears in.)
conftest.c:123: error: 'for' loop initial declaration used outside C99 mode
configure:6017: $? = 1
configure: failed program was:
| /* confdefs.h */


380/438  conftest.c:52:26: error: minix/config.h: No such file or directory

535/607  conftest.c:66:27: error: sys/processor.h: No such file or directory

658/731  conftest.c:67:21: error: sys/sdt.h: No such file or directory

773/846  conftest.c:67:25: error: sys/loadavg.h: No such file or directory

1490/1588  conftest.c:92:21: error: bstring.h: No such file or directory

答案1

好吧,恭喜你完成了自定义编译!让我想起了过去的美好时光!

话虽如此,这似乎是关键错误:

/usr/local/ssl/lib/libssl.a: could not read symbols: Bad value

根据我的经验,这是因为静态库是 32 位,而 make 的要求是 64 位。由于它是 SSL 项目,因此似乎一切都源于 OpenSSL 1.0.1g 本身。

看着OpenSSL 官方网站上的编译说明显示不同系统存在各种配置,可以通过./configure从源代码运行此命令来查看;从这里下载

./configure LIST

我得到的输出是:

BC-32
BS2000-OSD
BSD-generic32
BSD-generic64
BSD-ia64
BSD-sparc64
BSD-sparcv8
BSD-x86
BSD-x86-elf
BSD-x86_64
Cygwin
Cygwin-pre1.3
DJGPP
MPE/iX-gcc
OS2-EMX
OS390-Unix
QNX6
QNX6-i386
ReliantUNIX
SINIX
SINIX-N
UWIN
VC-CE
VC-WIN32
VC-WIN64A
VC-WIN64I
aix-cc
aix-gcc
aix3-cc
aix64-cc
aix64-gcc
android
android-armv7
android-x86
aux3-gcc
beos-x86-bone
beos-x86-r5
bsdi-elf-gcc
cc
cray-j90
cray-t3e
darwin-i386-cc
darwin-ppc-cc
darwin64-ppc-cc
darwin64-x86_64-cc
debug
debug-BSD-x86-elf
debug-Cygwin
debug-VC-WIN32
debug-VC-WIN64A
debug-VC-WIN64I
debug-ben
debug-ben-darwin64
debug-ben-debug
debug-ben-debug-64
debug-ben-macos
debug-ben-macos-gcc46
debug-ben-no-opt
debug-ben-openbsd
debug-ben-openbsd-debug
debug-ben-strict
debug-bodo
debug-darwin-i386-cc
debug-darwin-ppc-cc
debug-geoff32
debug-geoff64
debug-levitte-linux-elf
debug-levitte-linux-elf-extreme
debug-levitte-linux-noasm
debug-levitte-linux-noasm-extreme
debug-linux-elf
debug-linux-elf-noefence
debug-linux-generic32
debug-linux-generic64
debug-linux-ia32-aes
debug-linux-pentium
debug-linux-ppro
debug-linux-x86_64
debug-rse
debug-solaris-sparcv8-cc
debug-solaris-sparcv8-gcc
debug-solaris-sparcv9-cc
debug-solaris-sparcv9-gcc
debug-steve-opt
debug-steve32
debug-steve64
debug-ulf
debug-vos-gcc
dgux-R3-gcc
dgux-R4-gcc
dgux-R4-x86-gcc
dist
gcc
hpux-cc
hpux-gcc
hpux-ia64-cc
hpux-ia64-gcc
hpux-parisc-cc
hpux-parisc-cc-o4
hpux-parisc-gcc
hpux-parisc1_1-cc
hpux-parisc1_1-gcc
hpux-parisc2-cc
hpux-parisc2-gcc
hpux64-ia64-cc
hpux64-ia64-gcc
hpux64-parisc2-cc
hpux64-parisc2-gcc
hurd-x86
iphoneos-cross
irix-cc
irix-gcc
irix-mips3-cc
irix-mips3-gcc
irix64-mips4-cc
irix64-mips4-gcc
linux-alpha+bwx-ccc
linux-alpha+bwx-gcc
linux-alpha-ccc
linux-alpha-gcc
linux-aout
linux-armv4
linux-elf
linux-generic32
linux-generic64
linux-ia32-icc
linux-ia64
linux-ia64-ecc
linux-ia64-icc
linux-ppc
linux-ppc64
linux-sparcv8
linux-sparcv9
linux-x86_64
linux32-s390x
linux64-s390x
linux64-sparcv9
mingw
mingw64
ncr-scde
netware-clib
netware-clib-bsdsock
netware-clib-bsdsock-gcc
netware-clib-gcc
netware-libc
netware-libc-bsdsock
netware-libc-bsdsock-gcc
netware-libc-gcc
newsos4-gcc
nextstep
nextstep3.3
osf1-alpha-cc
osf1-alpha-gcc
purify
qnx4
rhapsody-ppc-cc
sco5-cc
sco5-gcc
solaris-sparcv7-cc
solaris-sparcv7-gcc
solaris-sparcv8-cc
solaris-sparcv8-gcc
solaris-sparcv9-cc
solaris-sparcv9-gcc
solaris-x86-cc
solaris-x86-gcc
solaris64-sparcv9-cc
solaris64-sparcv9-gcc
solaris64-x86_64-cc
solaris64-x86_64-gcc
sunos-gcc
tandem-c89
tru64-alpha-cc
uClinux-dist
uClinux-dist64
ultrix-cc
ultrix-gcc
unixware-2.0
unixware-2.1
unixware-7
unixware-7-gcc
vos-gcc
vxworks-mips
vxworks-ppc405
vxworks-ppc60x
vxworks-ppc750
vxworks-ppc750-debug
vxworks-ppc860
vxworks-ppcgen
vxworks-simlinux

我没有看到任何明确类似于 SUSE Linux Enterprise Server 11 的东西,但我会假设该./configure过程可能编译了一个 32 位版本?我猜想也许您的./configureOpenSSL 命令应该明确说明您希望为哪种体系结构进行编译?

例如以下命令:

./configure linux-generic64

甚至添加您以前使用过的选项,如下所示:

./configure linux-generic64 --prefix=/usr --openssldir=/usr/local/openssl enable-tlsext no-shared no-zlib -fPIC no-gost

然后将其滚动makemake install再次进行处理。

但我的直觉告诉我,这一切都取决于 32 位系统上的某些东西是否会破坏 64 位系统上的编译。

相关内容