Tuesday, 27 November 2012

Building PHP

Most of yesterday and today I have just been trying to get PHP installed. I was getting a build error, but didn't know what was causing it. No-one else seemed to know either.

(The problem was that it was trying to load /lib/libgcrypt.la, which doesn't exist on my system. It did this even when I told it to look in the folder (not /lib/) where I had installed a copy of libgcrypt.

So I had to keep running configure followed by make, using a slightly different set of configure options each time, until I found the configure option that was causing the make to fail.

Eventually I found that PHP would build okay without --with-xsl=$HOME/apps/libxslt. Sure enough, if I check $HOME/apps/libxslt/lib/libexslt.la, I have the following line:

# Libraries that this one depends upon.

dependency_libs=' /lib/libgcrypt.la /home/djeyewater/apps/libxslt/lib/libxslt.la -L/home/djeyewater/apps/libxml2/lib /home/djeyewater/apps/libxml2/lib/libxml2.la -ldl -lz -lm'

My guess is that when I built libxslt, Ubuntu included /lib/libgcrypt.la. But in an update this file must have been removed.

While I was trying to figure out what was causing this error, I also came across another PHP build error:

libcurl.so: undefined reference to `ldap_parse_result@OPENLDAP_2.4_2'

Some research revealed that this is likely due to conflicting ldap libs. I rebuilt curl with the option --with-ldap-lib=$HOME/apps/openldap/lib, and this seemed to solve the issue.

The strange thing is though, that after configuring CURL, it said something like "with ldap (--enable-ldap / --with-ldap-lib / --with-lber-lib) no". It seems strange that:

  1. It said ldap was not enabled even though I did use the --with-ldap-lib option
  2. That the version of CURL I already had installed contained a reference to ldap, since I would not have configured it with ldap enabled.

I had problems building icu4c as well (needed for internationalization). When I tried to build the latest version (1.5) on Ubuntu, I got the following errors:

   gcc  ...  umutex.c
umutex.c:211:1: error: conflicting types for ‘umtx_lock_50’
umutex.h:208:1: note: previous declaration of ‘umtx_lock_50’ was here
umutex.c: In function ‘umtx_lock_50’:
umutex.c:223:9: warning: implicit declaration of function ‘umtx_init’ [-Wimplicit-function-declaration]
umutex.c: At top level:
umutex.c:248:1: error: conflicting types for ‘umtx_unlock_50’
umutex.h:214:1: note: previous declaration of ‘umtx_unlock_50’ was here
umutex.c:314:1: warning: no previous prototype for ‘umtx_init’ [-Wmissing-prototypes]
umutex.c:314:1: warning: conflicting types for ‘umtx_init’ [enabled by default]
umutex.c:223:9: note: previous implicit declaration of ‘umtx_init’ was here
umutex.c:359:1: warning: no previous prototype for ‘umtx_destroy’ [-Wmissing-prototypes]
*** Failed compilation command follows: ----------------------------------------------------------
gcc -D_REENTRANT -I. -DDEFAULT_ICU_PLUGINS="/home/djeyewater/apps/icu4c-50.1/lib/icu"  -DU_ATTRIBUTE_DEPRECATED= -DU_COMMON_IMPLEMENTATION -O2 -Wall -std=c99 -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c -DPIC -fPIC -o umutex.o umutex.c
--- ( rebuild with "make VERBOSE=1 all" to show all parameters ) --------
make[1]: *** [umutex.o] Error 1
make[1]: Leaving directory `/home/djeyewater/tarballs/icu/source/common'
make: *** [all-recursive] Error 2

So I went back to, which I had previously built successfully (and rebuilt it okay just to check). But when I tried to install it on the webserver (which runs CentOS), I got a few errors about undefined references to __sync_fetch_and_add_4 and __sync_val_compare_and_swap_4, and the build failed.

After some research, and trying various different things, I found that you needed to add CFLAGS="-march=i486" to the configure line, then it would build okay.

The other thing I was doing yesterday and today (while waiting for PHP configures / builds to process) was writing and taking photos for an article for my photo tips website.

No comments: