I am working on a few new boxes I just bought for the rack – they’re 64 bit dual Xeon machines – fast, strong, delightful. But when I went to build Apache I had trouble. My personal method is to create configure scripts that call configure with the options that want – and I name this file configure.p, so that no matter how long it’s been since I’ve worked on a machine, I can come back and see how I configured (that) application. My standard Apache config looks like this:
./configure \
--enable-rewrite \
--enable-ssl \
--enable-proxy \
--enable-so
It configured without complaint, but when I went to make, I received this error and termination:
/usr/lib/libexpat.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[3]: *** [libaprutil-1.la] Error 1
make[3]: Leaving directory `/home/basel/temp/httpd-2.2.0/srclib/apr-util'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/basel/temp/httpd-2.2.0/srclib/apr-util'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/basel/temp/httpd-2.2.0/srclib'
make: *** [all-recursive] Error 1
After a big of searching, it turns out that Apache does not like to be compiled with 64 bit libraries by default. In addition to calling them out, you need to patch a bug in the configure script. Below is all the steps you need.
First off, we’ll assume that you are ready to compile apache 2. You have a directory something like /usr/local/installs/httpd-2.2.3 where your compiling from. Step into the srclib directory. Copy the following code, and paste it into a new file in the srclib directory called patch64:
(You can also get it directly from the apache foundation bug fixes here:
http://issues.apache.org/bugzilla/attachment.cgi?id=16166diff -rNu --exclude=.svn apr-util/build.orig/apu-conf.m4 apr-util/build/apu-conf.m4
--- apr-util/build.orig/apu-conf.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/apu-conf.m4 2005-08-23 16:10:23.000000000 +0200
@@ -20,6 +20,17 @@
dnl
dnl
+dnl enable preference of lib64 instead of lib
+dnl
+AC_ARG_ENABLE(lib64,
+AC_HELP_STRING([--enable-lib64],[prefer lib64 over lib [[default=no]]]),
+[case $enableval in
+yes|no) ;;
+*) AC_MSG_ERROR([bad value $enableval for --enable-lib64, need yes or no]) ;;
+esac],
+[enable_lib64=no])
+
+dnl
dnl APU_FIND_APR: figure out where APR is located
dnl
AC_DEFUN([APU_FIND_APR], [
@@ -64,6 +75,14 @@
expat_libs="-lexpat"
expat_libtool="$1/lib/libexpat.la"
elif test -r "$1/include/expat.h" -a \
+ -r "$1/lib64/libexpat.la" -a \
+ "$enable_lib64" = "yes" ; then
+ dnl Expat 1.95.* installation on certain 64-bit platforms (with libtool)
+ expat_include_dir="$1/include"
+ expat_ldflags="-L$1/lib64"
+ expat_libs="-lexpat"
+ expat_libtool="$1/lib64/libexpat.la"
+ elif test -r "$1/include/expat.h" -a \
-r "$1/lib/libexpat.la"; then
dnl Expat 1.95.* installation (with libtool)
expat_include_dir="$1/include"
diff -rNu --exclude=.svn apr-util/build.orig/apu-iconv.m4 apr-util/build/apu-iconv.m4
--- apr-util/build.orig/apu-iconv.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/apu-iconv.m4 2005-08-23 19:06:27.000000000 +0200
@@ -39,7 +39,11 @@
[ apu_iconv_dir="$withval"
if test "$apu_iconv_dir" != "yes"; then
APR_ADDTO(CPPFLAGS,[-I$apu_iconv_dir/include])
- APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib64])
+ else
+ APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib])
+ fi
fi
if test -f "$apu_iconv_dir/include/api_version.h"; then
have_apr_iconv="1"
@@ -74,9 +78,14 @@
fi
fi
APR_REMOVEFROM(CPPFLAGS,[-I$apu_iconv_dir/include])
- APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib])
APR_ADDTO(APRUTIL_INCLUDES,[-I$apu_iconv_dir/include])
- APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib64])
+ APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib64])
+ else
+ APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib])
+ APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib])
+ fi
fi
if test "$have_iconv" = "1"; then
diff -rNu --exclude=.svn apr-util/build.orig/dbd.m4 apr-util/build/dbd.m4
--- apr-util/build.orig/dbd.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/dbd.m4 2005-08-23 19:03:12.000000000 +0200
@@ -40,19 +40,31 @@
apu_have_pgsql=0
else
CPPFLAGS="-I$withval/include"
- LIBS="-L$withval/lib "
+ if test "$enable_lib64" = "yes" ; then
+ LIBS="-L$withval/lib64 "
+ else
+ LIBS="-L$withval/lib "
+ fi
AC_MSG_NOTICE(checking for pgsql in $withval)
AC_CHECK_HEADER(libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
if test "$apu_have_pgsql" != "0"; then
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ fi
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
fi
if test "$apu_have_pgsql" != "1"; then
AC_CHECK_HEADER(postgresql/libpq-fe.h, AC_CHECK_LIB(pq, PQsendQueryPrepared, [apu_have_pgsql=1]))
if test "$apu_have_pgsql" != "0"; then
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/postgresql])
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ fi
fi
fi
fi
@@ -88,12 +100,36 @@
apu_have_mysql=0
else
CPPFLAGS="-I$withval/include"
- LIBS="-L$withval/lib "
+ if test "$enable_lib64" = "yes" ; then
+ if test -d $withval/lib64/mysql ; then
+ LIBS="-L$withval/lib64/mysql "
+ else
+ LIBS="-L$withval/lib64 "
+ fi
+ else
+ if test -d $withval/lib/mysql ; then
+ LIBS="-L$withval/lib/mysql "
+ else
+ LIBS="-L$withval/lib "
+ fi
+ fi
AC_MSG_NOTICE(checking for mysql in $withval)
AC_CHECK_HEADER(mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
if test "$apu_have_mysql" != "0"; then
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ if test "$enable_lib64" = "yes" ; then
+ if test -d $withval/lib64/mysql ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64/mysql])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+ fi
+ else
+ if test -d $withval/lib64/mysql ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib/mysql])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ fi
+ fi
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
fi
@@ -101,7 +137,19 @@
AC_CHECK_HEADER(mysql/mysql.h, AC_CHECK_LIB(mysqlclient_r, mysql_init, [apu_have_mysql=1]))
if test "$apu_have_mysql" != "0"; then
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include/mysql])
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ if test "$enable_lib64" = "yes" ; then
+ if test -d $withval/lib64/mysql ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64/mysql])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+ fi
+ else
+ if test -d $withval/lib64/mysql ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib/mysql])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ fi
+ fi
fi
fi
fi
@@ -133,12 +181,20 @@
apu_have_sqlite3=0
else
CPPFLAGS="-I$withval/include"
- LIBS="-L$withval/lib "
+ if test "$enable_lib64" = "yes" ; then
+ LIBS="-L$withval/lib64 "
+ else
+ LIBS="-L$withval/lib "
+ fi
AC_MSG_NOTICE(checking for sqlite3 in $withval)
AC_CHECK_HEADER(sqlite3.h, AC_CHECK_LIB(sqlite3, sqlite3_open, [apu_have_sqlite3=1]))
if test "$apu_have_sqlite3" != "0"; then
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ fi
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
fi
fi
@@ -170,12 +226,19 @@
apu_have_sqlite2=0
else
CPPFLAGS="-I$withval/include"
- LIBS="-L$withval/lib "
-
+ if test "$enable_lib64" = "yes" ; then
+ LIBS="-L$withval/lib64 "
+ else
+ LIBS="-L$withval/lib "
+ fi
AC_MSG_NOTICE(checking for sqlite2 in $withval)
AC_CHECK_HEADER(sqlite.h, AC_CHECK_LIB(sqlite, sqlite_open, [apu_have_sqlite2=1]))
if test "$apu_have_sqlite2" != "0"; then
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ fi
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
fi
fi
diff -rNu --exclude=.svn apr-util/build.orig/dbm.m4 apr-util/build/dbm.m4
--- apr-util/build.orig/dbm.m4 2005-08-23 19:12:14.000000000 +0200
+++ apr-util/build/dbm.m4 2005-08-23 18:58:55.000000000 +0200
@@ -87,7 +87,12 @@
;;
* )
if test -d $bdb_place; then
- LDFLAGS="$LDFLAGS -L$bdb_place/lib"
+ if test "$enable_lib64" = "yes" ; then
+ LDFLAGS="$LDFLAGS -L$bdb_place/lib64"
+echo "$LDFLAGS"
+ else
+ LDFLAGS="$LDFLAGS -L$bdb_place/lib"
+ fi
CPPFLAGS="$CPPFLAGS -I$bdb_place/include"
else
AC_MSG_CHECKING([for Berkeley DB $bdb_version in $bdb_place])
@@ -183,7 +188,11 @@
;;
*)
APR_ADDTO(APRUTIL_INCLUDES, [-I$found/include])
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib64])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$found/lib])
+ fi
apu_db_header=$bdb_header
apu_db_lib=$bdb_libname
apu_have_db=1
@@ -589,12 +598,20 @@
apu_have_gdbm=0
else
CPPFLAGS="-I$withval/include"
- LIBS="-L$withval/lib "
+ if test "$enable_lib64" = "yes" ; then
+ LIBS="-L$withval/lib64 "
+ else
+ LIBS="-L$withval/lib "
+ fi
AC_MSG_CHECKING(checking for gdbm in $withval)
AC_CHECK_HEADER(gdbm.h, AC_CHECK_LIB(gdbm, gdbm_open, [apu_have_gdbm=1]))
if test "$apu_have_gdbm" != "0"; then
- APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ if test "$enable_lib64" = "yes" ; then
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib64])
+ else
+ APR_ADDTO(APRUTIL_LDFLAGS, [-L$withval/lib])
+ fi
APR_ADDTO(APRUTIL_INCLUDES, [-I$withval/include])
fi
fi
@@ -629,7 +646,11 @@
;;
*)
NDBM_INC="-I$withval/include"
- NDBM_LDFLAGS="-L$withval/lib"
+ if test "$enable_lib64" = "yes" ; then
+ NDBM_LDFLAGS="-L$withval/lib64"
+ else
+ NDBM_LDFLAGS="-L$withval/lib"
+ fi
AC_MSG_CHECKING(checking for ndbm includes in $withval)
;;
esac
So at this point, you should have a file named patch64 in the directory /usr/local/installs/httpd-2.2.3/srclib. Of course, your directory structure might be different.
To execute the patch, enter this command:
patch –p0 < ./patch64
This will patch up the appropriate configuration files. Then you’ll need to rebuild the configuration. So delete the file [yourInstallDir]/srclib/apr-util/configure as well as the file [youInstallDir]/configure.
Then we’ll need to rebuild the configure scripts, so the from the root of the installation directory, do this: ./buildconf
That will rebuild everything necessary to configure for Apache.
Now we need to change our configuration file. My configure.p file now looks like this:
./configure \
--enable-lib64 \
--libdir=/usr/lib64 \
--enable-rewrite \
--enable-ssl \
--enable-proxy \
--enable-so
… this will have to assume that your lib64 is in /usr/lib64, which is the default for Fedora Core 6.
Now configure, make and make install and you’re good to go!