dcmtk 3.5.4 with GCC 3.3 on Mac OS X

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
bkuemmer
Posts: 21
Joined: Wed, 2005-05-04, 12:49
Location: Bremen, Germany

dcmtk 3.5.4 with GCC 3.3 on Mac OS X

#1 Post by bkuemmer »

Hello there,

the new dcmtk 3.5.4 compiles without any problems on Mac OS X using GCC 4.0. The previous dcmtk 3.5.3 compiled using GCC 3.3.

When I try to compile 3.5.4 with GCC 3.3 instead instead of GCC 4.0, I get the following error:

Code: Select all

g++-3.3 -DHAVE_CONFIG_H  -DNDEBUG  -c -I. -I. -I../include -I../../config/include   \
        -I/sw/include -O -I/sw/include/libxml2 -I/sw/include -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L  ofthread.cc
ofthread.cc: In member function `int OFThread::start()':
ofthread.cc:151: error: invalid static_cast from type `_opaque_pthread_t*' to
   type `long unsigned int'
ofthread.cc: In member function `int OFThread::join()':
ofthread.cc:171: error: invalid static_cast from type `long unsigned int' to
   type `_opaque_pthread_t*'
ofthread.cc: In member function `bool OFThread::equal(long unsigned int)':
ofthread.cc:204: error: invalid static_cast from type `long unsigned int' to
   type `_opaque_pthread_t*'
ofthread.cc:204: error: invalid static_cast from type `long unsigned int' to
   type `_opaque_pthread_t*'
ofthread.cc: In static member function `static long unsigned int
   OFThread::self()':
ofthread.cc:234: error: invalid static_cast from type `_opaque_pthread_t*' to
   type `long unsigned int'
make[2]: *** [ofthread.o] Error 1
make[1]: *** [libsrc-all] Error 2
make: *** [ofstd-all] Error 2
### execution of make failed, exit code 2
Does anybody have an idea what the cause for this is?

Thanks
Bernd

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#2 Post by Marco Eichelberg »

This is not primarily a compiler version issue, but a general issue with pthread_t, which is a pointer type on some systems and an integer type on other systems. We have added some code in DCMTK 3.5.4 to make the code successfully compile in both cases, but it seems that it does not work for your configuration. Make sure that configure uses the same compiler that you are using to compile the toolkit. If things still don't work, we'll have to update the code. Please report precise details about the compiler and OS version you are using.

bkuemmer
Posts: 21
Joined: Wed, 2005-05-04, 12:49
Location: Bremen, Germany

#3 Post by bkuemmer »

This is on Mac OS X 10.3.9, using gcc 3.3:

Code: Select all

% uname -a
Darwin gandalf 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC  Power Macintosh powerpc

% ls -l `which c++`
lrwxr-xr-x  1 root  wheel  7  4 Aug  2004 /usr/bin/c++ -> g++-3.3

% g++-3.3 --version
g++-3.3 (GCC) 3.3 20030304 (Apple Computer, Inc. build 1671)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Here's part of the config.log

Code: Select all

configure:15335: checking if pthread_t is a pointer type (in pthread.h)
configure:15378: c++ -c -Wall   conftest.cc >&5
configure: In function `int main()':
configure:15372: warning: invalid conversion from `_opaque_pthread_t*' to `long
   unsigned int'
configure:15371: warning: unused variable `long unsigned int l'
configure:15381: $? = 0
configure:15384: test -s conftest.o
configure:15387: $? = 0
configure:15407: result: no
The same compiler (namely the c++) is used both for configure and make:

Code: Select all

c++     -DHAVE_CONFIG_H  -DNDEBUG  -c -I. -I. -I../include -I../../config/include   \
         -O -I/sw/include/libxml2 -I/sw/include -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall  ofthread.cc
ofthread.cc: In member function `int OFThread::start()':
ofthread.cc:151: error: invalid static_cast from type `_opaque_pthread_t*' to
   type `long unsigned int'
ofthread.cc: In member function `int OFThread::join()':
ofthread.cc:171: error: invalid static_cast from type `long unsigned int' to
   type `_opaque_pthread_t*'
ofthread.cc: In member function `bool OFThread::equal(long unsigned int)':
ofthread.cc:204: error: invalid static_cast from type `long unsigned int' to
   type `_opaque_pthread_t*'
ofthread.cc:204: error: invalid static_cast from type `long unsigned int' to
   type `_opaque_pthread_t*'
ofthread.cc: In static member function `static long unsigned int
   OFThread::self()':
ofthread.cc:234: error: invalid static_cast from type `_opaque_pthread_t*' to
   type `long unsigned int'
make[2]: *** [ofthread.o] Error 1
make[1]: *** [libsrc-all] Error 2
make: *** [ofstd-all] Error 2
Please let me know if I can provide anything else...

Cheers
Bernd

Michael Onken
DCMTK Developer
Posts: 2051
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

GCC on Mac OS X

#4 Post by Michael Onken »

Hi Bernd!

Just a note: I've tested DCMTK 3.5.4 on Mac OS X Tiger with gcc 4 (default). There you can compile the release without problems. Perhaps you're able to update your compiler to get DCMTK 3.5.4 working out of the box.

Best Regards,
Michael

bkuemmer
Posts: 21
Joined: Wed, 2005-05-04, 12:49
Location: Bremen, Germany

#5 Post by bkuemmer »

Thanks Michael... I don't have a problem using gcc4.0 on Tiger (Mac OS X 10.4), in fact, that's where I started: I am updating the dcmtk-Package for Fink <http://sourceforge.net/tracker/index.ph ... tid=414256>, and it is working without a problem on Tiger.

Since Fink is also running on Mac OS X 10.3, where the default is gcc3.3, I would like to build a package for this as well... Currently, the only way to build on 10.3 with gcc3.3 is by using "./configure --disable-threads"

Cheers
Bernd

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#6 Post by Marco Eichelberg »

Bernd,
the problem is caused by the fact that gcc 3.3 seems to accept the following code with a warning instead of an error:

Code: Select all

_opaque_pthread_t *p; 
unsigned long l = p;
This causes configure to believe that pthread_t is not a pointer type, but the static_cast subsequently used in the code fails with a compile error:

Code: Select all

_opaque_pthread_t *p; 
unsigned long l = static_cast<unsigned long>(p);
I will try to update the configure script to explicitly handle this case. This is not trivial because we also support older compilers that do not have static_cast<>.

bkuemmer
Posts: 21
Joined: Wed, 2005-05-04, 12:49
Location: Bremen, Germany

#7 Post by bkuemmer »

Thanks Marco...

I will try using the static_cast<...> as a Mac OS X-specific patch.

Cheers
Bernd

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest