在 Clion 中设置 Boost

2021-12-24 00:00:00 mingw c++ boost clion

如何在 Clion 和 MinGW 中使用 Boost 库?我已将

解决方案

我使用 MinGW 发行版Stephan T. Lavavej 预建了 Boost 库.

在我的 cmaklist.txt 中我添加了这个

set(Boost_INCLUDE_DIR c:/mingw/include/)设置(Boost_LIBRARY_DIR c:/mingw/lib/)find_package(需要提升组件系统文件系统)包含目录(${Boost_INCLUDE_DIR})

这篇文章帮助我开始.如何使用 CMake 将外部库 (boost) 包含到 CLion C++ 项目中?

How to use Boost library in Clion with MinGW ? I have downloaded and unzipped boost_1_60_0.zip to C:oost_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:

解决方案

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?

相关文章