Eelmises osas saime Boost C++ näite tööle MSYS2 MinGW-ga. Nüüd proovime sama asja siis Linuxiga. Avan käsurea ja annan käsklused:

cd ~/git-gtest/boostdemo/linux-build
cmake ..

Tulemus: 

 

Otsustan praeguse boost eemaldada ja panna käsitsi praegusel hetkel kõige uuema:

sudo apt-get --purge remove libboost-dev
sudo apt-get --purge remove libboost-all-dev
sudo apt-get autoremove
cd
mkdir boost-src
cd boost-src
wget -O boost_1_59_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download
tar xzvf boost_1_59_0.tar.gz
cd boost_1_59_0/
sudo apt-get update
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev
./bootstrap.sh --prefix=/usr/local ./b2

Tulemus:

 

Peame nüüd muutma fali 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() 

if(NOT WIN32)
	SET (BOOST_INCLUDEDIR "/home/tiit/boost-src/boost_1_59_0")
	SET (BOOST_LIBRARYDIR "/home/tiit/boost-src/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()
if(NOT WIN32)
	target_link_libraries(${PROJECT_NAME_STR} 
	${Boost_LIBRARY_DIRS}/libboost_serialization.a
	)
endif()

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

Annan nüüd käsklused:

cd ~/git-gtest/boostdemo/linux-build
cmake ..
make
./boostdemo

Tulemus:

 

Viited:

http://askubuntu.com/questions/397939/how-to-uninstall-boost-1-49-and-install-boost-1-54-in-ubuntu

http://stackoverflow.com/questions/12578499/how-to-install-boost-on-ubuntu