0

I am a complete beginner in C++ programming and have been advised to use CLion. I am trying to get the Boost package to work.

I found many posts and tutorials online, however they all skip the basics not known to someone who is not a programmer. Namely, there is no explanation of how to get from the moment you open a new project to using some function from the Boost package?

This is what I found to be lacking from previous answers:

  1. Here we are advised to use live incboost live template, however there is no explanation on where to find it or how to use it.

  2. Here seems like a clear tutorial, however it is aimed at Visual Studio, not CLion.

  3. Here I am not sure what each of those files are and how to adjust them to match my case.

I have downloaded boost_1_70_0 from https://www.boost.org/users/download/ and it is now unzipped and saved in C:\...\boost_1_70_0.

Could someone please explain really simply how to get from a blank project to being able to use functions stored in boost?

Kivis
  • 924
  • 2
  • 10
  • 20

1 Answers1

0

Considering you are using CLion and it supports only CMake at this time and you have installed BOOST library in the default directory, then your CMakeLists.txt file should look like this. I have used it in linux operating system but it should be able in Windows too.

cmake_minimum_required(VERSION 3.13)
project(LaserCV)

set(CMAKE_CXX_STANDARD 17)

#local
file(GLOB SOURCES
        *.hpp
        *.cpp
        )


add_executable(LaserCV ${SOURCE_FILES} ${SOURCES})
#add_executable(LaserCV main.cpp)
SET(CMAKE_CXX_FLAGS -pthread)

#boost
find_package(Boost REQUIRED)
target_link_libraries(LaserCV ${Boost_LIBRARIES})
include_directories(${Boost_INCLUDE_DIR})

Then simply include a header file for your wanted boost function, for example:

#include <boost/random.hpp>
Cactus'as
  • 70
  • 10