Saturday, October 24, 2009

compiling apg 6.0 on MacOS X 10.5.8

so mi amiga infinity asked me to report the following:

It looks like MacOS-X 10.5.8 doesn't like APG 6.0 for the following three reasons:
  1. it's a mac. it's a sullen little machine that likes to strike out randomly at people who love it.
  2. malloc.h is in a mildly non-standard place
  3. the version of autoconf that comes with it doesn't grok 'dist-lzma'
APG 6.0 is an ABNF Parser Generator from Coast to Coast Research that takes ABNF files and generates C and C++ files to make the creation of domain specific languages slightly easier. I'm not entirely certain, but my guess is she's working on a tool to manipulate LLIDL files; there was some chatter recently about an upcoming draft of LLSD and it's ABNF.

Here's what i did to replicate the problem and the solution:

  1. Download APG 6.0 by going to the page at http://www.coasttocoastresearch.com/apg-6.0/download-60.php , reading the license, and clicking on your favorite flavor of compressed archive file.
  2. Untar the file in your favorite place for parser generators on your hard drive.
  3. Change directories to that location and enter the command:
    ./configure ; make
  4. Witness the madness that is Autoconf:
    ./../src/CommandLine.c:31:20: error: malloc.h: No such file or directory.
  5. Modify line 6 of the file to remove the reference to dist-lzma, so it reads:
    AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-zip dist-bzip2])
  6. Modify the configure.ac file so that line 8 reads:
    CFLAGS="$CFLAGS"
  7. Then issue the commands:
    autoconf
    automake
    export CFLAGS=-I/usr/include/malloc
    ./configure
    make
  8. and viola! you're done. if you're brave, you can also install the package with the command:
    sudo make install
And that's it, enjoy!

2 comments:

  1. APG goes somewhat pear-shaped on Snow Leopard. There is an obvious compile-time issue in ApgLib/src/Apg.h with the UASSERT macro casting its first argument to an int (fails with pointers), but the broader issue might be that APG has more extensive 64-bit problems.

    This is a snippet from the Coast to Coast web site:
    03/01/09: APG will not run on Linux x86_64 platforms. Among possible other problems, it assumes that both sizeof(ulong) = 4 and sizeof(void*) = sizeof(ulong). Thanks to user TJ for pointing out the work-around: "However, if you add "-m32" to all compiler/linker calls and install the relevant 32bit libraries and compilers you can get everything to run on a x86_64bit as well."

    I've played a little with -m32 to no avail. Builds but throws memory exceptions at runtime. Works on Linux, so I'm not trying too hard. If I find a solution I'll post it here.

    David H

    ReplyDelete
  2. Solution is to do *exactly* what user TJ pointed out in the comment on the Coast to Coast web site, i.e change step 7 in the original post to:

    autoconf
    automake
    export CFLAGS=-I/usr/include/malloc -m32
    export CPPFLAGS=-m32
    export LDFLAGS=-m32
    ./configure
    make

    It now builds and also runs the Samples.

    regards - David

    ReplyDelete