Eelmises osas saime Boost C++ näite tööle Visual Studioga. Nüüd üritame sama teha MSYS2 MinGW-ga.

Avan MinGW-w64 Win32 Shell.

pacman -sS boost annab tulemuseks:

Seega annan käsklused:

pacman -S mingw-w64-i686-boost
pacman -S mingw-w64-x86_64-boost

Peame jällegi täiendama faili CMakeLists.txt

cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)

set(PROJECT_NAME_STR boostdemo)
project(${PROJECT_NAME_STR} C CXX)
MESSAGE("PROJECT_SOURCE_DIR:${PROJECT_SOURCE_DIR}")
MESSAGE("PROJECT_BINARY_DIR:${PROJECT_BINARY_DIR}")

if(MSVC)
SET (BOOST_ROOT "C:/boost_1_59_0")
SET (BOOST_INCLUDEDIR "C:/boost_1_59_0/boost")
SET (BOOST_LIBRARYDIR "C:/boost_1_59_0/stage/lib")
endif() 

SET (BOOST_MIN_VERSION "1.59.0")
set (Boost_NO_BOOST_CMAKE ON)
FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)
if (NOT Boost_FOUND)
  message(FATAL_ERROR "Fatal error: Boost (version >= 1.59) required.")
else()
  message(STATUS "Setting up BOOST")
  message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
  message(STATUS " Library  - ${Boost_LIBRARY_DIRS}")
  include_directories(${Boost_INCLUDE_DIRS})
  link_directories(${Boost_LIBRARY_DIRS})
endif (NOT Boost_FOUND)

include_directories(include)
file(GLOB SOURCES src/*.cpp include/*.h)

add_executable(${PROJECT_NAME_STR} ${SOURCES})

if(MINGW)
	target_link_libraries(${PROJECT_NAME_STR} 
	${Boost_LIBRARY_DIRS}/libboost_serialization-mt.a
	)
endif()

set_property(TARGET ${PROJECT_NAME_STR} PROPERTY CXX_STANDARD_REQUIRED ON)
set_property(TARGET ${PROJECT_NAME_STR} PROPERTY CXX_STANDARD 14)

Anname käsklused:

cd ~/git-gtest/boostdemo/mingw-build
cmake .. -G "MinGW Makefiles"
mingw32-make
./boostdemo.exe

Tulemus: