Martin embarked on an intriguing journey to set up the Facebook Folly C++ libraries on his Ubuntu machine. Let’s dive into the steps he took to make it all work seamlessly.

Step 1: Acquiring the Source Code

Martin initiated his process by obtaining `master.zip` from [this GitHub link](https://github.com/facebook/folly/archive/master.zip). After downloading, he extracted its contents, which paved the way for a new directory named `/home/martin/folly-master`.

Step 2: Setting the Groundwork – Installing Prerequisites

Without hesitation, Martin referred to the `README.md` and began installing the necessary prerequisites. Interestingly, he found that he already had many of them on his system. Here’s a snapshot of the commands he used:

```bash
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: The Building Phase

Getting hands-on, Martin began the building process using these commands:

```bash

autoreconf -ivf

./configure

make

sudo make install

```

However, a minor hiccup occurred. He couldn’t execute `make check` due to some alterations in Google Test, so he simply bypassed this part.

Step 4: Organizing the Header Files

With utmost precision, Martin copied the header files to specific directories:

```bash

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

```

Although uncertain about the need to copy headers from `detail`, Martin decided it was best to err on the side of caution.

Step 5: Integrating the Libraries

To ensure the libraries were integrated perfectly, Martin performed these commands:

```bash

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: The Final Test

The moment of truth arrived. Martin penned down a simple program, `hello.cpp`, with the primary aim of greeting the Folly World:

```cpp

include <iostream>

include <folly/FBString.h>

int main()

{

    folly::fbstring str("Hello, Folly World!");

    std::cout << str << "\n";

}

```

He then compiled it using `g++ hello.cpp -o hello -lfolly` and ran it with `./hello`. The screen echoed back “Hello, Folly World!”, marking a triumphant end to his endeavor.

Conclusion 

In the end, Martin’s meticulous efforts bore fruit as he successfully set up the Facebook Folly C++ libraries on his Ubuntu system. His journey, replete with careful steps and minor obstacles, serves as a testament to his dedication and an excellent guide for others embarking on a similar path. It goes to show that with the right approach and attention to detail, one can seamlessly integrate even the most complex libraries into their system. Truly, Martin’s experience is both inspiring and instructive.

Leave a Reply