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

Alex Lisovich alex.lisovich at gmail.com
Tue Jul 10 14:26:50 EDT 2007


Hi Luis,

   Thank you very much for the explanation! I was not thinking about
the order importance as the same line always worked and works fine for
32 bit build.
   Interestingly, the 64 bit build of the ITK core fails as well if
the BUILD_TESTING is turned ON, so I quess there is some violation of
the rules within the ITK CMakeLists hierarchy itself. It seems that
possibly the reason this problem was not raised before is following:
   Setting only the CMAKE_OSX_ARCHITECTURES to x86_64 does not produce
the 64 bit libraries but 32 bit instead (it can be easily verified by
checking the size of long for example), and such 32 bit build seems to
be more tolerant to the violation of order of libraries (even my
example with ITKCommon in front of everithing bulds fine).
In order to really build in 64 bit mode, one needs to set

CMAKE_CXX_FLAGS=-arch x86_64
CMAKE_C_FLAGS=-arch x86_64,

which produces the real 64 bit built, but building of the tests fails.
The failure is actually different depending on which tool you use.

In case of using make:

Linking CXX executable ../../../bin/itkNumericsHeaderTest
ld64-62.1 failed: duplicate symbol
itk::Object::SetGlobalWarningDisplay(bool) in
/Users/Alex/Sources/ITKCVS/Insight_built/bin/libITKCommon.a(itkObject.o)
and /Users/Alex/Sources/ITKCVS/Insight_built/bin/libITKCommon.a(itkObject.o)

And in case of using xcodebuild ARCHS="x86_64":

Ld /Users/Alex/Sources/ITKCVS/Insight_built/bin/Debug/itkAlgorithmsTests
normal x86_64
    cd /Users/Alex/Sources/ITKCVS/Insight_Xcode
    /usr/bin/g++-4.0 -o
/Users/Alex/Sources/ITKCVS/Insight_built/bin/Debug/itkAlgorithmsTests
-L/Users/Alex/Sources/ITKCVS/Insight_built/bin/Debug -LDebug -L.
-L/Users/Alex/Sources/ITKCVS/Insight_built/bin/Debug
-L/Users/Alex/Sources/ITKCVS/Insight_built/bin
-F/Users/Alex/Sources/ITKCVS/Insight_built/bin/Debug -filelist
/Users/Alex/Sources/ITKCVS/Insight_built/bin/ITK.build/Debug/itkAlgorithmsTests.build/Objects-normal/x86_64/itkAlgorithmsTests.LinkFileList
-arch x86_64 -Wl,-Y,1455 -headerpad_max_install_names -lITKAlgorithms
-lITKIO -lITKBasicFilters -lITKFEM -lITKStatistics -lITKBasicFilters
-lITKIO -lITKNrrdIO -litkgdcm -litkjpeg12 -litkjpeg16 -litkopenjpeg
-litkpng -litktiff -litkjpeg8 -lITKSpatialObject -lITKNumerics
-lITKMetaIO -lITKDICOMParser -lITKEXPAT -lITKniftiio -lITKznz
-litkzlib -lITKCommon -litkvnl_inst -litkvnl_algo -litkv3p_netlib
-litkvnl -litkvcl -lm -litksys -lpthread -lm
/usr/bin/ld: warning -L: directory name (Debug) does not exist
ld64-62.1 failed: duplicate symbol itk::VTKImageIO::VTKImageIO()in
/Users/Alex/Sources/ITKCVS/Insight_built/bin/Debug/libITKIO.a(itkVTKImageIO.o)
and /Users/Alex/Sources/ITKCVS/Insight_built/bin/Debug/libITKIO.a(itkVTKImageIO.o)

As you can see this time the ITKBasicFilters was included twice.
So it looks like the order linker accesses the libraries depends on
the 32 or 64 bit mode, comiler options etc., so probably the order of
including the tests within the ITK core is incorrectt as well, but in
32 bit mode it builds simply by luck, at least on Mac.

Regards,

Alex

