 |
DICOM @ OFFIS Discussion Forum for OFFIS DICOM Tools
|
| View previous topic :: View next topic |
| Author |
Message |
wollet88
Joined: 28 Mar 2008 Posts: 9
|
Posted: Thu, 2009-04-09, 10:35 Post subject: Building DCMTK 3.5.4 on Mac OS X 10.5.6 as Universal Binary |
|
|
Dear DCMTK team,
I am trying to build OFFIS DCMTK 3.5.4 on my Intel-based MacBook Pro running Mac OS X 10.5.6. I am using gcc 4.0.1.
After running the "./configure" command, as suggested in another post on this Forum, I added the following switch to the CFLAGS and CXXFLAGS in the /config/Makefile.def: -D_DARWIN_C_SOURCE.
Then, I ran the "make all" and "make install" commands, and the overall build process completed correctly.
Finally, I wanted to modify the build process in order to build a "Universal Binary" version of OFFIS DCMTK 3.5.4.
Here is what I did. I edited the "/config/Makefile.def" and I added the following line:
ARCH = -arch ppc -arch i386 -arch ppc64 -arch x86_64
Then I ran the following commands:
make clean
make all
The build process seems to start in a correct way, and many object files seem to be built correctly. But, at a certain stage I get the following errors:
=====
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::SetReadlock()':
wldsfs.cc:769: error: cast from 'flock*' to 'int' loses precision
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::ReleaseReadlock()':
wldsfs.cc:824: error: cast from 'flock*' to 'int' loses precision
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::SetReadlock()':
wldsfs.cc:769: error: cast from 'flock*' to 'int' loses precision
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::ReleaseReadlock()':
wldsfs.cc:824: error: cast from 'flock*' to 'int' loses precision
lipo: can't figure out the architecture type of: /var/folders/qA/qAYVTAn-GQaM0hVV5zyqLE+++TI/-Tmp-//ccerp9r4.out
make[2]: *** [wldsfs.o] Error 1
make[1]: *** [libsrc-all] Error 2
make: *** [dcmwlm-all] Error 2
=====
The above errors seem to have to do with the fact that pointers become 64-bit values and casting to "int" (32-bit) may lead to a loss of precision.
Do you have suggestions on how I may solve this problem?
My final objective would be to create an "XCode project" for the OFFIS DCMTK 3.5.4, with appropriate settings to build it as a Universal Binary.
Any hint or suggestion would be greatly appreciated.
Best regards,
Marco. |
|
| Back to top |
|
 |
Marco Eichelberg OFFIS DICOM Team

Joined: 02 Nov 2004 Posts: 1155 Location: Oldenburg, Germany
|
Posted: Thu, 2009-04-09, 13:19 Post subject: |
|
|
The compile error you observe is most likely due to the fact that you modified the compile flags after running configure - the configure script tries to figure out various system properties, and these of course depend on certain compiler settings. Modifying the settings after completion of configure may cause a setting in cfunix.h to become invalid.
Fat binaries may be particularly difficult because you run configure only once yet compile for multiple architectures.
I would suggest that you try setting the CFLAGS, CXXFLAGS and ARCH environment variables before running configure - this should cause your settings to be used during the configure process and to be copied into Makefile.def. Then see if compiling makes any difference - in this particular case SIZEOF_VOID_P in config/include/dcmtk/config/cfunix.h should be defined as 8 after configure, not as 4. |
|
| Back to top |
|
 |
