Setting up Facebook Folly on Ubuntu

This is how I installed the Facebook Folly C++ libraries on Ubuntu.

Step 1: The source

I downloaded master.zip from https://github.com/facebook/folly/archive/master.zip and unzipped it, creating the directory /home/martin/folly-master.

Step 2: Install prerequisites

I just installed everything mentioned in the README.md. I had most of these already:

sudo apt-get install \
    g++ \
    automake \
    autoconf \
    autoconf-archive \
    libtool \
    libboost-all-dev \
    libevent-dev \
    libdouble-conversion-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    liblz4-dev \
    liblzma-dev \
    libsnappy-dev \
    make \
    zlib1g-dev \
    binutils-dev \
    libjemalloc-dev \
    libssl-dev
    libunwind8-dev \
    libelf-dev \
    libdwarf-dev
    libiberty-dev

Step 3: Build

autoreconf -ivf
./configure
make
sudo make install

I couldn’t get make check to work because Google Test has changed, so I skipped that step.

Step 4: Install header files

sudo mkdir /usr/include/folly
sudo mkdir /usr/include/folly/detail
sudo cp /home/martin/folly-master/folly/*.h /usr/include/folly
sudo cp /home/martin/folly-master/folly/detail/*.h /usr/include/folly/detail
sudo cp -r /home/martin/folly-master/folly/compatibility /usr/include/folly

I’m not sure if copying the header files from detail was necessary, but it doesn’t do any harm.

Step 5: Install the libraries

sudo cp /home/martin/folly-master/folly/.libs/libfolly.so.57.0.0 /usr/local/lib
cd /usr/local/lib
sudo ln -s libfolly.so.57.0.0 libfolly.so
sudo ln -s libfolly.so.57.0.0 libfolly.so.57
sudo ldconfig -v

Step 6: Try it

I wrote this program in hello.cpp:

#include <iostream>
#include <folly/FBString.h>

int main()
{
    folly::fbstring str("Hello, Folly World!");
    std::cout << str << "\n";
}

I compiled it like this:

g++ hello.cpp -o hello -lfolly

Finally, I ran it:

./hello
Hello, Folly World!

Success!