On 7/9/07, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>
> HI Alex,
>
>
>                   ITKIO depends on ITKCommon,
>
>
>    and so do ITKBasicFilters, ITKAlgorthms,
>    ITKFEM, ITKStatistics and ITKNumerics...
>
>
> CMake is aware of the dependencies of ITK libraries, so it will
> add ITKCommon to the list of libraries to link with, if it finds that
> you included a library that depends on ITKCommon.
>
> You simply don't need to add ITKCommon to the list of libraries,
> given that you are already setting all the others.
>
>
> Also, in general , you should put first in the list the high level libraries
> and put towards the end the low level libraries. The goal is to resolve
> the dependencies progressively.
>
> Note that since you are including ITKIO in the list you can also
> get rid of "ITKMetaIO itkpng itkzlib" in your command:
> TARGET_LINK_LIBRARIES.
>
> If you are curious about the dependencies in ITK, you can take
> a look at the CMakeLists.txt files of the different directories.
>
> For example, in Insight/Code/IO/CMakeLists.txt lines 69-83
> you will find:
>
> 69 TARGET_LINK_LIBRARIES(ITKIO
> 70 ITKCommon
> 71 ITKNrrdIO
> 72 itkjpeg8
> 73 itkjpeg12
> 74 itkjpeg16
> 75 ${ITK_GDCM_LIBRARIES}
> 76 ${ITK_PNG_LIBRARIES}
> 77 ${ITK_ZLIB_LIBRARIES}
> 78 ${ITK_TIFF_LIBRARIES}
> 79 ITKSpatialObject
> 80 ITKMetaIO
> 81 ITKDICOMParser
> 82 ITKEXPAT
> 83 ITKniftiio)
>
>
> Even better, you may find interesting the CMake option that
> exports all the dependencies in the format that Graphviz can
> use for generating a dependency graph.
>
> You can invoke CMake as
>
>     cmake    --graphviz=InsightDependencies.dot    ~/src/Insight/
>
>
> and then call the "dot" tool from Graphviz as
>
>
>    dot -Tjpg -o InsightDependencies.jpg InsightDependencies.dot
>
>
>
>  The dependencies of CMake source code itself can be seen at
>  http://www.cmake.org/Wiki/CMake:For_CMake_Hackers
>
>
>
> Note that you can do the same for your own project, and
> then you will identify all the dependencies of your code
> with other libraries.
>
>
>   Regards,
>
>
>       Luis
>
>
> --------------------------------------------
>
> On 7/9/07, Alex Lisovich <alex.lisovich at gmail.com> wrote:
> >
> > Hi Sean,
> >
> > I was able to fix the problem, but the fix looks (to me) as strange as
> > the problem itself.
> > Inside my CMakeLists.txt file there was a line:
> >
> > TARGET_LINK_LIBRARIES(Test64 ITKCommon ITKBasicFilters ITKAlgorithms
> > ITKNumerics ITKFEM ITKIO ITKStatistics ITKMetaIO itkpng itkzlib)
> >
> > It appears that ITKCommon does not live together with any other
> > libraries in 64 bit mode, causing linker to include it twice into the
> > build (see the complete failure message below).Removing ITKCommon from
> > the line above  leads to the successive build with, at least,
> > succesive creation of the image during the execution. The 32 bit build
> > works fine without the removal of ITKCommon.
> >
> > Best,
> >
> > Alex
> >
> > P.S .: failure message (double inclusion of ITKCommon):
> >
> > Ld
> /Users/Alex/Sources/ITK_J2K_Region/Test64built/Debug/Test64
> normal x86_64
> >     mkdir
> /Users/Alex/Sources/ITK_J2K_Region/Test64built/Debug
> >     cd /Users/Alex/Sources/ITK_J2K_Region/Test64built
> >     /usr/bin/g++-4.0 -o
> >
> /Users/Alex/Sources/ITK_J2K_Region/Test64built/Debug/Test64
> > -L/Users/Alex/Sources/ITK_J2K_Region/Test64built/Debug
> >
> -L/Users/Alex/Sources/ITK_J2K_Region/ItkXCode_Debug/bin/Debug
> > -L/Users/Alex/Sources/ITK_J2K_Region/ItkXCode_Debug/bin
> > -F/Users/Alex/Sources/ITK_J2K_Region/Test64built/Debug
> -filelist
> >
> /Users/Alex/Sources/ITK_J2K_Region/Test64built/Test64.build/Debug/Test64.build/Objects-normal/x86_64/Test64.LinkFileList
> > -arch x86_64 -Wl,-Y,1455 -headerpad_max_install_names -lITKCommon
> > -lITKBasicFilters -lITKAlgorithms -lITKNumerics -lITKFEM -lITKIO
> > -lITKStatistics -lITKMetaIO -litkpng -litkzlib -lITKBasicFilters
> > -lITKNrrdIO -litkgdcm -litkjpeg12 -litkjpeg16 -litktiff -litkjpeg8
> > -litkopenjpeg -lITKSpatialObject -lITKNumerics -lITKMetaIO
> > -lITKDICOMParser -lITKEXPAT -lITKniftiio -lITKznz -litkzlib
> > -lITKCommon -litkvnl_inst -litkvnl_algo -litkv3p_netlib -litkvnl
> > -litkvcl -lm -lpthread -lm -litksys
> > ld64-62.1 failed: duplicate symbol
> > itk::Region::Print(std::basic_ostream<char,
> std::char_traits<char> >&,
> > itk::Indent) constin
> >
> /Users/Alex/Sources/ITK_J2K_Region/ItkXCode_Debug/bin/Debug/libITKCommon.a(itkRegion.o)
> > and
> /Users/Alex/Sources/ITK_J2K_Region/ItkXCode_Debug/bin/Debug/libITKCommon.a(itkRegion.o)
> >
> >
> >
> > On 7/9/07, Alex Lisovich <alex.lisovich at gmail.com> wrote:
> > > Yes, I do, and it's actually using gcc/g++ 4.0
> > >
> > > Well, life of mortals is difficult...
> > >
> > > Alex
> > >
> > > On 7/9/07, Sean McBride <sean at rogue-research.com> wrote:
> > > > On 7/6/07 5:52 PM, Alex Lisovich said:
> > > >
> > > > >Thank you very much for your patch! The warning about AppKit and
> > > > >Carbon issue are gone.
> > > >
> > > > Glad it helped.
> > > >
> > > > >However, the build fails as before:
> > > > >
> > > > >ld64-62.1 failed: duplicate symbol
> > > > >itk::Region::Print(std::basic_ostream<char,
> std::char_traits<char> >&,
> > > > >itk::Indent) constin
> > > >
> >/Users/Alex/Sources/ITK_J2K_Region/ItkXCode_Debug/bin/Debug/
> > > > > libITKCommon.a(itkRegion.o)
> > > > >and
> /Users/Alex/Sources/ITK_J2K_Region/ItkXCode_Debug/bin/Debug/
> > > > >libITKCommon.a(itkRegion.o)
> > > > >
> > > > >So it looks like it complains about the duplicate Region::Print()
> > > > >method within the same itkRegion.o? And this definitely looks like
> > > > >template instantiation problem, because when I remove the line
> > > > >"ImageType::Pointer im=ImageType::New();" it builds. I am (almost)
> > > > >positive I am not building universal binaries, because I am using
> > > > ><xcodebuild ARCHS="x86_64"> which should build for a single target.
> > > > >Using make also produces the same build failure with the same
> message.
> > > >
> > > > hmmm, not sure about this one... Are you specifying the 10.4u SDK with
> > > > CMAKE_OSX_SYSROOT?
> > > >
> > > > --
> > > >
> ____________________________________________________________
> > > > Sean McBride, B. Eng                 sean at rogue-research.com
> > > > Rogue
> Research                        www.rogue-research.com
> > > > Mac Software Developer              Montréal, Québec,
> Canada
> > > >
> > > >
> > > >
> > >
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>
>


More information about the Insight-users mailing list