CMake: Using Boost v1.69 with MSVC on Windows












0














I'm trying to use the Boost library in my C++ project on Windows using CLion and MinGWMSVC. I downloaded the precompiled binaries here and extracted everything to C:localboost_1_69_0_b1_rc3. I setup the following CMakeLists.txt:



cmake_minimum_required(VERSION 3.11.4)
project(BoostTesting)

set(CMAKE_CXX_STANDARD 17)

set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1")
set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_DEBUG ON)
set(Boost_DETAILED_FAILURE_MSG ON)
set(Boost_COMPILER "-vc141")
set(Boost_ARCHITECTURE "-x64")

find_package(Boost 1.69.0 COMPONENTS filesystem REQUIRED)

if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(BoostTesting main.cpp)
target_link_libraries(BoostTesting ${Boost_LIBRARIES})
endif ()


Using CMake's FindBoost debug mode (Boost_DEBUG) I got the following output:



C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe" "-DCMAKE_C_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe" -G "CodeBlocks - MinGW Makefiles" D:CppBoostTesting
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe
-- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:18 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

Environment variable Boost_ROOT is set to:

C:localboost_1_68_0boost

For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.

-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1125 ] _boost_TEST_VERSIONS =
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1127 ] Boost_USE_MULTITHREADED = ON
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1129 ] Boost_USE_STATIC_LIBS = ON
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1131 ] Boost_USE_STATIC_RUNTIME = OFF
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1133 ] Boost_ADDITIONAL_VERSIONS =
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1135 ] Boost_NO_SYSTEM_PATHS =
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1203 ] Declared as CMake or Environmental Variables:
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1205 ] BOOST_ROOT = C:/local/boost_1_69_0_b1_rc3
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1207 ] BOOST_INCLUDEDIR = C:/local/boost_1_69_0_b1_rc3/boost
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1209 ] BOOST_LIBRARYDIR = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1211 ] _boost_TEST_VERSIONS =
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1286 ] Include debugging info:
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1288 ] _boost_INCLUDE_SEARCH_DIRS = C:/local/boost_1_69_0_b1_rc3/boost;C:/local/boost_1_69_0_b1_rc3/include;C:/local/boost_1_69_0_b1_rc3;PATHS;C:/boost/include;C:/boost;/sw/local/include
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1290 ] _boost_PATH_SUFFIXES =
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1310 ] location of version.hpp: C:/local/boost_1_69_0_b1_rc3/boost/version.hpp
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1334 ] version.hpp reveals boost 1.69.0
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1410 ] using user-specified Boost_COMPILER = -vc141
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1430 ] _boost_MULTITHREADED = -mt
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1506 ] _boost_RELEASE_ABI_TAG = -
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1508 ] _boost_DEBUG_ABI_TAG = -d
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1571 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:18 (find_package)


CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:18 (find_package)


-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for FILESYSTEM_LIBRARY_RELEASE: libboost_filesystem-vc141-mt-1_69;libboost_filesystem-vc141-mt;libboost_filesystem-mt-1_69;libboost_filesystem-mt;libboost_filesystem
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for FILESYSTEM_LIBRARY_DEBUG: libboost_filesystem-vc141-mt-d-1_69;libboost_filesystem-vc141-mt-d;libboost_filesystem-mt-d-1_69;libboost_filesystem-mt-d;libboost_filesystem-mt;libboost_filesystem
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc141-mt-1_69;libboost_system-vc141-mt;libboost_system-mt-1_69;libboost_system-mt;libboost_system
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc141-mt-d-1_69;libboost_system-vc141-mt-d;libboost_system-mt-d-1_69;libboost_system-mt-d;libboost_system-mt;libboost_system
-- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1887 ] Boost_FOUND = 1
CMake Error at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:2048 (message):
Unable to find the requested Boost libraries.

Boost version: 1.69.0

Boost include path: C:/local/boost_1_69_0_b1_rc3

Could not find the following static Boost libraries:

boost_filesystem

Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:18 (find_package)


-- Configuring incomplete, errors occurred!
See also "D:/Cpp/BoostTesting/cmake-build-debug/CMakeFiles/CMakeOutput.log".

[Failed to reload]


CMake is looking for those specific files but I noticed that the -x64 indication is not part of the searched file names. My directory only contains 64-bit libraries:





Why is the Boost_ARCHITECTURE environment variable ignored? I expect it to add the missing -x64 to the searched file names. If I manually rename the libboost_filesystem-vc141-mt*.lib files they can be found by CMake. However, if I compile and link my simple main.cpp I'm getting a linker error:



