[Insight-users] Cannot build ITK for MAC OS X Tiger 64 bit

Sean McBride sean at rogue-research.com
Fri Jul 6 15:56:08 EDT 2007


On 7/6/07 2:06 PM, Alex Lisovich said:

>Was anybody able to build ITK on MAC OS Tiger for 64 bit Intel target
>(x86_64)?

Tiger is only kinda 64 bit.  We have a 64 bit ITK mostly working in a
Mac OS X 10.5 beta.  It builds anyway.

>    The first problem is that it itkMultiThreader.cxx unconditionally
>includes Carbon.h for any APPLE build including 64-bit, and Carbon on
>Tiger does not support it. It seems I was able to solve this by using
>fix from VTK bug report list ( see
>http://www.vtk.org/Bug/bug.php?op=show&bugid=2932 ) which allowed ITK
>to build (without examples and tests).

Neat, that was me that patched that.  :)  A shame that ITK has pretty
much the same code copy and pasted.  I had no idea or I would have
patched it in both places.

>And the build fails:
>
>....
>ld64 warning: in /System/Library/Frameworks//AppKit.framework/AppKit,
>missing required architecture x86_64 in file

AppKit is 32 bit only in 10.4.  Odd that ITK thinks it needs to link
with AppKit.framework.  However, searching the ITK source reveals that
it does indeed pass "-framework AppKit".  This should not be necessary. 
I suspect if you remove that your problem will go away.  The current ITK
code does an #include <Carbon/Carbon.h> and so should use "-framework
Carbon", AppKit itself links to Carbon which explains why ITK can link.

Anyway, try the attached patch.  I have not actually tried it, but I
think it will work.

Let us know if it works, then maybe someone can commit it.

Cheers,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada
-------------- next part --------------
Index: Code/Common/CMakeLists.txt
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/CMakeLists.txt,v
retrieving revision 1.122
diff -r1.122 CMakeLists.txt
127,129d126
< IF(APPLE)
<   TARGET_LINK_LIBRARIES(ITKCommon "-framework AppKit")
< ENDIF(APPLE)
Index: Code/Common/itkMultiThreader.cxx
===================================================================
RCS file: /cvsroot/Insight/Insight/Code/Common/itkMultiThreader.cxx,v
retrieving revision 1.38
diff -r1.38 itkMultiThreader.cxx
42c42,43
< #include <Carbon/Carbon.h>
---
> #include <sys/types.h>
> #include <sys/sysctl.h>
44c45
<     
---
> 
123,125c124,133
<     // MPProcessors returns the physical number of processors present
<     // MPProcessorsScheduled returns number of active processors
<     num = MPProcessors();
---
>     // Use sysctl() to determine the number of CPUs.  This is prefered
>     // over MPProcessors() because it doesn't require CoreServices
>     // (which is only available in 32bit on Mac OS X 10.4)
>     int mib[2] = {CTL_HW, HW_NCPU};
>     size_t dataLen = sizeof(int); // 'num' is an 'int'
>     int result = sysctl(mib, 2, &num, &dataLen, NULL, 0);
>     if (result == -1)
>       {
>       num = 1;
>       }


More information about the Insight-users mailing list