Good to the last bit.

A Million Times

Stunning clock of clocks.

Autoconf and GNU compatible malloc / realloc

Occasionally I’ll attempt to run autoconf on a project and find that it tells me I do not have a GNU compatible malloc / realloc. Later, make fails claiming something about malloc or realloc not being defined. I always find this really confusing and forget the solution, so I’m posting it here for myself (and anyone else who runs across this problem).

First, it helps to understand what this business of GNU compatible malloc / realloc is all about. It’s very simple: if the C library you’re using returns non-NULL for malloc(0), it’s GNU compatible; otherwise, it isn’t. I’m on Linux using glibc, so I always find it rather unsettling when autoconf tells me that GNU libc doesn’t have a GNU compatible malloc or realloc. Contrary to my (and maybe your) initial impulse, this error actually has nothing to do with include paths or linker paths or the use of some rogue C library that I forgot I installed.

Here’s how it breaks down. In order to test whether you have a GNU compatible malloc / realloc, autoconf actually attempts to compile a short test program containing the call to malloc(0). If the compilation fails for any reason, autoconf assumes you don’t have the GNU compatible version of the function and sets some flags to indicate such — you’re then supposed to define your own replacements for these functions (which, of course, you didn’t).

The problem is that the compilation of the test program rarely (in my experience) fails due to an actual absense of malloc or realloc; rather it fails due to some bogus or missing command line arguments passed to the compiler. For example, if I do gcc test.c -l somerandomjunk, the command will fail because the linker can’t find the somerandomjunk library, not because anything in test.c is undefined or GNU incompatible. gcc will actually tell you exactly that reason when it fails, but autoconf doesn’t parse this error message or show it to you; it just assumes there’s no malloc / realloc.

So here’s what to do: go into the config.log generated by autoconf and find the actual place where it attempted and failed to compile the malloc / realloc test program. Nearby, you’ll find the actual gcc (or g++) command that it attempted and (finally) the actual error message you need. Fix it (maybe by setting some variables in configure.ac), and your GNU compatible malloc / realloc will magically be restored.

R U OK Day

R U OK Day

It’s R U OK Day. Connect with someone you know.

Zend Captcha Figlet: No Output

Quick tip: If you’re trying to use Zend_Captcha_Figlet and not getting any output (or errors), you probably need to enable the bcmath extension in your php.ini.

 __   __     ___     __   __  
 \ \\/ //   / _ \\   \ \\/ // 
  \ ` //   / //\ \\   \ ` //  
   | ||   |  ___  ||   | ||   
   |_||   |_||  |_||   |_||   
   `-`'   `-`   `-`    `-`'   

Warning Labels for Shoddy Journalism

Warning Labels for Shoddy Journalism

Tom Scott created these brilliant warning labels to flag the more questionable articles in his daily newspaper.