====================[ Build | BoostTesting | Debug ]============================
C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting -- -j 4
Scanning dependencies of target BoostTesting
[ 50%] Building CXX object CMakeFiles/BoostTesting.dir/main.cpp.obj
[100%] Linking CXX executable BoostTesting.exe
CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::path_traits::convert(char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&)':
C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path::codecvt()'
C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::file_size(boost::filesystem::path const&)':
C:/local/boost_1_69_0_b1_rc3/boost/filesystem/operations.hpp:616: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFilesBoostTesting.dirbuild.make:88: BoostTesting.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFilesMakefile2:72: CMakeFiles/BoostTesting.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFilesMakefile2:84: CMakeFiles/BoostTesting.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: BoostTesting] Error 2


main.cpp source code:



#include <iostream>
#include <boost/filesystem.hpp>

using namespace boost::filesystem;

int main(int argc, char *argv) {
if (argc < 2) {
std::cout << "Usage: tut1 pathn";
return 1;
}
std::cout << argv[1] << " " << file_size(argv[1]) << 'n';
return 0;
}


I'm pretty sure renaming the files is not the proper way of doing it. But even this way it doesn't work. What am I doing wrong and how do you properly use Boost in a simple C++ project like this one?










share|improve this question





























    0














    I'm trying to use the Boost library in my C++ project on Windows using CLion and MinGWMSVC. I downloaded the precompiled binaries here and extracted everything to C:localboost_1_69_0_b1_rc3. I setup the following CMakeLists.txt:



    cmake_minimum_required(VERSION 3.11.4)
    project(BoostTesting)

    set(CMAKE_CXX_STANDARD 17)

    set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
    set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1")
    set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")

    set(Boost_USE_STATIC_LIBS ON)
    set(Boost_USE_MULTITHREADED ON)
    set(Boost_USE_STATIC_RUNTIME OFF)
    set(Boost_DEBUG ON)
    set(Boost_DETAILED_FAILURE_MSG ON)
    set(Boost_COMPILER "-vc141")
    set(Boost_ARCHITECTURE "-x64")

    find_package(Boost 1.69.0 COMPONENTS filesystem REQUIRED)

    if (Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS})
    add_executable(BoostTesting main.cpp)
    target_link_libraries(BoostTesting ${Boost_LIBRARIES})
    endif ()


    Using CMake's FindBoost debug mode (Boost_DEBUG) I got the following output:



    C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe" "-DCMAKE_C_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe" -G "CodeBlocks - MinGW Makefiles" D:CppBoostTesting
    -- The C compiler identification is GNU 8.1.0
    -- The CXX compiler identification is GNU 8.1.0
    -- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe
    -- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe
    -- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    CMake Warning (dev) at CMakeLists.txt:18 (find_package):
    Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
    Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
    command to set the policy and suppress this warning.

    Environment variable Boost_ROOT is set to:

    C:localboost_1_68_0boost

    For compatibility, CMake is ignoring the variable.
    This warning is for project developers. Use -Wno-dev to suppress it.

    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1125 ] _boost_TEST_VERSIONS =
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1127 ] Boost_USE_MULTITHREADED = ON
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1129 ] Boost_USE_STATIC_LIBS = ON
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1131 ] Boost_USE_STATIC_RUNTIME = OFF
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1133 ] Boost_ADDITIONAL_VERSIONS =
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1135 ] Boost_NO_SYSTEM_PATHS =
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1203 ] Declared as CMake or Environmental Variables:
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1205 ] BOOST_ROOT = C:/local/boost_1_69_0_b1_rc3
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1207 ] BOOST_INCLUDEDIR = C:/local/boost_1_69_0_b1_rc3/boost
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1209 ] BOOST_LIBRARYDIR = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1211 ] _boost_TEST_VERSIONS =
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1286 ] Include debugging info:
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1288 ] _boost_INCLUDE_SEARCH_DIRS = C:/local/boost_1_69_0_b1_rc3/boost;C:/local/boost_1_69_0_b1_rc3/include;C:/local/boost_1_69_0_b1_rc3;PATHS;C:/boost/include;C:/boost;/sw/local/include
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1290 ] _boost_PATH_SUFFIXES =
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1310 ] location of version.hpp: C:/local/boost_1_69_0_b1_rc3/boost/version.hpp
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1334 ] version.hpp reveals boost 1.69.0
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1410 ] using user-specified Boost_COMPILER = -vc141
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1430 ] _boost_MULTITHREADED = -mt
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1506 ] _boost_RELEASE_ABI_TAG = -
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1508 ] _boost_DEBUG_ABI_TAG = -d
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1571 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
    CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
    New Boost version may have incorrect or missing dependencies and imported
    targets
    Call Stack (most recent call first):
    C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
    C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
    CMakeLists.txt:18 (find_package)


    CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
    New Boost version may have incorrect or missing dependencies and imported
    targets
    Call Stack (most recent call first):
    C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
    C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
    CMakeLists.txt:18 (find_package)


    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for FILESYSTEM_LIBRARY_RELEASE: libboost_filesystem-vc141-mt-1_69;libboost_filesystem-vc141-mt;libboost_filesystem-mt-1_69;libboost_filesystem-mt;libboost_filesystem
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for FILESYSTEM_LIBRARY_DEBUG: libboost_filesystem-vc141-mt-d-1_69;libboost_filesystem-vc141-mt-d;libboost_filesystem-mt-d-1_69;libboost_filesystem-mt-d;libboost_filesystem-mt;libboost_filesystem
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc141-mt-1_69;libboost_system-vc141-mt;libboost_system-mt-1_69;libboost_system-mt;libboost_system
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc141-mt-d-1_69;libboost_system-vc141-mt-d;libboost_system-mt-d-1_69;libboost_system-mt-d;libboost_system-mt;libboost_system
    -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1887 ] Boost_FOUND = 1
    CMake Error at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:2048 (message):
    Unable to find the requested Boost libraries.

    Boost version: 1.69.0

    Boost include path: C:/local/boost_1_69_0_b1_rc3

    Could not find the following static Boost libraries:

    boost_filesystem

    Some (but not all) of the required Boost libraries were found. You may
    need to install these additional Boost libraries. Alternatively, set
    BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
    to the location of Boost.
    Call Stack (most recent call first):
    CMakeLists.txt:18 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "D:/Cpp/BoostTesting/cmake-build-debug/CMakeFiles/CMakeOutput.log".

    [Failed to reload]


    CMake is looking for those specific files but I noticed that the -x64 indication is not part of the searched file names. My directory only contains 64-bit libraries:





    Why is the Boost_ARCHITECTURE environment variable ignored? I expect it to add the missing -x64 to the searched file names. If I manually rename the libboost_filesystem-vc141-mt*.lib files they can be found by CMake. However, if I compile and link my simple main.cpp I'm getting a linker error:



    ====================[ Build | BoostTesting | Debug ]============================
    C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting -- -j 4
    Scanning dependencies of target BoostTesting
    [ 50%] Building CXX object CMakeFiles/BoostTesting.dir/main.cpp.obj
    [100%] Linking CXX executable BoostTesting.exe
    CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::path_traits::convert(char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&)':
    C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path::codecvt()'
    C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
    CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::file_size(boost::filesystem::path const&)':
    C:/local/boost_1_69_0_b1_rc3/boost/filesystem/operations.hpp:616: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make.exe[3]: *** [CMakeFilesBoostTesting.dirbuild.make:88: BoostTesting.exe] Error 1
    mingw32-make.exe[2]: *** [CMakeFilesMakefile2:72: CMakeFiles/BoostTesting.dir/all] Error 2
    mingw32-make.exe[1]: *** [CMakeFilesMakefile2:84: CMakeFiles/BoostTesting.dir/rule] Error 2
    mingw32-make.exe: *** [Makefile:117: BoostTesting] Error 2


    main.cpp source code:



    #include <iostream>
    #include <boost/filesystem.hpp>

    using namespace boost::filesystem;

    int main(int argc, char *argv) {
    if (argc < 2) {
    std::cout << "Usage: tut1 pathn";
    return 1;
    }
    std::cout << argv[1] << " " << file_size(argv[1]) << 'n';
    return 0;
    }


    I'm pretty sure renaming the files is not the proper way of doing it. But even this way it doesn't work. What am I doing wrong and how do you properly use Boost in a simple C++ project like this one?










    share|improve this question



























      0












      0








      0







      I'm trying to use the Boost library in my C++ project on Windows using CLion and MinGWMSVC. I downloaded the precompiled binaries here and extracted everything to C:localboost_1_69_0_b1_rc3. I setup the following CMakeLists.txt:



      cmake_minimum_required(VERSION 3.11.4)
      project(BoostTesting)

      set(CMAKE_CXX_STANDARD 17)

      set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
      set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1")
      set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")

      set(Boost_USE_STATIC_LIBS ON)
      set(Boost_USE_MULTITHREADED ON)
      set(Boost_USE_STATIC_RUNTIME OFF)
      set(Boost_DEBUG ON)
      set(Boost_DETAILED_FAILURE_MSG ON)
      set(Boost_COMPILER "-vc141")
      set(Boost_ARCHITECTURE "-x64")

      find_package(Boost 1.69.0 COMPONENTS filesystem REQUIRED)

      if (Boost_FOUND)
      include_directories(${Boost_INCLUDE_DIRS})
      add_executable(BoostTesting main.cpp)
      target_link_libraries(BoostTesting ${Boost_LIBRARIES})
      endif ()


      Using CMake's FindBoost debug mode (Boost_DEBUG) I got the following output:



      C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe" "-DCMAKE_C_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe" -G "CodeBlocks - MinGW Makefiles" D:CppBoostTesting
      -- The C compiler identification is GNU 8.1.0
      -- The CXX compiler identification is GNU 8.1.0
      -- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe
      -- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe -- works
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe
      -- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe -- works
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      CMake Warning (dev) at CMakeLists.txt:18 (find_package):
      Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
      Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
      command to set the policy and suppress this warning.

      Environment variable Boost_ROOT is set to:

      C:localboost_1_68_0boost

      For compatibility, CMake is ignoring the variable.
      This warning is for project developers. Use -Wno-dev to suppress it.

      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1125 ] _boost_TEST_VERSIONS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1127 ] Boost_USE_MULTITHREADED = ON
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1129 ] Boost_USE_STATIC_LIBS = ON
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1131 ] Boost_USE_STATIC_RUNTIME = OFF
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1133 ] Boost_ADDITIONAL_VERSIONS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1135 ] Boost_NO_SYSTEM_PATHS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1203 ] Declared as CMake or Environmental Variables:
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1205 ] BOOST_ROOT = C:/local/boost_1_69_0_b1_rc3
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1207 ] BOOST_INCLUDEDIR = C:/local/boost_1_69_0_b1_rc3/boost
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1209 ] BOOST_LIBRARYDIR = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1211 ] _boost_TEST_VERSIONS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1286 ] Include debugging info:
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1288 ] _boost_INCLUDE_SEARCH_DIRS = C:/local/boost_1_69_0_b1_rc3/boost;C:/local/boost_1_69_0_b1_rc3/include;C:/local/boost_1_69_0_b1_rc3;PATHS;C:/boost/include;C:/boost;/sw/local/include
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1290 ] _boost_PATH_SUFFIXES =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1310 ] location of version.hpp: C:/local/boost_1_69_0_b1_rc3/boost/version.hpp
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1334 ] version.hpp reveals boost 1.69.0
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1410 ] using user-specified Boost_COMPILER = -vc141
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1430 ] _boost_MULTITHREADED = -mt
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1506 ] _boost_RELEASE_ABI_TAG = -
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1508 ] _boost_DEBUG_ABI_TAG = -d
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1571 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
      CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
      New Boost version may have incorrect or missing dependencies and imported
      targets
      Call Stack (most recent call first):
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
      CMakeLists.txt:18 (find_package)


      CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
      New Boost version may have incorrect or missing dependencies and imported
      targets
      Call Stack (most recent call first):
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
      CMakeLists.txt:18 (find_package)


      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for FILESYSTEM_LIBRARY_RELEASE: libboost_filesystem-vc141-mt-1_69;libboost_filesystem-vc141-mt;libboost_filesystem-mt-1_69;libboost_filesystem-mt;libboost_filesystem
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for FILESYSTEM_LIBRARY_DEBUG: libboost_filesystem-vc141-mt-d-1_69;libboost_filesystem-vc141-mt-d;libboost_filesystem-mt-d-1_69;libboost_filesystem-mt-d;libboost_filesystem-mt;libboost_filesystem
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc141-mt-1_69;libboost_system-vc141-mt;libboost_system-mt-1_69;libboost_system-mt;libboost_system
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc141-mt-d-1_69;libboost_system-vc141-mt-d;libboost_system-mt-d-1_69;libboost_system-mt-d;libboost_system-mt;libboost_system
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1887 ] Boost_FOUND = 1
      CMake Error at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:2048 (message):
      Unable to find the requested Boost libraries.

      Boost version: 1.69.0

      Boost include path: C:/local/boost_1_69_0_b1_rc3

      Could not find the following static Boost libraries:

      boost_filesystem

      Some (but not all) of the required Boost libraries were found. You may
      need to install these additional Boost libraries. Alternatively, set
      BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
      to the location of Boost.
      Call Stack (most recent call first):
      CMakeLists.txt:18 (find_package)


      -- Configuring incomplete, errors occurred!
      See also "D:/Cpp/BoostTesting/cmake-build-debug/CMakeFiles/CMakeOutput.log".

      [Failed to reload]


      CMake is looking for those specific files but I noticed that the -x64 indication is not part of the searched file names. My directory only contains 64-bit libraries:





      Why is the Boost_ARCHITECTURE environment variable ignored? I expect it to add the missing -x64 to the searched file names. If I manually rename the libboost_filesystem-vc141-mt*.lib files they can be found by CMake. However, if I compile and link my simple main.cpp I'm getting a linker error:



      ====================[ Build | BoostTesting | Debug ]============================
      C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting -- -j 4
      Scanning dependencies of target BoostTesting
      [ 50%] Building CXX object CMakeFiles/BoostTesting.dir/main.cpp.obj
      [100%] Linking CXX executable BoostTesting.exe
      CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::path_traits::convert(char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&)':
      C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path::codecvt()'
      C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
      CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::file_size(boost::filesystem::path const&)':
      C:/local/boost_1_69_0_b1_rc3/boost/filesystem/operations.hpp:616: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
      collect2.exe: error: ld returned 1 exit status
      mingw32-make.exe[3]: *** [CMakeFilesBoostTesting.dirbuild.make:88: BoostTesting.exe] Error 1
      mingw32-make.exe[2]: *** [CMakeFilesMakefile2:72: CMakeFiles/BoostTesting.dir/all] Error 2
      mingw32-make.exe[1]: *** [CMakeFilesMakefile2:84: CMakeFiles/BoostTesting.dir/rule] Error 2
      mingw32-make.exe: *** [Makefile:117: BoostTesting] Error 2


      main.cpp source code:



      #include <iostream>
      #include <boost/filesystem.hpp>

      using namespace boost::filesystem;

      int main(int argc, char *argv) {
      if (argc < 2) {
      std::cout << "Usage: tut1 pathn";
      return 1;
      }
      std::cout << argv[1] << " " << file_size(argv[1]) << 'n';
      return 0;
      }


      I'm pretty sure renaming the files is not the proper way of doing it. But even this way it doesn't work. What am I doing wrong and how do you properly use Boost in a simple C++ project like this one?










      share|improve this question















      I'm trying to use the Boost library in my C++ project on Windows using CLion and MinGWMSVC. I downloaded the precompiled binaries here and extracted everything to C:localboost_1_69_0_b1_rc3. I setup the following CMakeLists.txt:



      cmake_minimum_required(VERSION 3.11.4)
      project(BoostTesting)

      set(CMAKE_CXX_STANDARD 17)

      set(BOOST_ROOT "C:/local/boost_1_69_0_b1_rc3")
      set(BOOST_LIBRARYDIR "C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1")
      set(BOOST_INCLUDEDIR "C:/local/boost_1_69_0_b1_rc3/boost")

      set(Boost_USE_STATIC_LIBS ON)
      set(Boost_USE_MULTITHREADED ON)
      set(Boost_USE_STATIC_RUNTIME OFF)
      set(Boost_DEBUG ON)
      set(Boost_DETAILED_FAILURE_MSG ON)
      set(Boost_COMPILER "-vc141")
      set(Boost_ARCHITECTURE "-x64")

      find_package(Boost 1.69.0 COMPONENTS filesystem REQUIRED)

      if (Boost_FOUND)
      include_directories(${Boost_INCLUDE_DIRS})
      add_executable(BoostTesting main.cpp)
      target_link_libraries(BoostTesting ${Boost_LIBRARIES})
      endif ()


      Using CMake's FindBoost debug mode (Boost_DEBUG) I got the following output:



      C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe" "-DCMAKE_C_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe" -G "CodeBlocks - MinGW Makefiles" D:CppBoostTesting
      -- The C compiler identification is GNU 8.1.0
      -- The CXX compiler identification is GNU 8.1.0
      -- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe
      -- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gcc.exe -- works
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe
      -- Check for working CXX compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-g++.exe -- works
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      CMake Warning (dev) at CMakeLists.txt:18 (find_package):
      Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
      Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
      command to set the policy and suppress this warning.

      Environment variable Boost_ROOT is set to:

      C:localboost_1_68_0boost

      For compatibility, CMake is ignoring the variable.
      This warning is for project developers. Use -Wno-dev to suppress it.

      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1125 ] _boost_TEST_VERSIONS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1127 ] Boost_USE_MULTITHREADED = ON
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1129 ] Boost_USE_STATIC_LIBS = ON
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1131 ] Boost_USE_STATIC_RUNTIME = OFF
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1133 ] Boost_ADDITIONAL_VERSIONS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1135 ] Boost_NO_SYSTEM_PATHS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1203 ] Declared as CMake or Environmental Variables:
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1205 ] BOOST_ROOT = C:/local/boost_1_69_0_b1_rc3
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1207 ] BOOST_INCLUDEDIR = C:/local/boost_1_69_0_b1_rc3/boost
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1209 ] BOOST_LIBRARYDIR = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1211 ] _boost_TEST_VERSIONS =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1286 ] Include debugging info:
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1288 ] _boost_INCLUDE_SEARCH_DIRS = C:/local/boost_1_69_0_b1_rc3/boost;C:/local/boost_1_69_0_b1_rc3/include;C:/local/boost_1_69_0_b1_rc3;PATHS;C:/boost/include;C:/boost;/sw/local/include
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1290 ] _boost_PATH_SUFFIXES =
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1310 ] location of version.hpp: C:/local/boost_1_69_0_b1_rc3/boost/version.hpp
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1334 ] version.hpp reveals boost 1.69.0
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1410 ] using user-specified Boost_COMPILER = -vc141
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1430 ] _boost_MULTITHREADED = -mt
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1506 ] _boost_RELEASE_ABI_TAG = -
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1508 ] _boost_DEBUG_ABI_TAG = -d
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1571 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib_boost_LIBRARY_SEARCH_DIRS_DEBUG = C:/local/boost_1_69_0_b1_rc3/lib64-msvc-14.1;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;C:/local/boost_1_69_0_b1_rc3/lib;C:/local/boost_1_69_0_b1_rc3/../lib;C:/local/boost_1_69_0_b1_rc3/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
      CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
      New Boost version may have incorrect or missing dependencies and imported
      targets
      Call Stack (most recent call first):
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
      CMakeLists.txt:18 (find_package)


      CMake Warning at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:847 (message):
      New Boost version may have incorrect or missing dependencies and imported
      targets
      Call Stack (most recent call first):
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:963 (_Boost_COMPONENT_DEPENDENCIES)
      C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1622 (_Boost_MISSING_DEPENDENCIES)
      CMakeLists.txt:18 (find_package)


      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for FILESYSTEM_LIBRARY_RELEASE: libboost_filesystem-vc141-mt-1_69;libboost_filesystem-vc141-mt;libboost_filesystem-mt-1_69;libboost_filesystem-mt;libboost_filesystem
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for FILESYSTEM_LIBRARY_DEBUG: libboost_filesystem-vc141-mt-d-1_69;libboost_filesystem-vc141-mt-d;libboost_filesystem-mt-d-1_69;libboost_filesystem-mt-d;libboost_filesystem-mt;libboost_filesystem
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1760 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc141-mt-1_69;libboost_system-vc141-mt;libboost_system-mt-1_69;libboost_system-mt;libboost_system
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1813 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc141-mt-d-1_69;libboost_system-vc141-mt-d;libboost_system-mt-d-1_69;libboost_system-mt-d;libboost_system-mt;libboost_system
      -- [ C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:1887 ] Boost_FOUND = 1
      CMake Error at C:/Users/User/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/183.4284.104/bin/cmake/win/share/cmake-3.12/Modules/FindBoost.cmake:2048 (message):
      Unable to find the requested Boost libraries.

      Boost version: 1.69.0

      Boost include path: C:/local/boost_1_69_0_b1_rc3

      Could not find the following static Boost libraries:

      boost_filesystem

      Some (but not all) of the required Boost libraries were found. You may
      need to install these additional Boost libraries. Alternatively, set
      BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
      to the location of Boost.
      Call Stack (most recent call first):
      CMakeLists.txt:18 (find_package)


      -- Configuring incomplete, errors occurred!
      See also "D:/Cpp/BoostTesting/cmake-build-debug/CMakeFiles/CMakeOutput.log".

      [Failed to reload]


      CMake is looking for those specific files but I noticed that the -x64 indication is not part of the searched file names. My directory only contains 64-bit libraries:





      Why is the Boost_ARCHITECTURE environment variable ignored? I expect it to add the missing -x64 to the searched file names. If I manually rename the libboost_filesystem-vc141-mt*.lib files they can be found by CMake. However, if I compile and link my simple main.cpp I'm getting a linker error:



      ====================[ Build | BoostTesting | Debug ]============================
      C:UsersUserAppDataLocalJetBrainsToolboxappsCLionch-0183.4284.104bincmakewinbincmake.exe --build D:CppBoostTestingcmake-build-debug --target BoostTesting -- -j 4
      Scanning dependencies of target BoostTesting
      [ 50%] Building CXX object CMakeFiles/BoostTesting.dir/main.cpp.obj
      [100%] Linking CXX executable BoostTesting.exe
      CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::path_traits::convert(char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&)':
      C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path::codecvt()'
      C:/local/boost_1_69_0_b1_rc3/boost/filesystem/path.hpp:997: undefined reference to `boost::filesystem::path_traits::convert(char const*, char const*, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&, std::codecvt<wchar_t, char, int> const&)'
      CMakeFilesBoostTesting.dir/objects.a(main.cpp.obj): In function `boost::filesystem::file_size(boost::filesystem::path const&)':
      C:/local/boost_1_69_0_b1_rc3/boost/filesystem/operations.hpp:616: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
      collect2.exe: error: ld returned 1 exit status
      mingw32-make.exe[3]: *** [CMakeFilesBoostTesting.dirbuild.make:88: BoostTesting.exe] Error 1
      mingw32-make.exe[2]: *** [CMakeFilesMakefile2:72: CMakeFiles/BoostTesting.dir/all] Error 2
      mingw32-make.exe[1]: *** [CMakeFilesMakefile2:84: CMakeFiles/BoostTesting.dir/rule] Error 2
      mingw32-make.exe: *** [Makefile:117: BoostTesting] Error 2


      main.cpp source code:



      #include <iostream>
      #include <boost/filesystem.hpp>

      using namespace boost::filesystem;

      int main(int argc, char *argv) {
      if (argc < 2) {
      std::cout << "Usage: tut1 pathn";
      return 1;
      }
      std::cout << argv[1] << " " << file_size(argv[1]) << 'n';
      return 0;
      }


      I'm pretty sure renaming the files is not the proper way of doing it. But even this way it doesn't work. What am I doing wrong and how do you properly use Boost in a simple C++ project like this one?







      c++ visual-c++ boost cmake






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 17:49

























      asked Nov 19 at 12:43









      BullyWiiPlaza

      5,82924655




      5,82924655
























          2 Answers
          2






          active

          oldest

          votes


















          3














          I believe find_package(Boost ...) has failed in your case as it won't be able to find the REQUIRED filesystem library for 64-bit GCC.



          Make sure you have the GCC build of Boost available as well, because now you're only showing the V++ libraries.






          share|improve this answer





















          • There are no GCC compiled binaries for Windows and I just want to use the provided MSVC libraries. Isn't that possible?
            – BullyWiiPlaza
            Nov 19 at 12:53










          • @BullyWiiPlaza I am pretty sure you need to compile boost using mingw. Thankfully its not difficult to build boost.
            – drescherjm
            Nov 19 at 13:08












          • @BullyWiiPlaza You'll need to build it. GCC and MSVC are not ABI compatible.
            – rubenvb
            Nov 19 at 13:22



















          0














          It turns out it works when using the MinGW distribution with built-in Boost.



          CMakeLists.txt:



          cmake_minimum_required(VERSION 3.11.4)
          project(BoostTesting)

          set(CMAKE_CXX_STANDARD 17)

          if(WIN32)
          set(BOOST_ROOT "C:/MinGW")
          endif ()

          find_package(Boost 1.67.0 COMPONENTS filesystem REQUIRED)

          if (Boost_FOUND)
          include_directories(${Boost_INCLUDE_DIRS})
          add_executable(BoostTesting main.cpp)
          target_link_libraries(BoostTesting ${Boost_LIBRARIES})
          endif ()


          main.cpp output:



          D:CppBoostTestingcmake-build-debugBoostTesting.exe
          Usage: tut1 path

          Process finished with exit code 1


          It compiled and linked successfully.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374910%2fcmake-using-boost-v1-69-with-msvc-on-windows%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            I believe find_package(Boost ...) has failed in your case as it won't be able to find the REQUIRED filesystem library for 64-bit GCC.



            Make sure you have the GCC build of Boost available as well, because now you're only showing the V++ libraries.






            share|improve this answer





















            • There are no GCC compiled binaries for Windows and I just want to use the provided MSVC libraries. Isn't that possible?
              – BullyWiiPlaza
              Nov 19 at 12:53










            • @BullyWiiPlaza I am pretty sure you need to compile boost using mingw. Thankfully its not difficult to build boost.
              – drescherjm
              Nov 19 at 13:08












            • @BullyWiiPlaza You'll need to build it. GCC and MSVC are not ABI compatible.
              – rubenvb
              Nov 19 at 13:22
















            3














            I believe find_package(Boost ...) has failed in your case as it won't be able to find the REQUIRED filesystem library for 64-bit GCC.



            Make sure you have the GCC build of Boost available as well, because now you're only showing the V++ libraries.






            share|improve this answer





















            • There are no GCC compiled binaries for Windows and I just want to use the provided MSVC libraries. Isn't that possible?
              – BullyWiiPlaza
              Nov 19 at 12:53










            • @BullyWiiPlaza I am pretty sure you need to compile boost using mingw. Thankfully its not difficult to build boost.
              – drescherjm
              Nov 19 at 13:08












            • @BullyWiiPlaza You'll need to build it. GCC and MSVC are not ABI compatible.
              – rubenvb
              Nov 19 at 13:22














            3












            3








            3






            I believe find_package(Boost ...) has failed in your case as it won't be able to find the REQUIRED filesystem library for 64-bit GCC.



            Make sure you have the GCC build of Boost available as well, because now you're only showing the V++ libraries.






            share|improve this answer












            I believe find_package(Boost ...) has failed in your case as it won't be able to find the REQUIRED filesystem library for 64-bit GCC.



            Make sure you have the GCC build of Boost available as well, because now you're only showing the V++ libraries.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 19 at 12:49









            rubenvb

            52.6k22136257




            52.6k22136257












            • There are no GCC compiled binaries for Windows and I just want to use the provided MSVC libraries. Isn't that possible?
              – BullyWiiPlaza
              Nov 19 at 12:53










            • @BullyWiiPlaza I am pretty sure you need to compile boost using mingw. Thankfully its not difficult to build boost.
              – drescherjm
              Nov 19 at 13:08












            • @BullyWiiPlaza You'll need to build it. GCC and MSVC are not ABI compatible.
              – rubenvb
              Nov 19 at 13:22


















            • There are no GCC compiled binaries for Windows and I just want to use the provided MSVC libraries. Isn't that possible?
              – BullyWiiPlaza
              Nov 19 at 12:53










            • @BullyWiiPlaza I am pretty sure you need to compile boost using mingw. Thankfully its not difficult to build boost.
              – drescherjm
              Nov 19 at 13:08












            • @BullyWiiPlaza You'll need to build it. GCC and MSVC are not ABI compatible.
              – rubenvb
              Nov 19 at 13:22
















            There are no GCC compiled binaries for Windows and I just want to use the provided MSVC libraries. Isn't that possible?
            – BullyWiiPlaza
            Nov 19 at 12:53




            There are no GCC compiled binaries for Windows and I just want to use the provided MSVC libraries. Isn't that possible?
            – BullyWiiPlaza
            Nov 19 at 12:53












            @BullyWiiPlaza I am pretty sure you need to compile boost using mingw. Thankfully its not difficult to build boost.
            – drescherjm
            Nov 19 at 13:08






            @BullyWiiPlaza I am pretty sure you need to compile boost using mingw. Thankfully its not difficult to build boost.
            – drescherjm
            Nov 19 at 13:08














            @BullyWiiPlaza You'll need to build it. GCC and MSVC are not ABI compatible.
            – rubenvb
            Nov 19 at 13:22




            @BullyWiiPlaza You'll need to build it. GCC and MSVC are not ABI compatible.
            – rubenvb
            Nov 19 at 13:22













            0














            It turns out it works when using the MinGW distribution with built-in Boost.



            CMakeLists.txt:



            cmake_minimum_required(VERSION 3.11.4)
            project(BoostTesting)

            set(CMAKE_CXX_STANDARD 17)

            if(WIN32)
            set(BOOST_ROOT "C:/MinGW")
            endif ()

            find_package(Boost 1.67.0 COMPONENTS filesystem REQUIRED)

            if (Boost_FOUND)
            include_directories(${Boost_INCLUDE_DIRS})
            add_executable(BoostTesting main.cpp)
            target_link_libraries(BoostTesting ${Boost_LIBRARIES})
            endif ()


            main.cpp output:



            D:CppBoostTestingcmake-build-debugBoostTesting.exe
            Usage: tut1 path

            Process finished with exit code 1


            It compiled and linked successfully.






            share|improve this answer




























              0














              It turns out it works when using the MinGW distribution with built-in Boost.



              CMakeLists.txt:



              cmake_minimum_required(VERSION 3.11.4)
              project(BoostTesting)

              set(CMAKE_CXX_STANDARD 17)

              if(WIN32)
              set(BOOST_ROOT "C:/MinGW")
              endif ()

              find_package(Boost 1.67.0 COMPONENTS filesystem REQUIRED)

              if (Boost_FOUND)
              include_directories(${Boost_INCLUDE_DIRS})
              add_executable(BoostTesting main.cpp)
              target_link_libraries(BoostTesting ${Boost_LIBRARIES})
              endif ()


              main.cpp output:



              D:CppBoostTestingcmake-build-debugBoostTesting.exe
              Usage: tut1 path

              Process finished with exit code 1


              It compiled and linked successfully.






              share|improve this answer


























                0












                0








                0






                It turns out it works when using the MinGW distribution with built-in Boost.



                CMakeLists.txt:



                cmake_minimum_required(VERSION 3.11.4)
                project(BoostTesting)

                set(CMAKE_CXX_STANDARD 17)

                if(WIN32)
                set(BOOST_ROOT "C:/MinGW")
                endif ()

                find_package(Boost 1.67.0 COMPONENTS filesystem REQUIRED)

                if (Boost_FOUND)
                include_directories(${Boost_INCLUDE_DIRS})
                add_executable(BoostTesting main.cpp)
                target_link_libraries(BoostTesting ${Boost_LIBRARIES})
                endif ()


                main.cpp output:



                D:CppBoostTestingcmake-build-debugBoostTesting.exe
                Usage: tut1 path

                Process finished with exit code 1


                It compiled and linked successfully.






                share|improve this answer














                It turns out it works when using the MinGW distribution with built-in Boost.



                CMakeLists.txt:



                cmake_minimum_required(VERSION 3.11.4)
                project(BoostTesting)

                set(CMAKE_CXX_STANDARD 17)

                if(WIN32)
                set(BOOST_ROOT "C:/MinGW")
                endif ()

                find_package(Boost 1.67.0 COMPONENTS filesystem REQUIRED)

                if (Boost_FOUND)
                include_directories(${Boost_INCLUDE_DIRS})
                add_executable(BoostTesting main.cpp)
                target_link_libraries(BoostTesting ${Boost_LIBRARIES})
                endif ()


                main.cpp output:



                D:CppBoostTestingcmake-build-debugBoostTesting.exe
                Usage: tut1 path

                Process finished with exit code 1


                It compiled and linked successfully.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 19 at 21:50

























                answered Nov 19 at 13:22









                BullyWiiPlaza

                5,82924655




                5,82924655






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374910%2fcmake-using-boost-v1-69-with-msvc-on-windows%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)