Any known build issues on OSX Snow Leopard? #16

justinfx opened this Issue May 26, 2012 · 4 comments


None yet

2 participants


I am wondering if there are any known issues when trying to build on OSX Snow Leopard (10.6.8)?
What I am seeing is that during the make, it constantly wants to look for python2.7 headers and fails to find them. I looked at the source files and found some hardcoded python2.7 references.

My current approach was to install python2.7 and rebuild, though now I am dealing with mixed interps. I can get the build to succeed but its till expecting various headers and libs in certain locations, and I get a corrupt .so

While trying to build on OSX Lion (10.7.4), I can neither build a working module with the system python2.7 (complains about mismatched interps), or with a homebrew python2.7 (Complains about a symbol not found: _environ)

Are there any detailed instructions on how to build for OSX? I don't see where it says in the README that python2.7 is expected and hardcoded. Any ideas?


Yes, you're right. As this is a Python extension,
it uses the CPython API (mainly through Boost.Python, but in some cases directly / hardcoded).

You need the Python development files and Python 2.7 or higher to build.
I'll add that to the README.

I'm not a Mac expert, but keep in mind that
Python compiler flags were removed because it didn't build.
See issue #6 and the proposed solution, #8.

You can try to enable them (just undo the changes in #8).
Then, make sure to remove other Python installations (leaving only 2.7),
remove CMakeCache.txt and run cmake.
Does CMake detect Python and OpenNI correctly?

If that doesn't work, please post the output of cmake and make.

Thanks for using PyOpenNI.

@jmendeth jmendeth was assigned May 26, 2012

Thanks for the reply! I actually just made some progress. I'm not extremely fluent with all the possible ways to specify libs and whatnot during compile phase, but maybe this will offer some insight and you would see a more direct fix...

I first reinstalled my python2.7 install via homebrew, adding the --framework flag

After building the module, I noticed via otool that it was still linking to my system python, and the system python on Lion is fat i386 and x86_64. I also noticed that the libboost which was linked to was also linked against the system python instead of homebrew. So I used the following to relink them:

install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python \

install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python \
/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Python \

After doing this, I was able to import openni without any errors. Also performed these steps again using the unpatched .cpp source files (no extra Python includes, etc), and it still built fine. Ultimately, I am suggesting that the steps to building on OSX specifically need to address:

  1. python2.7 as framework, as x86_64 (not fat)
  2. libboost linked to the proper 64bit python
  3. export CPPFLAGS="-arch x86_64"
  4. cmake
  5. make
  6. relink lib/ to the 64bit python

Maybe you have a suggestion about how to properly set the env before building to get it to link properly in the first place?


My previous working procedure didn't end up being very consistant. When I tried to rebuild recently I kept having an issue with the build not finding the proper python2.7 includes. Removing all other python installs from my system isn't really a viable option. What I found to be a consistent fix was:

  1. pass the explicit location of the Headers location to cmake: cmake -D PYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Headers ..
  2. Make python 2.7 a minimum version requirement in CMakeLists.txt when searching for the libs
  3. Remove the explicit #include <python2.7/...> from the source since they are already properly included with the previous #include <Python.h> line

Proposed PATCH:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c3aced4..c3d6827 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,8 +23,8 @@

 # Find the needed libraries
-find_package (PythonInterp REQUIRED)
-find_package (PythonLibs REQUIRED)
+find_package (PythonInterp 2.7 REQUIRED)
+find_package (PythonLibs 2.7 REQUIRED)

diff --git a/src/DepthMapWrapper.cpp b/src/DepthMapWrapper.cpp
index bf66552..c1e0539 100644
--- a/src/DepthMapWrapper.cpp
+++ b/src/DepthMapWrapper.cpp
@@ -26,8 +26,6 @@
 #include "wrapperTypes.h"
 #include "wrapperExceptions.h"
 #include <Python.h>
-#include <python2.7/intobject.h>
-#include <python2.7/object.h>

 namespace pyopenni {

diff --git a/src/PointMapWrapper.cpp b/src/PointMapWrapper.cpp
index 756f923..fa2aefd 100644
--- a/src/PointMapWrapper.cpp
+++ b/src/PointMapWrapper.cpp
@@ -26,8 +26,6 @@
 #include "wrapperTypes.h"
 #include "wrapperExceptions.h"
 #include <Python.h>
-#include <python2.7/intobject.h>
-#include <python2.7/object.h>

 namespace pyopenni {
@justinfx justinfx added a commit to justinfx/PyOpenNI that referenced this issue Jun 22, 2012
@justinfx justinfx Patch for issue #16
Require min python version 2.7
Remove explicit python2.7 includes

Closed in favor of proposed patch in issue #18

@justinfx justinfx closed this Jun 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment