some common problems building Apache 2 on AIX

apr_md5.c won't compile

Example message:
"apr_md5.c", line 753.2: 1506-205 (S) #error Configuration error! crypt_r() should have been selected!
make: 1254-004 The error code from the last command is 1.
This is a problem with Apache 2.0.46 that affects gcc builds on AIX. The work-around is to define _THREAD_SAFE like this:
CPPFLAGS=-D_THREAD_SAFE ./configure --other-options

sqrt unresolved

Example message:
ld: 0711-317 ERROR: Undefined symbol: .sqrt
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status
There are a couple of causes. The simple one is that /usr/lib/libm.a doesn't exist, in which case you need to install the right fileset, then rebuild Apache by doing "make distclean && ./configure --myoptions". The "make distclean" command is required to tell the configure process to ignore anything it figured out before the error occurred.

The more insidious problem is that your gcc installation is using an ld that can't handle AIX's /usr/lib/libm.a. To test that theory, try the following:

$ echo 'main(){printf("hello\n");}' > hello.c
$ gcc hello.c -lm
$ ./a.out
hello
Some people have gotten the following message:
collect2: /lib/libm.a: not a COFF file
If this simple test fails, your gcc is busted or is using the wrong ld (GNU ld?) or something. I have not encountered any such problems with IBM's build of gcc, which is available from the AIX toolbox for Linux applications . Any time a build tool such as the compiler is replaced or updated after running configure, make sure you run make distclean before trying it again.

DSOs won't load with Apache 2.0.45

To work-around a bug in that level of Apache, add --enable-so to your other configure options.

error in system header files when compiling with gcc

Here is an example:
        /bin/sh /tmp/httpd-2.0.45/srclib/apr/libtool --silent
        --mode=compile
gcc -g -O2   -DHAVE_CONFIG_H -U__STR__ -D_USE_IRS -D_THREAD_SAFE
        -I../
./include -I../../include/arch/unix -I../../include/arch/unix  -c
        dir.c &&
touch dir.lo
In file included from /usr/include/pthread.h:43,
                 from ../../include/apr_portable.h:85,
                 from dir.c:57:
/usr/include/time.h:230: warning: `struct sigevent' declared inside
parameter list
/usr/include/time.h:230: warning: its scope is only this definition or
declaration, which is probably not what you want.
In file included from ../../include/apr_portable.h:85,
                 from dir.c:57:
/usr/include/pthread.h:554: parse error before `*'
/usr/include/pthread.h:557: parse error before `*'
/usr/include/pthread.h:561: parse error before `*'
/usr/include/pthread.h:564: parse error before `*'
/usr/include/pthread.h:567: parse error before `*'
/usr/include/pthread.h:570: parse error before `*'
/usr/include/pthread.h:573: parse error before `*'
/usr/include/pthread.h:576: parse error before `*'
/usr/include/pthread.h:579: parse error before `*'
/usr/include/pthread.h:583: parse error before `*'
/usr/include/pthread.h:586: parse error before `*'
make: 1254-004 The error code from the last command is 1.
Here is another example:
/bin/sh /apache/httpd-2.0.47/srclib/apr/libtool --silent
--mode=compile gcc -g -O2   -DHAVE_CONFIG_H -U__STR__ -D_THREAD_SAFE
-D_USE_IRS   -I../include -I../include/arch/unix  -c apr_snprintf.c
&& touch apr_snprintf.lo
In file included from /usr/include/sys/pri.h:29,
                 from /usr/include/sys/sched.h:38,
                 from /usr/include/sched.h:52,
                 from /usr/include/pthread.h:43,
                 from ../include/apr_portable.h:85,
                 from apr_snprintf.c:65:
/usr/include/sys/proc.h:203: parse error before "crid_t"
/usr/include/sys/proc.h:212: parse error before "p_class"
/usr/include/sys/proc.h:355: parse error before '}' token
make: The error code from the last command is 1.

gcc actually uses a copy of some system header files. If gcc is built for a relatively old AIX, it can end up using backlevel files from its copies and uplevel files from /usr/include and compile can fail depending on what sort of enhancements were made to the system since gcc was built. If you hit problems like this, your gcc build may be out of date.

I have not encountered any such problems with IBM's build of gcc when used on AIX 4.3.3 and AIX 5.1, which is available from the AIX toolbox for Linux applications . Unfortunately, I have seen such problems with IBM's build of gcc on AIX 5.2. (Maybe those were resolved after August/2003?)

Any time a build tool such as the compiler is replaced or updated after running configure, make sure you run make distclean before trying it again.

"prefork.c", line 686.36: 1506-045 (S) Undeclared identifier BINDPROCESS.

The problem here is that /usr/include/sys/processor.h is missing. Make sure that fileset bos.adt.include is properly installed:

$ lslpp -w /usr/include/sys/processor.h
  File                                        Fileset
  Type
  ----------------------------------------------------------------------------
  /usr/include/sys/processor.h                bos.adt.include  File