Skip to content

How to build for Linux

Robert Schumacher edited this page Jan 24, 2017 · 19 revisions

How to setup, build, and run tests on Linux

0. We're in apt-get! Use sudo apt-get install libcpprest-dev to get all our development files. If your distribution has an outdated version, continue on to build from source.

1. Install Ubuntu 14.04 or later.

2. Install all the needed build tools and libraries

sudo apt-get install g++ git make libboost-all-dev libssl-dev cmake

Minimum versions:

  • g++: 4.8
  • libboost: 1.54
  • libssl: 1.0.0

3. Clone the project using Git (it will be stored in the folder "casablanca"):

git clone https://github.com/Microsoft/cpprestsdk.git casablanca

Going forward, you will want to pull from the master branch, which will always contain the last known release.

4. Build the SDK in Debug mode

cd casablanca/Release
mkdir build.debug
cd build.debug
cmake .. -DCMAKE_BUILD_TYPE=Debug
make

You can build the Release version by specifying -DCMAKE_BUILD_TYPE=Release on the cmake line instead.
You can also build the static libraries instead of the shared libraries by adding -DBUILD_SHARED_LIBS=0 on the cmake line above.

5. After building you can run the tests by executing the test_runner inside the "Binaries" folder:

cd Binaries
./test_runner *_test.so

6. To install on your system run: sudo make install

7. You can check your first program by compiling it using necessary command line arguments

g++ -std=c++11 my_file.cpp -o my_file -lboost_system -lcrypto -lssl -lcpprest
./my_file

For versions prior to 2.0, please visit Setup and Build on Linux (1.4)