Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Unofficial installation guide for librealsense with OpenMP support on OSX

Unofficial Installation Guide for librealsense on OSX

These instructions are for how to build librealsense on OSX with OpenMP support.

Install the Dependencies

Setup Brew (the OSX Package Manager)

The easiest way to get everything setup correctly on OSX is to install the dependencies with brew. After pasting the command on the linked website, make sure you read the instructions it reports. Brew may tell you about additional steps you need to take. After following any of the directions it may have stated, you are advised to run

$ brew doctor

Install the Dependencies using Brew

Now that you have brew installed, you need to install the dependencies.

# Install a modern version of CMake
$ brew install cmake

# pkg-config allows us to find libusb
$ brew install pkg-config

# libusb is for transfer protocols
$ brew install libusb

# librealsense on OSX defaults to a libuvc backend
$ brew install libuvc

# Install GLFW3 for OpenGL windows
$ brew install homebrew/versions/glfw3

This guide is written to enable you to install librealsense using OpenMP threading support. You can skip this next step if you decide you do not want threaded support for image conversions / compression operations. Generally speaking, you do want OpenMP support.

# This may take a while to install!
$ brew install llvm

Build librealsense

Acquire librealsense

For this tutorial, you will need to be an administrator on your computer. If you are not, then install it somewhere underneath your home directory instead. We will build librealsense in /opt/librealsense_build, and ultimately install it to /opt/librealsense. You can choose to build / install it anywhere you prefer.

# Go to /opt and clone the repository
sven:~> cd /opt

sven:/opt> sudo git clone librealsense_build
Cloning into 'librealsense_build'...
remote: Counting objects: 34377, done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 34377 (delta 8), reused 19 (delta 5), pack-reused 34347
Receiving objects: 100% (34377/34377), 97.32 MiB | 885.00 KiB/s, done.
Resolving deltas: 100% (24823/24823), done.

Now that you have the repository, give your user ownership of the directory.

sven:/opt> echo $USER

sven:/opt> sudo chown -R sven librealsense_build/

Now that you can modify the directory structure, you are encouraged to checkout a stable release tag rather than building from the master branch. At the time of writing this, the latest stable release is v2.8.0.

sven:/opt> cd librealsense_build/

sven:/opt/librealsense_build> git tag -l

sven:/opt/librealsense_build> git checkout v2.8.0
Note: checking out 'v2.8.0'.


Build librealsense

Assuming you followed the instructions above and performed brew install llvm, we will use this to compile librealsense as it will contain a fully-featured LLVM compiler toolchain, complete with OpenMP support. We set four variables to ensure everything will work correctly when using CMake (skip if you are not building OpenMP support):

sven:/opt/librealsense_build> export CC=/usr/local/opt/llvm/bin/clang
sven:/opt/librealsense_build> export CXX=/usr/local/opt/llvm/bin/clang++
sven:/opt/librealsense_build> export LDFLAGS="-L/usr/local/opt/llvm/lib"
sven:/opt/librealsense_build> export CPPFLAGS="-I/usr/local/opt/llvm/include"

CMake uses the CC and CXX environment variables to determine which compiler to use. The LDFLAGS and CPPFLAGS environment variables will be used to set where the libraries being linked against are (particularly,, and where the C++ standard library headers are.

We can now build librealsense as follows, where you would change CMAKE_INSTALL_PREFIX to wherever you want the final installation to end up.

# Always build projects "out of source"
sven:/opt/librealsense_build> mkdir build

sven:/opt/librealsense_build> cd build

sven:/opt/librealsense_build/build> cmake .. -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=/opt/librealsense
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang -- works
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ -- works
-- Found OpenMP_C: -fopenmp=libomp (found version "3.1")
-- Found OpenMP_CXX: -fopenmp=libomp (found version "3.1")
CMake Warning at CMakeLists.txt:461 (message):
  Using libuvc!

-- Checking for one of the modules 'libusb-1.0'

Assuming the configuration output reports success / uses the compiler you want, we can now build and then install

# First build the library
sven:/opt/librealsense_build/build> make -j 4

# If everything was built correctly, install it recalling that
# in this tutorial we are installing to /opt/librealsense
sven:/opt/librealsense_build/build> sudo make install

Enable librealsense for Other CMake Projects

The reason for building in /opt/librealsense_build, and installing to /opt/librealsense is so that we can make changes or update easily. The default CMAKE_INSTALL_PREFIX is /usr/local, it is generally dangerous to try and selectively delete things from there. In the future, if you want to get a new version (say v2.8.9 was released):

$ cd /opt/librealsense_build

$ git pull

$ git tag -l

# NOTE: does not currently exist, just an example
$ git checkout v2.8.9

You can now delete the entire build directory and start over. The consequence if this strategy is that while it is easier to maintain / update installations, there is nothing currently indicating to other projects that this is where librealsense is installed. If you want to use librealsense in a project, you are encouraged to add the following to your shell configuration file (e.g., your ~/.bashrc):

# Shell access to the built executables (e.g., `realsense-viewer`)
export PATH="/opt/librealsense/bin${PATH:+:${PATH}}"

# Linkage paths for building libraries that depend on `librealsense2`
export LD_LIBRARY_PATH="/opt/librealsense/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
export DYLD_LIBRARY_PATH="/opt/librealsense/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}"

# Allow e.g. `pkg-config --cflags --libs realsense2`
export PKG_CONFIG_PATH="/opt/librealsense/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}"

# Allow for `find_package(realsense2)` in CMake projects
export CMAKE_MODULE_PATH="/opt/librealsense/lib/cmake${CMAKE_MODULE_PATH:+:${CMAKE_MODULE_PATH}}"

This comment has been minimized.

Copy link

@cstamatiadis cstamatiadis commented Sep 18, 2018

Hi, I was trying to follow your guide and did all the steps as you listed them. However, I'm still getting the following error once I try to execute cmake .. -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=/opt/librealsense:

(ml) public-docking-hg-1784:build MacBookProCosta$ cmake .. -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=/opt/librealsense
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
CMake Error at CMakeLists.txt:58 (message):

OpenMP package is missing!

-- Configuring incomplete, errors occurred!
See also "/opt/librealsense_build/build/CMakeFiles/CMakeOutput.log".

I double checked and I followed all the steps. Do you perhaps have any experience with similar issues?

EDIT: If I disable OpenMP when calling CMake things work


This comment has been minimized.

Copy link

@JayMonkey JayMonkey commented Sep 23, 2018

Hi Stephen,

Many thanks for posting this guide, using it I was able to get the librealsense SDK repo compiled and working with my Intel SR300 RealSense Camera on High Sierra 10.13.6 most of the examples work but as the official Wiki states changing any config values usually results in a crash.

Do you know of any projects that are using the librealsense SDK to provide a basic RGB Webcam function that works with native MacOS applications such as FaceTime ... seems to me that if one could take the RGB stream and present it to MacOS in the appropriate format through a driver/kext it should work ... I'd have a go myself but unfortunately i cant find any documentation on what the current MacOS Web cam API is ...

Any pointers or examples would be much appreciated.



This comment has been minimized.

Copy link

@spk921 spk921 commented Apr 26, 2019

Hi JayMonkey,

I am using D435i with USB2.0 port. The problem is I was not able to get the RGB stream.
Also, it only works with USB2.0 port, not USB3.0 have you able to get both RGB and DEPTH stream?
Is there is any firmware update needed? Also, I was not able to run the R300 as well.
Could you help?


This comment has been minimized.

Copy link

@gezabohus gezabohus commented Jun 2, 2020

One more thanks for posting this. Got my setup working with T265 and D435.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment