Building the demo
The first moment of truth: let’s see if your newly-fetched demo builds!
At this point we assume that your working directory contains the sources for the Derecho SOSP tutorial’s demo. If it doesn’t, these instructions won’t work for you: go back to getting the files first! If you’re coming from the VM instructions, then you should already have a terminal open to the correct directory.
Starting with CMake
The Derecho project (including this tutorial!) is built via the CMake
build system. CMake has many benefits, but the major one we’ll see in
this tutorial is out-of-source builds. Unlike a traditional build
environment, CMake can keep all the compiled code in a separate
directory from the source files and include files. This is pretty great!
Let’s take advantage of this out of source build now, by making a new
build
directory in which we’ll build our project.
$ mkdir build
$ cd build
Please note that scripts used in this tutorial will assume that you’ve
chosen to perform an out-of-source build in a directory named build
,
so please do not choose a different name for your build directory.
From here, we’ll use CMake to configure our build environment in this directory. We’ll enable debugging for this build, which might come in handy during the coding part of the tutorial:
$ cmake -DCMAKE_BUILD_TYPE=Debug ../
-- The CXX compiler identification is GNU 8.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Protobuf: /usr/lib/libprotobuf.so;-lpthread (found version "3.8.0")
-- Using protobuf
-- Found OpenCV: /usr (found version "3.4.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /some/directory/path
Note the messages printed here might vary slightly depending on your
installations of Derecho’s dependencies. By default CMake will use
Makefiles to build your project. On some very new installations,
CMake will default to ninja
instead.1 Either way, it’s time to build
your project. Go ahead and type make -j
here:
$ make -j
[ 12%] Generating ../generated/function_tier.pb.h, ../generated/function_tier.pb.cc, ../generated/function_tier.grpc.pb.h, ../generated/function_tier.grpc.pb.cc
Scanning dependencies of target sospdemo
[ 25%] Building CXX object src/CMakeFiles/sospdemo.dir/function_tier.cpp.o
[ 37%] Building CXX object src/CMakeFiles/sospdemo.dir/main.cpp.o
[ 50%] Building CXX object src/CMakeFiles/sospdemo.dir/categorizer_tier.cpp.o
[ 62%] Building CXX object src/CMakeFiles/sospdemo.dir/blob.cpp.o
[ 75%] Building CXX object src/CMakeFiles/sospdemo.dir/__/generated/function_tier.pb.cc.o
[ 87%] Building CXX object src/CMakeFiles/sospdemo.dir/__/generated/function_tier.grpc.pb.cc.o
[100%] Linking CXX executable sospdemo
[100%] Built target sospdemo
…And you’re done! Demo built. Next up: running the demo
- If the
cmake
command succeeded but themake
command complained about a lack of Makefiles thencmake
might have producedninja
files instead ofMakefiles
. Try runningninja
. [return]