OSS-Fuzz: Build fuzz targets using C++ compiler

Otherwise, the targets will require libstdc++, the i386 version of which
is not available in the OSS-Fuzz runtime environment.  The OSS-Fuzz
build environment passes -stdlib:libc++ in the CXXFLAGS environment
variable in order to mitigate this issue, since the runtime environment
has the i386 version of libc++, but using that compiler flag requires
using the C++ compiler.
diff --git a/fuzz/CMakeLists.txt b/fuzz/CMakeLists.txt
index 6af371b..60ff5dc 100644
--- a/fuzz/CMakeLists.txt
+++ b/fuzz/CMakeLists.txt
@@ -16,6 +16,12 @@
 endif()
 message(STATUS "FUZZ_LIBRARY = ${FUZZ_LIBRARY}")
 
+enable_language(CXX)
+
+set(EFFECTIVE_CXX_FLAGS
+  "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
+message(STATUS "C++ Compiler flags = ${EFFECTIVE_CXX_FLAGS}")
+
 macro(add_fuzz_target target source_file)
   add_executable(${target}_fuzzer ${source_file})
   if(NOT ENABLE_SHARED)
@@ -29,8 +35,8 @@
 # NOTE: This target is named libjpeg_turbo_fuzzer instead of decompress_fuzzer
 # in order to preserve the corpora from Google's OSS-Fuzz target for
 # libjpeg-turbo, which this target replaces.
-add_fuzz_target(libjpeg_turbo decompress.c)
+add_fuzz_target(libjpeg_turbo decompress.cc)
 
-add_fuzz_target(decompress_yuv decompress_yuv.c)
+add_fuzz_target(decompress_yuv decompress_yuv.cc)
 
-add_fuzz_target(transform transform.c)
+add_fuzz_target(transform transform.cc)
diff --git a/fuzz/build.sh b/fuzz/build.sh
index cf8597b..8f48f45 100644
--- a/fuzz/build.sh
+++ b/fuzz/build.sh
@@ -4,7 +4,8 @@
 set -e
 
 cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \
-	-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \
+	-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" \
+	-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \
 	-DWITH_FUZZ=1 -DFUZZ_BINDIR=$OUT -DFUZZ_LIBRARY=$LIB_FUZZING_ENGINE
 make "-j$(nproc)" "--load-average=$(nproc)"
 make install
diff --git a/fuzz/decompress.c b/fuzz/decompress.cc
similarity index 97%
rename from fuzz/decompress.c
rename to fuzz/decompress.cc
index 48eb312..a751f6a 100644
--- a/fuzz/decompress.c
+++ b/fuzz/decompress.cc
@@ -34,7 +34,7 @@
 #define NUMPF  4
 
 
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
 {
   tjhandle handle = NULL;
   unsigned char *dstBuf = NULL;
diff --git a/fuzz/decompress_yuv.c b/fuzz/decompress_yuv.cc
similarity index 97%
rename from fuzz/decompress_yuv.c
rename to fuzz/decompress_yuv.cc
index ea9c6b8..b74723e 100644
--- a/fuzz/decompress_yuv.c
+++ b/fuzz/decompress_yuv.cc
@@ -34,7 +34,7 @@
 #define NUMPF  3
 
 
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
 {
   tjhandle handle = NULL;
   unsigned char *dstBuf = NULL, *yuvBuf = NULL;
diff --git a/fuzz/transform.c b/fuzz/transform.cc
similarity index 98%
rename from fuzz/transform.c
rename to fuzz/transform.cc
index 2890a40..2b0b250 100644
--- a/fuzz/transform.c
+++ b/fuzz/transform.cc
@@ -35,7 +35,7 @@
 #define NUMXFORMS  3
 
 
-int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
 {
   tjhandle handle = NULL;
   unsigned char *dstBufs[NUMXFORMS] = { NULL, NULL, NULL };