Skip to content

Latest commit

 

History

History

1.4.InstallUnderMacOS

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Table of contents

This tutorial is part of OpenSceneGraph cross-platform guide.

In this tutorial we install OpenSceneGraph under macOS and take a look at the cube with osgviewer tool.

Note: this tutorial requires OpenSceneGraph model created in 1.1. Create a cube.

YouTube | Download

Video depicts OpenSceneGraph installation under macOS El Capitan (10.11).

Note: steps below use frames from the video as screenshots. Watch the video to see all details.

Screenshot

Xcode is an integrated development environment for macOS. It contains C/C++ compiler that we will use to build OpenSceneGraph.

Screenshot

You need a valid Apple ID to download Xcode.

Screenshot

Choose the latest Xcode version that suits your macOS version. In case of El Capitan, it's Xcode 8.2.

Screenshot

Move Xcode from Downloads directory into Applications directory. This lets CMake, which we install later, find Xcode development tools without additional help.

Screenshot

Since Xcode has been downloaded from the Internet, macOS first verifies the file. This may take up some time.

Screenshot

Since Xcode has been downloaded from the Internet, macOS needs your permission to open the file.

Screenshot

Accept Xcode and iOS SDK license agreement to be able to use the product.

Screenshot

Provide your password to allow Xcode to install necessary additional components like Git and xcodebuild.

Close Xcode after it has been launched.

Screenshot

Find OpenSceneGraph repository at the website.

Screenshot

Get the latest copy of OpenSceneGraph with the following command:

git clone https://github.com/openscenegraph/OpenSceneGraph.git

Screenshot

OpenSceneGraph uses CMake build system, which supports out-of-source builds. We create a build directory to keep generated (built) content separate from the original source.

Screenshot

Find CMake and download its macOS version.

Screenshot

Launch downloaded dmg package and follow instructions to install CMake.

Screenshot

Open CMake.

Screenshot

Build directory is the one we created to host binaries.

Source directory is the one where we cloned OpenSceneGraph using Git.

Screenshot

Before we can build OpenSceneGraph, we need to configure the build. Do it by pressing Configure button.

Make sure to select Xcode generator when prompted.

Screenshot

By default, OpenSceneGraph libraries are installed into /usr/local/lib, which is not where libraries usually reside.

However, macOS El Capitan is aware of /usr/local/lib location, so we don't need to do anything about it.

Screenshot

Press Generate to generate Xcode specific project file.

Screenshot

We are finally ready to build OpenSceneGraph with the following command:

xcodebuild -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=6 -target install -configuration Release

xcodebuild is a command line utility to build Xcode projects. Of course, we could use Xcode itself, but then this tutorial would be a lot longer.

Here's a brief overview of the parameters we used:

  • -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=6 requests 6 parallel jobs to speed up the build process;
  • -target install makes installation phase start right after the building one;
  • -configuration Release strips binaries of debug information, which we don't need in this tutorial.

Screenshot

Installation failed, because xcodebuild needs administrative privileges to install OpenSceneGraph into /usr/local/lib.

Screenshot

Run xcodebuild with administrative privileges using the following command:

sudo xcodebuild -IDEBuildOperationMaxNumberOfConcurrentCompileTasks=6 -target install -configuration Release

Make sure to provide your password for sudo when prompted.

Screenshot

Finally, take a look at the cube with osgviewer:

/usr/local/bin/osgviewer /path/to/box.osgt