# OSX\_DEPLOYMENT\_TARGET 10.9 or later required with ITKv5

**URL:** https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616
**Category:** Engineering
**Tags:** python, itkv5, macos
**Created:** [January 23, 2018, 3:00pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616 "2018-01-23T15:00:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [January 23, 2018, 3:00pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616/1 "2018-01-23T15:00:14Z")

</div>

Hi folks,

If you do not build macOS binaries for distribution that target compatibility with older OS versions, you can ignore this thread.

As a consequence of the [C++11 requirement of ITKv5](https://discourse.itk.org/t/gearing-up-for-itk5/515/2), macOS builds that specify `OSX_DEPLOYMENT_TARGET`, e.g. through the [`CMAKE_OSX_DEPLOYMENT_TARGET`](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html) variable, will require a version of `10.9` or later. Since [`10.9` builds](https://open.cdash.org/buildSummary.php?buildid=5230185) use `libc++`, which has sufficient C++11 support, they will build, [unlike earlier versions](https://open.cdash.org/buildSummary.php?buildid=5231129), which use an old `libstdc++`.

M

CC: @blowekamp @hjmjohnson

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [January 23, 2018, 4:08pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616/2 "2018-01-23T16:08:33Z")

</div>

Matt,

Thanks for moving this discussion here! And for submitting those builds to the dashboard.

Yes, it appears that the Apple’s GNU libstdc++ is old and does not properly support C++11, even with the `-std=c++11`. Compiling the current ITK, results in compilation errors in the VNL related to std::shared\_ptr not being available as your builds show.

By default, when `OSX_DEPLOYMENT_TARGET=10.9` libc++ is used, which is required for using c+11. However, libc++ is available with `OSX_DEPLOYMENT_TARGET=10.7`. So configuring the current ITKv5 development with the following works:

```auto
 cmake -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 ~/src/ITK

```

Resulting in the following executables:

```auto
$ otool -L bin/itkTestDriver 
bin/itkTestDriver:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)

```

While the Apple system python (2.6,2.7) uses it’s own os version for the min OS X:

```auto
lhcp-vm-osx11-1$ /usr/bin/python -c "import distutils.util; print(distutils.util.get_platform())"
macosx-10.11-intel
lhcp-vm-osx11-1$ /usr/bin/python2.6 -c "import distutils.util; print(distutils.util.get_platform())"
macosx-10.11-intel

```

the [python.org](http://python.org) distribution is still stuck at 10.6:

```auto
lhcp-vm-osx11-1$ /usr/local/bin/python3.5 -c "import distutils.util; print(distutils.util.get_platform())"
macosx-10.6-intel
lhcp-vm-osx11-1$ /usr/local/bin/python3.4 -c "import distutils.util; print(distutils.util.get_platform())"
macosx-10.6-intel
lhcp-vm-osx11-1$ /usr/local/bin/python2.7 -c "import distutils.util; print(distutils.util.get_platform())"
macosx-10.6-intel

```

I am unaware of a Python PEP for a recommendation on OS X binaries nor what c++ library to use.

The [Spinning Wheels Mac Python](https://github.com/MacPython/wiki/wiki/Spinning-wheels) is old and does not address libc++ issues.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [January 23, 2018, 4:29pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616/3 "2018-01-23T16:29:03Z")

</div>

> [@blowekamp](#):
>
> By default, when OSX\_DEPLOYMENT\_TARGET=10.9 libc++ is used, which is required for using c+11. However, libc++ is available with OSX\_DEPLOYMENT\_TARGET=10.7. So configuring the current ITKv5 development with the following works:
> 
> cmake -DCMAKE\_CXX\_FLAGS=-stdlib=libc++ -DCMAKE\_OSX\_DEPLOYMENT\_TARGET=10.7 ~/src/ITK

Yes, `CMAKE_CXX_FLAGS` can be used to augment `CMAKE_OSX_DEPLOYMENT_TARGET`. That is another option, though it is more difficult to apply.

> [@blowekamp](#):
>
> The Spinning Wheels Mac Python is old and does not address libc++ issues.

This page shows that other binary Python distributions are using OSX\_DEPLOYMENT\_TARGET 10.9.

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [January 23, 2018, 5:03pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616/4 "2018-01-23T17:03:44Z")

</div>

> [@matt.mccormick](#):
>
> This page shows that other binary Python distributions are using OSX\_DEPLOYMENT\_TARGET 10.9.

It is unclear when that table was updated. I just showed the current [Python.org](http://Python.org) distributions are stuck at 10.6. I’m not sure where home-brew/Mac ports are, but I’d guess they are on a very recent version.

There is also Anaconda, which appears to be developing [their own toolchain](https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html) which uses the 10.9 framework, but I don’t see and indication of neither what C++ library they are using nor what min OS X deployment target. From my recent miniconda installations I am getting the following report:

```auto
$ ~/miniconda2/bin/python2.7 -c "import distutils.util; print(distutils.util.get_platform())"
macosx-10.7-x86_64
$ ~/miniconda3/bin/python3.6 -c "import distutils.util; print(distutils.util.get_platform())"
macosx-10.7-x86_64

```

Additionally they seem to be using libc++

```auto
$ otool -L ~/miniconda3/lib/*.dylib |grep c++
/Users/blowekamp/miniconda3/lib/libc++.1.0.dylib:
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 48.0.0)
	@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/blowekamp/miniconda3/lib/libc++.1.dylib:
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 48.0.0)
	@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/blowekamp/miniconda3/lib/libc++.dylib:
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 48.0.0)
	@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/blowekamp/miniconda3/lib/libc++abi.1.0.dylib:
	@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/blowekamp/miniconda3/lib/libc++abi.1.dylib:
	@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/blowekamp/miniconda3/lib/libc++abi.dylib:
	@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)

```

IMHO, I think we can keep the check for requiring 10.7, but that is not sufficient to determine that compiler configuration will work. I’d expect that the CMake [WriteCompilerDetectionHeader](https://cmake.org/cmake/help/v3.10/module/WriteCompilerDetectionHeader.html) would be more aware of these compiler options to generate compliant results. As these extra configuration flags ( specifying OSX\_DEPLOYMENT\_TARGET) are not commonly used by default and geared towards packaging, it may be ok not to have a complete check and leave the code as it is.

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [January 23, 2018, 5:23pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616/5 "2018-01-23T17:23:44Z")

</div>

Typo? That shows it uses libc++ (from llvm), _not_ libstdc++ (from GNU).

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [January 23, 2018, 5:37pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616/6 "2018-01-23T17:37:24Z")

</div>

Corrected

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [January 23, 2018, 5:50pm UTC](https://discourse.itk.org/t/osx-deployment-target-10-9-or-later-required-with-itkv5/616/7 "2018-01-23T17:50:43Z")

</div>

> [@blowekamp](#):
>
> IMHO, I think we can keep the check for requiring 10.7, but that is not sufficient to determine that compiler configuration will work. I’d expect that the CMake WriteCompilerDetectionHeader would be more aware of these compiler options to generate compliant results. As these extra configuration flags ( specifying OSX\_DEPLOYMENT\_TARGET) are not commonly used by default and geared towards packaging, it may be ok not to have a complete check and leave the code as it is.

This is reasonable.
