Bug #488

GammaLib unit test compilation fails on Mac OS 10.6 with gcc 4.3 & 4.4 compilers

Added by Knödlseder Jürgen over 11 years ago. Updated over 11 years ago.

Status:ClosedStart date:09/16/2012
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:-
Duration:

Description

Using the MacPorts gcc 4.3 or 4.4 compiler, the compilation of the test suite fails on Mac OS 10.6.

To compile with MacPorts gcc 4.4 compiler, I used

$ export CXX=g++-mp-4.4
$ export CC=gcc-mp-4.4
$ ./configure --disable-python-binding
$ make
$ make check

This led to the following error:

Making check in test
make  test_GSupport test_GVector test_GMatrix test_GSymMatrix test_GSparseMatrix test_GNumerics test_GFits test_GXml test_GApplication test_GModel test_GSky test_GOptimizer test_GObservation test_MWL test_CTA test_LAT
make[2]: *** No rule to make target `test_GSupport-test_GSupport.', needed by `test_GSupport'.  Stop.
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1


Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen over 11 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

It turned our that the OBJEXT variable was not set to the object extension in the Makefile. The variable reads

OBJEXT =

Setting

OBJEXT = o

made the compilation work.

It remains to be understood why the OBJEXT variable is not set correctly.

#2 Updated by Knödlseder Jürgen over 11 years ago

Note that after fixing the above mentioned problem, another problem occurred. Compilation of the test_GObservation executable failed with the following message:

ld: duplicate symbol _gomp_thread_attr in ../src/.libs/libgamma.a(GTestSuite.o) and test_GObservation-test_GObservation.o for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [test_GObservation] Error 1
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1

This is due to the OpenMP section in test_GObservation.cpp:

#ifdef _OPENMP
#include <omp.h>
#ifdef __APPLE__ 
#ifdef __MACH__
#include <pthread.h>
pthread_attr_t gomp_thread_attr;
#endif
#endif
#endif

Note that a similar section exists in GTestSuite.cpp. I therefore deleted the corresponding section in test_GObservation.cpp.

#3 Updated by Knödlseder Jürgen over 11 years ago

  • Status changed from In Progress to Feedback
  • Assigned To set to Knödlseder Jürgen
  • % Done changed from 10 to 100

The OBJEXT problem was also solved. The missing object extension was due to the Mac OS X clang kluge that has been introduced to make clang preceeding the gcc compiler in case that the system is Mac OS X >= 10.7.

#4 Updated by Knödlseder Jürgen over 11 years ago

The problem was a little bit more complex, as the Apple gcc compiler needs both inclusions, while the MacPorts gcc compiler did not like this.

I added a specific test to the configure script that checks the type of code that is needed. This sets then the compiler definition HAVE_OPENMP_DARWIN_KLUGE so that the respective code section can be written as:

#ifdef _OPENMP
#include <omp.h>
#ifdef HAVE_OPENMP_DARWIN_KLUGE
#include <pthread.h>
pthread_attr_t gomp_thread_attr;
#endif
#endif

Now the global variable gomp_thread_attr is only defined when it’s really needed.

#5 Updated by Knödlseder Jürgen over 11 years ago

  • Status changed from Feedback to Closed

Also available in: Atom PDF