Configure problem building SDL apps (atexit undefined)

Attempting to build SDL apps (e.g those in the test directory of the
SDL-1.2.1 package) fails as follows. SDL 1.2.1 has just been installed.

Running configure produces the following:

creating cache ./config.cache
checking host system type… i686-pc-linux-gnu
checking target system type… i686-pc-linux-gnu
checking for a BSD compatible install… /bin/install -c
checking whether build environment is sane… yes
checking whether make sets ${MAKE}… yes
checking for working aclocal… found
checking for working autoconf… found
checking for working automake… found
checking for working autoheader… found
checking for working makeinfo… found
checking for gcc… gcc
checking whether the C compiler (gcc -s -O3 -march=i686 -mcpu=i686
-fomit-frame-pointer -Wall -malign-functions=4 -funroll-loops -malign-double
-fschedule-insns2 -mwide-multiply
) works… yes
checking whether the C compiler (gcc -s -O3 -march=i686 -mcpu=i686
-fomit-frame-pointer -Wall -malign-functions=4 -funroll-loops -malign-double
-fschedule-insns2 -mwide-multiply
) is a cross-compiler… no
checking whether we are using GNU C… yes
checking whether gcc accepts -g… yes
checking for working const… yes
checking how to run the C preprocessor… gcc -E
checking for X… libraries /usr/X11R6/lib, headers /usr/X11R6/include
checking for dnet_ntoa in -ldnet… no
checking for dnet_ntoa in -ldnet_stub… no
checking for gethostbyname… yes
checking for connect… yes
checking for remove… yes
checking for shmat… yes
checking for IceConnectionNumber in -lICE… yes
checking for sdl-config… /usr/local/bin/sdl-config
checking for SDL - version >= 1.2.0… no
*** Could not run SDL test program, checking why…
*** The test program failed to compile or link. See the file config.log for
*** exact error that occured. This usually means SDL was incorrectly installed
*** or that you have moved SDL since it was installed. In the latter case, you
*** may want to edit the sdl-config script: /usr/local/bin/sdl-config
configure: error: *** SDL version 1.2.0 not found!

The final entry in config.log is the following:

configure:2293: gcc -o conftest -s -O3 -march=i686 -mcpu=i686
-fomit-frame-pointer -Wall -malign-functions=4 -funroll-loops -malign-double
-fschedule-insns2 -mwide-multiply -I/
usr/X11R6/include -I/usr/local/include -I/usr/local/include/SDL -D_REENTRANT
conftest.c -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -lpthread 1>&5
/usr/X11R6/lib/ undefined reference to `atexit’
collect2: ld returned 1 exit status
configure: failed program was:
#line 2278 “configure”
#include “confdefs.h”

#include <stdio.h>
#include “SDL.h”

int main(int argc, char *argv[])
{ return 0; }
#undef main
#define main K_and_R_C_main

int main() {
return 0;
; return 0; }

My system is a linuxfromscratch build, using gcc 2.95.3 and glibc2.2.3.

Simon Geard.