Oct 4, 2011

Getting cppunit 1.12.1 to compile on OpenIndiana 151a

The cppunit 1.12.1 has some problems to be compiled on Solaris or maybee even *nix with gcc.

First configure fails, regardless if sunstudio or gcc is used as compiler platform.
dirname has to many options

creating include/cppunit/config-auto.h - prefix CPPUNIT for config/config.h defines
dirname: extra operand `/ausl'
Try `dirname --help' for more information.
/* automatically generated config/ contrib/ doc/ examples/ include/ lib

The solution was found here. Replace all
/* automatically generated */
in the configure script.
After this the configure worked. 

But compiling cppunit was failing

 g++ -DHAVE_CONFIG_H -I. -I../../config -I../../include -I../../include -g -O2 -MT TestAssert.lo -MD -MP -MF .deps/TestAssert.Tpo -c TestAssert.cpp  -fPIC -DPIC -o .libs/TestAssert.o
In file included from TestAssert.cpp:2:0:
../../include/cppunit/portability/FloatingPoint.h: In function ‘int CppUnit::floatingPointIsFinite(double)’:
../../include/cppunit/portability/FloatingPoint.h:43:21: error: ‘finite’ was not declared in this scope
The solutions was in a forum entry for cppunit.

--- cppunit-1.12.1/include/cppunit/portability/FloatingPoint.h 
+++ cppunit-1.12.1/include/cppunit/portability/FloatingPoint.h 

@@ -3,6 +3,11 @@ 
#include <cppunit/Portability.h> 
#include <math.h> 
+#if defined(__sun) && !defined(CPPUNIT_HAVE_ISFINITE) && defined(CPPUNIT_HAVE_FINITE) 
+#include <ieeefp.h> 
+ // <math.h> is still needed for usage of fabs in TestAssert.cpp 
After this the compilation works.

I used the compiler commands from here  to compile with the SunStudio compiler.
I also had to insert the math.h after ieeefp.h because of unreferenced fabs