Product, Use Cases

How to build Apache Mesos on Mac OSX with the Eclipse IDE

Apr 20, 2015



5 min read

By Marco Massenzio, Distributed Systems Engineer
  1. Familiarize yourself with the Apache Mesos Getting started guide or see my guide.
  2. Follow the Gist instructions I put together, explaining how to to build Mesos on your Mac.
  3. Install and configure the Eclipse IDE.
At this point I assume you have a fully built, functioning Apache Mesos distribution on your laptop, residing in:
 export MESOS_HOME=/path/to/mesos
Prepare your Mac OSX Dev Environment
Start by installing XCode and the Command Line Tools via Apple's AppStore. This will take a while, so relax and go grab a coffee or something.
Then, you'llneed to install homebrew, if you haven't already done so. Run which brew and see what comes up. Then, the autotools:
  ruby -e "$(curl -fsSL"
  brew install git bash-completion maven  brew install autoconf automake libtool subversion
Note: you might need to install Python 3 as it doesn't come by default in Yosemite. While you're at it, you may also want to also install Google Test; this is optional: the Mesos distribution brings along its own copy of gtest and will use that on to test itself – make check.
At this point you should be ready to build and test Apache Mesos:
    ./bootstrap    mkdir build    cd build    ../configure --disable-python --disable-java    make    make check
Note: I've disabled building the Python and Java extensions as this speeds up compilation significantly. Not to mention other gory details around getting Maven setup and other Java-specific stuff (another day, another post ;).
Setup your Project in Eclipse
All going well, you should now be ready to set up Apache Mesos in Eclipse. I based the following instructions on what my colleague Bernd shared on Stack Overflow:
  1. Open Eclipse. Select "File → Import… → Git → Projects from Git".
  2. Select "Existing local repository".
  3. Click on "Add…" and add your local Mesos git directory ($MESOS_HOME). It will show up in the list in the selector box from step 4.
  4. Select the entry for your directory and click on "Next".
  5. Select "Import as general project" and click on "Next".
  6. Give your project a name and click on "Finish". Now you have a project.
  7. Make sure you are in the C++ perspective. Select/highlight your project in the Project Explorer. Then select "File → New… → Convert to a C/C++ Autotools project".
  8. Edit your project's properties (Select project, Cmd-I). On the pane "C/C++ Build", add /build to the value of "Build directory". It should look like this: ${workspace_loc:/myProjectName}/build
  9. In pane "Autotools" go to "Configure Settings → Advanced". Under "Additional command line options" you must add -with-svn=/usr/local and can optionally put –disable-python –disable-java too, if you don't want to build Python and Java-related stuff every time. 
  10. Add /usr/local/include and /usr/local/include/subversion-1 to the "Include directories" in Project Settings (you will need to right-click on the Project's root node: there is no way to get to this page via Eclipse Preferences).
If you want to build the Java components, add the following to C/C++ Build/Environment:
add MAVEN_HOME = /usr/local/Cellar/maven/3.3.1
Above assumes you have installed Maven via brew – adjust as appropriate for your environment.
Finally, configure the C++ indexer: Eclipse → Preferences → C/C++ → Indexer: make sure "Enable indexer" is checked; "Index source files not included in the build" and "Index unused headers" must be checked; and, optionally, both "Automatically update the index" and "Update index immediately after file-save" should be checked. Also, give its cache plenty of RAM (e.g., 640MB).
Now for the fun part: you must configure a bunch of symbolic links to point from /usr/local/include to the right places. Make sure you have the following entries in your include path (actual path will vary on your system):
export MESOS_HOME=/path/to/mesosexport GTEST_HOME=/path/to/gtest-1.7.0
and create the following symbolic links from /usr/local/include to these targes:
boost -> $MESOS_HOME/build/3rdparty/libprocess/3rdparty/boost-1.53.0/boostc++11 -> /Applications/ -> $MESOS_HOME/build/3rdparty/libprocess/3rdparty/glog-0.3.3/src/gloggoogle -> $MESOS_HOME/build/3rdparty/libprocess/3rdparty/protobuf-2.5.0/src/googlegtest -> $GTEST_HOME/include/gtestjni.h -> /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.hlibltdl -> ../Cellar/libtool/2.4.6/include/libltdlltdl.h -> ../Cellar/libtool/2.4.6/include/ltdl.hmesospicojson.hprocessstoutsubversion-1 -> ../Cellar/subversion/1.8.13/include/subversion-1
Note: picojson.h must be manually copied to /usr/local/include.
After you do that, click Ok, you should expand the "Includes" node in the Project tree and see something similar to the one shown above.
Build Mesos
All going well, you should now be able to Build the project (hit the "hammer" icon) and see autotools progress in the Console view (make sure to select CDT Global Build Console from the dropdown in the Console View's terminal icon.
Build a C++ Framework
Create a new "Hello World" C++ Project, make sure to select the "OSX GCC Toolchain" and then repeat the same steps above to add /usr/local/include to the "Includes" directories; you will then have to add to the libraries for your linker to pick up:
If you have a Unittests configuration, you can add gtest (libgtest.a), too.
At this point, the "framework" project can successfully include from <mesos/executor.hpp> and do something like:
#include <mesos/executor.hpp>
class MongoExecutor : public mesos::Executor{ public:        MongoExecutor() {}        virtual ~MongoExecutor();};
without causing any syntax errors.
If you want to try a simple example, you can git clone my sample mongo_fw project like so:
git clone
This should build against the just-built, and then you can execute (once you have Master/Slave up and running) with:
./mongo_fw $hostname:5050
Make sure you have a working MongoDB Server installed and that you update the location of the configuration file.
Last but not least, beware of Eclipse configuring the toolchain to be the "Cross gcc" (instead of OSX gcc) – it won't build the binaries; see here for more details.

Ready to get started?