Setup Boost in Clion

dimitris93 picture dimitris93 · Apr 9, 2016 · Viewed 20.7k times · Source

How to use Boost library in Clion with MinGW ? I have downloaded and unzipped boost_1_60_0.zip to C:\boost_1_60_0. What am I supposed to do now ? Do I have to install something ? Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(server_client)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -s -O3")
set(CMAKE_EXE_LINKER_FLAGS -static)

set(BOOST_ROOT "C:/boost_1_60_0")
set(BOOSTROOT "C:/boost_1_60_0")
find_package(Boost 1.60.0)
if(NOT Boost_FOUND)
    message(FATAL_ERROR "Could not find boost!")
endif()

set(SOURCE_FILES chat_server.cpp)
add_executable(server_client ${SOURCE_FILES})

Can not find Boost:

1

Answer

Hellonearthis picture Hellonearthis · Aug 15, 2016

I use MinGW distro by Stephan T. Lavavej with Boost libraries prebuilt.

In my cmaklist.txt I added this

set(Boost_INCLUDE_DIR c:/mingw/include/)
set(Boost_LIBRARY_DIR c:/mingw/lib/)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})

This post help me get it going. How to include external library (boost) into CLion C++ project with CMake?