[Insight-users] Compilation problems with cygwin (solved)

Stéphane Wasserhardt stephane.wasserhardt at magellium.fr
Thu Aug 4 10:52:46 EDT 2005


Just for the few newbies like me who could have the same compilation problem
:
The solution is easy to find if you take a look at the source code.

In {insight source dir}\code\common\itkMutexLock.h are written the following
lines :

#ifdef ITK_USE_SPROC
typedef abilock_t MutexType;
#endif

#ifdef ITK_USE_PTHREADS
typedef pthread_mutex_t MutexType;
#endif

#ifdef ITK_USE_WIN32_THREADS
typedef HANDLE MutexType;
#endif

#ifndef ITK_USE_SPROC
#ifndef ITK_USE_PTHREADS
#ifndef ITK_USE_WIN32_THREADS
typedef int MutexType;
#endif
#endif
#endif

And the build error tells that "MutexType" is declared multiple times. The
reason is that both ITK_USE_PTHREADS and ITK_USE_WIN32_THREADS were defined.
Then the problem is just to find where these variables were defined in order
to "undefine" ITK_USE_PTHREADS. A little grep search helped me to find that
it was CMake which had set this variables by mean of CMAKE_USE_PTHREAD and
CMAKE_USE_WIN32_THREADS (and CMAKE_USE_SPROC).
So the problem was in fact that CMake detected that both pthreads and win32
threads were available on the system, and activated both by default...
I tried to switch off pthreads, but it didn't work so easily : another
compilation error appeared when trying to compile code using threads, in
ItkMultiThreader.cxx (the function "_beginthreadex" was not declared...)
So I switched off win32 thread and tried using pthreads instead. And it
worked !!




More information about the Insight-users mailing list