Child pages
  • pcl-trunk on OS X 10.9 with homebrew
Skip to end of metadata
Go to start of metadata

Also see pcl-trunk on OS X 10.8.4 with homebrew.

Partly based on PCL Homebrew build instructions. Also see PCL Binaries for OS X and Ken Spratlin's Notes (local copy).

We do things ourselves vs installing the binaries for a few reasons:

  • we want the ability to track and patch PCL trunk, and to specify custom build options
  • we want to know/control exactly what OpenNI code we are using
  • we want to match our OS X PCL stack as closely as possible to our main Ubuntu 12.04 PCL stack
  1. Check OS and tool versions, update if needed. Make sure your xcode is up to date, and install the most up to date xcode command line tools — after installing/updating xcode you need to launch it and update the command line tools components in the preferences run xcode-select --install.
    sw_vers -productVersion
    xcodebuild -version
    Xcode 5.0.2
    Build version 5A3005
    g++ --version
    Configured with: --prefix=/Applications/ --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
    Target: x86_64-apple-darwin13.0.0
    Thread model: posix
    c++ --version
    Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
    Target: x86_64-apple-darwin13.0.0
    Thread model: posix
  2. Reinstall all homebrew formulae if you just updated to OS X 10.9. The reason is that most formulae use the clang defaults for -stdlib which prior to 10.9 was (apparently) libstdc++ (in fact, I believe it was a fairly old version based on gcc4.2), but is now libc++ as of 10.9. If you had built things (e.g. vtk5) before updating to 10.9 then they'll probably be linked against libstdc++ so when you try to build PCL on 10.9, which will use libc++, you'll probably get link errors for undefined references to things like std::__1::basic_ostream.
    c++0x/c++11 compatibility when building against homebrew deps was basically horked prior to OS X 10.9 (see pcl-trunk on OS X 10.8.4 with homebrew). But as long as you reinstall all your homebrew deps after updating to 10.9, it should work now. TBD test.
  3. Install dependencies.
    brew update
    brew install cmake
    brew install boost # installs boost 1.55.0
    brew install eigen # installs eigen 3.2.0
    brew install flann
    brew install qhull
    brew install gnu-sed
    brew tap homebrew/versions
    brew install vtk5 # installs vtk 5.10.1
    # libusb < 1.0.16 on OS X has a serious issue that blocks keyboard and mouse which manifests for me on OS X 10.9
    # workaround is to install libusbx # installs libusbx 1.0.17
    brew unlink libusb # if you had installed libusb, which was at 1.0.9 as of the time of this writing (11/19/13)
    brew install libusbx
  4. Install CUDA 5.5 from here. Unfortunately at the time of this writing 11/19/13 CUDA support is broken for OS X 10.9 (Mavericks) on my old macbook pro which has a GeForce 9600M GT. Apparently the issue is that CUDA is not supported at the moment for any 1.x (Tesla) class cards on 10.9, though a fix is planned. According to this you can check if you have one of the bad cards like this: "About this Mac -> More Information -> System Report -> Extensions ... if the NVDANV50HalTesla is loaded, CUDA won't work". CUDA did work on my old mac with OS X 10.8.4, and it works on my new mac which has a GeForce GT 750M.
    # in System Preferences -> Energy Saver make sure Graphics is set to "Higher performance" (TBD is this required)
    export "PATH=/Developer/NVIDIA/CUDA-5.5/bin:$PATH" >> ~/.profile
    export "DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-5.5/lib:$DYLD_LIBRARY_PATH" >> ~/.profile
    # open new terminal
    kextstat | grep -i cuda
      143    0 0xffffff7f825ad000 0x2000     0x2000     com.nvidia.CUDA (1.1.0) <4 1>
    nvcc -V
    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2013 NVIDIA Corporation
    Built on Thu_Sep__5_10:17:14_PDT_2013
    Cuda compilation tools, release 5.5, V5.5.0
    /Developer/NVIDIA/CUDA-5.5/bin/ .
    cd NVIDIA_CUDA-5.5_Samples
    for F in `find . -name Makefile | xargs grep -l -- "-framework.*CUDA"`; do cp -n $F $F.ORIG; sed -e "s|-Xlinker -framework -Xlinker CUDA|-Xlinker -F/Library/Frameworks -Xlinker -framework -Xlinker CUDA|" $F.ORIG > $F; done
  5. Install a similar version of OpenNI 1.x as we use in Linux to /usr/local. (Also see totakke's homebrew formula openni.rb.) These commands attempt to replicate the way things get installed on Ubuntu so we have maximal compatibility between our development on the two platforms. This seems to work fine with Carmine 1.09 (firmware 5.9.2) and Xtion Pro Live (firmware 5.3.26). Because it installs an un-patched version of the PrimeSense Sensor code, it is not expected to work with Kinect (TBD test). If you only need Kinect and Xtion support, try installing Jochen Sprickerhof's patched OpenNI and SensorV2 by following the instructions for OS X 10.8.4.
    # manually install java for os x from
    mkdir primesense && cd primesense 
    git clone # gets 1e9524ff (11/12/13) as of 11/13/13
    pushd OpenNI
    # fix hardcoded paths
    cp -n $F $F.ORIG
    sed -e 's|/var/lib/ni|/usr/local/etc/openni|' $F.ORIG > $F
    cp -n $F $F.ORIG
    sed -e 's|SAMPLE_XML_PATH ".*"|SAMPLE_XML_PATH "/usr/local/etc/openni/SamplesConfig.xml"|' $F.ORIG > $F
    # fix install paths
    cp -n $F $F.ORIG
    sed -e '/INSTALL/s|usr|usr/local| ; s|/var/lib/ni|/usr/local/etc/openni|' $F.ORIG > $F
    # disable sse and i386
    cp -n $F $F.ORIG
    sed -e 's/SSE_GENERATION = 3/SSE_GENERATION = 0/ ; s/DUMMY.*/DUMMY=/; s/-arch i386//' $F.ORIG > $F
    # work around name collision with "equivalent" defined at
    # /Applications/
    # which gets included by iostream header
    for F in `find . -name glh_linear.h`; do cp -n $F $F.ORIG; sed -e 's/equivalent/glh_equivalent/g' $F.ORIG > $F; done
    # PCL seems to use the installed SamplesConfig.xml but only on OS X
    cp -n $F $F.ORIG
    sed -e 's|<GlobalMirror on="true"/>|<!-- GlobalMirror on="true"/-->|' $F.ORIG > $F
    # fix include path for OS X
    cp -n $F $F.ORIG
    sed -e 's+opt/local+usr/local+' $F.ORIG > $F
    cd Platform/Linux/CreateRedist
    cd ../Redist
    D=`ls -d *-Bin*`
    V=`expr $D : ".*-v\(.*\)"`
    cd $D
    sed -e "s/VERSION/$V/" $ > $F
    ls /usr/local/bin > bin-orig.txt
    cp Bin/ni* Samples/Bin/x64-Release/Ni* /usr/local/bin
    ls /usr/local/bin > bin-new.txt
    diff bin-orig.txt bin-new.txt | cut -d' ' -f2 | grep -E 'ni.*|Ni.*' > ../../../../bin-installed.txt
    ls /usr/local/lib > lib-orig.txt
    cp Lib/libOpenNI.* Lib/libni* /usr/local/lib
    ls /usr/local/lib > lib-new.txt
    diff lib-orig.txt lib-new.txt | cut -d' ' -f2 | grep -E 'libni.*|libOpenNI.*' > ../../../../lib-installed.txt
    mkdir -p /usr/local/include/ni
    cp -R Include/* /usr/local/include/ni/
    mkdir -p /usr/local/etc/openni
    for f in `ls /usr/local/lib/libni*`; do niReg $f; done
    cp Samples/Config/SamplesConfig.xml /usr/local/etc/openni/
    cp openni-dev.pc /usr/local/lib/pkgconfig
    # at least in git 28d22bca (8/30/13) pcl trunk uses a hardcoded path /etc/openni/SamplesConfig.xml on Apple
    sudo mkdir /etc/openni
    sudo ln -s /usr/local/etc/openni/SamplesConfig.xml /etc/openni
    for f in `ls /usr/local/lib/libni*`; do niReg -u $f; done
    for f in `cat bin-installed.txt`; do rm -f /usr/local/bin/$f; done
    for f in `cat lib-installed.txt`; do rm -f /usr/local/lib/$f; done
    rm -rf /usr/local/include/ni
    rm -rf /usr/local/etc/openni
    sudo rm -rf /etc/openni
    rm -f /usr/local/lib/pkgconfig/*openni*.pc
  6. Ditto for the "sensor" driver for OpenNI.
    git clone # gets 60170bfe (11/12/13) as of 11/13/13
    cd Sensor
    # fix hardcoded paths
    cp -n $F $F.ORIG
    sed -e 's|/usr|/usr/local|' $F.ORIG > $F
    cp -n $F $F.ORIG
    sed -e 's|/usr|/usr/local|' $F.ORIG > $F
    cp -n $F $F.ORIG
    sed -e 's|/usr|/usr/local|' $F.ORIG > $F
    cp -n $F $F.ORIG
    gsed -e '/LDFLAGS += $(LIB_DIRS_OPTION)/iLDFLAGS += -L/usr/local/lib' $F.ORIG > $F
    # fix install paths
    cp -n $F $F.ORIG
    sed -e '/INSTALL/s|usr|usr/local| ; s|/var/lib/ni|/usr/local/etc/openni| ; s|etc/primesense|etc/openni| ; s|/var/log|/usr/local/var/log|' $F.ORIG > $F
    # disable sse and i386
    cp -n $F $F.ORIG
    sed -e 's/SSE_GENERATION = 3/SSE_GENERATION = 0/ ; s/DUMMY.*/DUMMY=/; s/-arch i386//' $F.ORIG > $F
    # parallel build is broken on OS X
    cp -n $F $F.ORIG
    sed -e 's/-j$(calc_jobs_number)//' $F.ORIG > $F
    cd Platform/Linux/CreateRedist
    cd ../Redist
    D=`ls -d *-Bin*`
    V=`expr $D : ".*-v\(.*\)"`
    cd $D
    cp Config/GlobalDefaults.ini /usr/local/etc/openni
    cp Bin/XnSensorServer /usr/local/bin
    echo "XnSensorServer" > ../../../../bin-installed.txt
    ls /usr/local/lib > lib-orig.txt
    cp Lib/libXn* /usr/local/lib
    ls /usr/local/lib > lib-new.txt
    diff lib-orig.txt lib-new.txt | cut -d' ' -f2 | grep 'libXn*' > ../../../../lib-installed.txt
    for f in `ls /usr/local/lib/libXnDevice*`; do niReg $f; done
    sudo chown root $F
    sudo chmod +s $F
    mkdir -p $D
    chmod a+w $D
    sudo chmod -s $F
    sudo chown `whoami` $F
    for f in `ls /usr/local/lib/libXnDevice*`; do niReg -u $f; done
    for f in `cat bin-installed.txt`; do rm -f /usr/local/bin/$f; done
    for f in `cat lib-installed.txt`; do rm -f /usr/local/lib/$f; done
    rm -rf /usr/local/var/log/primesense
    rm -f /usr/local/etc/openni/GlobalDefaults.ini 
  7. To check installed OpenNI version, run niReg -l. You should get OpenNI version and PrimeSense/SensorV2/
  8. To check hardware and firmware versions, change Log writeToConsole="true" and LogLevel value="0" in /usr/local/etc/openni/SamplesConfig.xml. Then attach (one) device, run NiViewer, and grep the console output for Hardware versions.
  9. Finally download, build, and install PCL
    git clone pcl-trunk # gets b1edb0d9 (11/21/13) on 12/9/13
    cd pcl-trunk
    # On a newer USB3 macbook pro I am getting severe USB communication errors that seem to be related to
    # RGB image transfer from non-Kinect primesense devices like Xtion Pro Live and Carmine.  Kinect works
    # fine though you have to install the older patched OpenNI code as mentioned above.  To work around
    # the issue with the other sensors the following snippet will force them to get detected by PCL as
    # Xtion Pro (not Live) which has no RGB sensor.  So you will lose RGB capability but at least the depth
    # stream will work (without this hack you won't get depth even if that's all you request from PCL).
    # These devices all worked fine on an older USB2 macbook pro.
    cp -n $F $F.ORIG
    sed -e '/(device_context_.*.image_node.get/s/device_context/false \&\& device_context/' $F.ORIG > $F
    #for some reason the cuda dependency find in cmake is told to be quiet
    #this can make it hard to notice when it fails
    #not only will no message be emitted about failure to find cuda
    #but also for some reason no PCL gpu_* modules will be listed under either
    #"The following subsystems will be built:" or "The following subsystems will not be built:"
    cp -n $F $F.ORIG
    sed -e '/CUDA_FIND_QUIETLY/s/^/#/' $F.ORIG > $F
    #cuda 5.5 on os x 10.9 does not officially support clang and libc++ yet so here are some hacks
    #with these I was able to get kinfu built and running at 10FPS on
    #GeForce GT 750M 2048Mb, sm_30, 384 cores
    #unfortunately with these hacks I could not get the gpu_octree module to build
    #and apparently gpu_kinfu_large_scale depends on gpu_octree
    cp -n $F $F.ORIG
    sed -e '/macro(PCL_CUDA_ADD_LIBRARY/,/endmacro/s|target_link_libraries(${_name} ${Boost_LIBRARIES})|target_link_libraries(${_name} ${Boost_LIBRARIES} /usr/lib/libstdc++.dylib)|' $F.ORIG > $F
    CUDA_HACK="-DBUILD_gpu_octree=OFF -DBUILD_gpu_kinfu_large_scale=OFF -DCUDA_HOST_COMPILER=/usr/bin/clang"
    # keyboard input seems broken in kinfu_app on OX X 10.9
    # this seems to fix it
    cp -n $F $F.ORIG
    sed -e 's/keyUp/keyDown/' $F.ORIG > $F
    mkdir build && cd build
    cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENNI_INCLUDE_DIR=/usr/local/include/ni -DGLEW_INCLUDE_DIR=/usr/X11R6/lib -DCMAKE_BUILD_TYPE=Release -DBUILD_GPU=ON $CUDA_HACK -DBUILD_apps=OFF -DBUILD_examples=OFF ..
    make -j`sysctl -n hw.physicalcpu` # use make VERBOSE=1 ... for detailed messages
    make install
    for d in /usr/local/bin/pcl_*.app; do ln -s $d/Contents/MacOS/pcl_* /usr/local/bin; done
    # It seems that the cmake install target modifies the binaries when it installs them,
    # possibly to strip debug info or something.
    # This should be ok but I am getting "Malformed Mach-o file" when trying to run some (but not all)
    # after this mangling.
    # In particular this seems to be happening with pcl_kinfu_app.
    # So manually copy the un-mangled binaries to /usr/local/bin
    for f in `find bin -not -type d -name "pcl_*"`; do g=`grep ${f##*/}$ install_manifest.txt`; ! [ -x $g ] || cp $f $g; done
    make uninstall
    rm -f /usr/local/bin/pcl_*
    TBD If you get compile errors with c++11 code you might need to make this edit in point_tests.h around line 99:
      template <> inline bool
      isFinite<pcl::BorderDescription> (const pcl::BorderDescription &p)
      {    /* TBD BorderDescription components are ints return (pcl_isfinite (p.x) && pcl_isfinite (p.y)); */   return true;  }
    Note that PCLVisualizer and ImageViewer seem to be only usable from the main thread on OS X.
  • No labels