Why afl-g++ can’t compile ImageMagick?

  american-fuzzy-lop, c++, fuzzing, imagemagick

I’m trying to experiment some fuzz testing with the tool afl (link). I downloaded the source code of ImageMagick as described in the docs, but when I try to run ./configure with the afl compiler I get an error:

$ CC=/usr/local/bin/afl-gcc CXX=/usr/local/bin/afl-g++ ./configure --disable-shared
checking whether we are using the GNU C++ compiler... no
checking whether /usr/local/bin/afl-g++ accepts -g... no
checking dependency style of /usr/local/bin/afl-g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/home/ubuntu/ImageMagick-7.0.10':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details

FYI config.log is 3000 lines long

If I try to use the default c++ compiler everything seems fine:

$ CC=/usr/local/bin/afl-gcc ./configure --disable-shared #this works

How can I make the compiler run?

Source: Windows Questions C++