[Insight-users] How to get ITK4+ and Python wrapping to work on Mac OSX (10.7)?

Mark Tsuchida marktsuchida at gmail.com
Mon Nov 12 20:28:38 EST 2012


On Mon, Nov 12, 2012 at 7:53 PM, Ahmed Halaweish, Ph.D.
<ahmed.halaweish at duke.edu> wrote:
>    I'm trying to get ITK 4.1 and ITK 4.2 + Python wrapping to work on my
> macbook and mac pro desktop (both running 10.7) without any luck. I always
> seem to get a make: error 2 in the Wrapping/Modules section of the
> compilation process.

I don't know if the following applies to your case (would need to see the
error messages you got), but here is what I have found necessary trying to
compile WrapITK for Python on Lion.

Xcode comes with two sets of compilers (clan/clang++ and llvm-gcc/llvm-g++).
While either appears to work for compiling ITK itself, I have only been
able to get llvm-gcc to work for WrapITK.

By default, cmake chooses /usr/bin/gcc (a symlink to llvm-gcc) and
/usr/bin/c++ (a symlink to clang++), which is not just inconsistent but
causes some weird problems with GCC_XML, a program required for generating
the wrappers.


I have been able to get WrapITK to compile by following these steps (Lion,
Xcode 4.5, cmake 2.8.8):

1. Download GCC_XML from
http://itk.org/files/gccxml/gccxml-2012-08-08.tar.bz2 (see the thread in
this list today titled "build fails to download gccxml (4.2.1)").

2. Configure GCC_XML with the following, build, and install (to /usr/local).

CMAKE_BUILD_TYPE=Release
CMAKE_C_COMPILER=/usr/bin/llvm-gcc
CMAKE_CXX_COMPILER=/usr/bin/llvm-g++

[If the compilers are not explicitly set here, building WrapITK will fail.
If they are set to clang/clang++, configuration of GCC_XML will fail.]

3. Configure ITK 4.2.1. First set the compilers:

CMAKE_C_COMPILER=/usr/bin/llvm-gcc
CMAKE_CXX_COMPILER=/usr/bin/llvm-g++

[If you are using ccmake, all other settings will be reset after changing
the compiler.]

Then,
BUILD_SHARED_LIBS=ON
BUILD_EXAMPLES=OFF   # Not the point here, but this is what I did
BUILD_TESTING=OFF    # Ditto.

Add
ITK_WRAP_PYTHON=ON

This (if using ccmake) will disclose additional options.
We need to set

ITK_USE_SYSTEM_GCCXML=ON

to use the GCC_XML installed above in 2.

Also, they Python paths are usually detected incorrectly (the paths may
exist but may be wrong or belong to a different installation of Python). In
my case, I am using Python 2.7 compiled from the source, which is installed
under /Library (as is Python 2.7 from the python.org installer package). It
is best to set all of the following explicitly, or at least check that they
are correct:

PYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
PYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
PY_SITE_PACKAGES_PATH=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
PYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

(end of steps)

I have not tried building ITK from the git head. It is probably sufficient
to just set the compilers in ITK's config and let those propagate to
GCC_XML's, rather than doing a separate build and installation of GCC_XML.
At least, that used to work with ITK 4.2.1 before the GCC_XML repository
got moved.

Hope this helps,

Mark




On Mon, Nov 12, 2012 at 1:25 PM, Matt McCormick
<matt.mccormick at kitware.com>wrote:

> Hi AFH,
>
> Could you please reply with the error message that you get.
>
> Thanks,
> Matt
>
> On Mon, Nov 12, 2012 at 7:53 PM, Ahmed Halaweish, Ph.D.
> <ahmed.halaweish at duke.edu> wrote:
> > All,
> >    I'm trying to get ITK 4.1 and ITK 4.2 + Python wrapping to work on my
> > macbook and mac pro desktop (both running 10.7) without any luck. I
> always
> > seem to get a make: error 2 in the Wrapping/Modules section of the
> > compilation process.
> >
> > Here are the variables I set in cmake:
> > BUILD_SHARED_LIBS = ON
> > CMAKE_BUILD_TYPE = Release
> > ITK_USE_REVIEW = ON
> > ITK_WRAPPING = ON
> > ITK_WRAP_PYTHON = ON
> >
> > If anyone has had any luck with this, please do share any tips or
> pointers.
> >
> > Cheers
> > AFH
> >
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.php
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
> >
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121112/c060366d/attachment.htm>


More information about the Insight-users mailing list