You are viewing...

Dabbling in C++, Using Boost

Updated on September 07, 2016 at the 04th hour
Posted under:

DISCLAIMER: Expressed views on this blog are my own.

To start off, I'm using a Mac and you know we have homebrew to install things, so lets use it to use boost in our C++ program.

To install homebrew:
Go to and you follow the instructions to get it

Install boost:
`brew install boost`

Verify boost is installed:
`brew list | grep 'boost'`

Great, once it is verified now we need to include BOOST into our CMake project.

Open up CMakeLists.txt and make sure you have the below (USE C++ 14 PLS):

cmake_minimum_required(VERSION 3.6)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

FIND_PACKAGE(Boost COMPONENTS thread system)



target_link_libraries(TARGET_NAME_HERE ${Boost_LIBRARIES})

Personally, I think FIND_PACKAGE is nice since you do not need to pick a specific directory where boost is installed. It will just search and expose some variables such as Boost_LIBRARIES and Boost_INCLUDE_DIRS that you can use elsewhere. Also, you'll likely want to modify the component included as part of the find.

Alright, now regenerate CMake build with the new settings and boom BOOST is now included.

Try to do this:

to verify that boost is successfully linked and your program can run.

I like to think small steps in learning things take you a long way.
You just read "Dabbling in C++, Using Boost". Please share if you liked it!
You can read more recent posts here.