wollet88
Joined: 28 Mar 2008 Posts: 9
|
Posted: Thu, 2009-04-09, 15:27 Post subject: |
|
|
Hi Marco,
first of all, thanks a lot for your reply and help.
Following your suggestion, I have modified the following lines in the "/config/Makefile.def.in" file:
=====
[...]
ARCH = -arch ppc -arch i386 -arch ppc64 -arch x86_64
[...]
CFLAGS = @CFLAGS@ -D_DARWIN_C_SOURCE
[...]
CXXFLAGS = @CXXFLAGS@ -D_DARWIN_C_SOURCE
=====
Then, I executed the following commands:
make distclean
./configure
At this point, I verified the content of the /config/include/dcmtk/config/cfunix.h file, and it still contained the following line:
=====
[...]
/* The size of a `void *', as computed by sizeof. */
#define SIZEOF_VOID_P 4
=====
In fact, a later execution of the "make all" command returned the same build error as before:
=====
[...]
c++ -DHAVE_CONFIG_H -DNDEBUG -c -I. -I. -I../include -I../../config/include -I../../dcmdata/include -I../../dcmnet/include -I../../ofstd/include -arch ppc -arch i386 -arch ppc64 -arch x86_64 \
-O -I/usr/include/libxml2 -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 -D_DARWIN_C_SOURCE wldsfs.cc
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::SetReadlock()':
wldsfs.cc:769: error: cast from 'flock*' to 'int' loses precision
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::ReleaseReadlock()':
wldsfs.cc:824: error: cast from 'flock*' to 'int' loses precision
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::SetReadlock()':
wldsfs.cc:769: error: cast from 'flock*' to 'int' loses precision
wldsfs.cc: In member function 'bool WlmDataSourceFileSystem::ReleaseReadlock()':
wldsfs.cc:824: error: cast from 'flock*' to 'int' loses precision
lipo: can't figure out the architecture type of: /var/folders/qA/qAYVTAn-GQaM0hVV5zyqLE+++TI/-Tmp-//ccENlflJ.out
make[2]: *** [wldsfs.o] Error 1
make[1]: *** [libsrc-all] Error 2
make: *** [dcmwlm-all] Error 2
=====
As a further attempt, I tried specifying just "x86_64" as the value for ARCH in "config/Makefile.def.in":
ARCH = -arch x86_64
Then, I executed:
make distclean
./configure
At this point, I verified once again the content of the /config/include/dcmtk/config/cfunix.h file, and once again it still contained the following line:
=====
[...]
/* The size of a `void *', as computed by sizeof. */
#define SIZEOF_VOID_P 4
=====
Then, I executed:
make all
In this case, I obtain a different error:
=====
[...]
c++ -DHAVE_CONFIG_H -DNDEBUG -c -I. -I. -I../include -I../../config/include -I../include -arch x86_64 \
-O -I/usr/include/libxml2 -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 -D_DARWIN_C_SOURCE tststack.cc
c++ -O -I/usr/include/libxml2 -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 -D_DARWIN_C_SOURCE -L../libsrc -o tststack tststack.o -lofstd -lpthread
ld warning: in tststack.o, file is not of required architecture
ld warning: in ../libsrc/libofstd.a, file is not of required architecture
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [tststack] Error 1
make[1]: *** [tests-all] Error 2
make: *** [ofstd-all] Error 2
=====
I am a bit new to building C / C++ in Unix-like environments, so I am sorry if some of my questions or mistakes are a bit basic...
Thank you in advance for your help and best regards,
Marco. |
|
| Back to top |
|
 |
wollet88
Joined: 28 Mar 2008 Posts: 9
|
Posted: Fri, 2009-04-10, 11:48 Post subject: |
|
|
Hi to everybody,
I think I figured it out, looking at how the "configure" script compiles test config files and how compilation flags are read from environment variables.
So, here is what I finally did, which seems to lead to a successful "Universal Binary" build of the DCMTK:
1 - I left all files from the DMCTK 3.5.4 source distribution unchanged.
2 - I created a "dicom" subfolder in my home directory (not sure if this step is mandatory)
3 - I launched the following command:
env ARCH='-arch ppc -arch i386 -arch ppc64 -arch x86_64' CFLAGS='-D_DARWIN_C_SOURCE -arch ppc -arch i386 -arch ppc64 -arch x86_64' CXXFLAGS='-D_DARWIN_C_SOURCE -arch ppc -arch i386 -arch ppc64 -arch x86_64' ./configure --prefix=$HOME/dicom
4 - I launched the following command:
make all
5 - I launched the following command:
make install
That's it. Now in my ~/dicom folder I have a "Universal Binary" version of all DCMTK utilities. Also, all "*.a" static libraries compiled under the DCMTK source directory should be in "Universal Binary" format.
I hope the above explanation may help other Mac DCMTK users.
Best regards,
Marco. |
|
| Back to top |
|
 |
Marco Eichelberg OFFIS DICOM Team

Joined: 02 Nov 2004 Posts: 1155 Location: Oldenburg, Germany
|
Posted: Fri, 2009-04-10, 20:17 Post subject: |
|
|
| Thanks for your post. This is what I tried to explain (of course in much less detail than provided in your post that will certainly be helpful for other Mac OS X users) when I suggested that you set environment variables prior to running configure. Good to know it still works - the ARCH stuff was originally included in the DCMTK makefile structure for NeXTStep 3.3 some 13 or 14 years ago. As you may know, NeXTStep is kind of a grandfather of current MacOS X, and already supported fat binaries with gcc's -arch command line option. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2.0.21-7 (Debian) © 2001, 2005 phpBB Group
|