Ich verbrachte buchstäblich gute 6 Stunden damit und schaute überall im Internet.C++ CMake kann Boost 1.63 (mit CLion IDE) nicht finden
Hier ist was ich getan habe. Ich bin unter Windows 10 mit JetBrain CLion IDE. Direkt heruntergeladen MinGW 5.3, nicht über CodeBlocks. Lade Boost 1.63 herunter und entpacke es. Ran bootstrap.bat gcc
und b2.exe toolset=gcc
um es zu bauen. Während der Installation erschien gcc-mingw-5.3.0
tonnenweise, also nehme ich an, dass sie jetzt irgendwie miteinander verbunden sind. Dann erschien ein neuer Ordner C:/Boost
, der nur zwei Ordner enthielt: include und lib.
Hier ist meine CMakeList.txt:
cmake_minimum_required(VERSION 3.7)
project(BoostTest)
set(CMAKE_CXX_STANDARD 11)
set(Boost_INCLUDE_DIR C:/Boost/include)
set(BOOST_LIBRARY_DIR C:/Boost/lib)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
set(SOURCE_FILES main.cpp)
add_executable(BoostTest ${SOURCE_FILES})
Da das ursprüngliche Verzeichnis (die ich aus dem Download entpackt) Verzeichnisse include
und lib
Namen nicht hat, ich dachte, ich mit dem Verzeichnis, das von der Installation erstellt gehen sollte (oder Gebäude). Dann habe ich diesen Fehler:
CMake Error at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1169 (file):
file STRINGS file "C:/Boost/include/boost/version.hpp" cannot be read.
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
CMake Warning at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version 0
Call Stack (most recent call first):
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:8 (find_package)
CMake Warning at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version 0
Call Stack (most recent call first):
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:8 (find_package)
CMake Error at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1793 (message):
Unable to find the requested Boost libraries.
Boost version: 0.0.0
Boost include path: C:/Boost/include
Could not find the following Boost libraries:
boost_system
boost_filesystem
No Boost libraries were found. You may need to 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:8 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Workspace_cpp/BoostTest/cmake-build-debug/CMakeFiles/CMakeOutput.log".
Sie sehen, ist CMake irgendwie in der Lage diese version.hpp
Datei zu erreichen, aber es nicht lesen kann. Ich habe ziemlich viele Leute gesehen, die dieselbe Frage gestellt haben, aber keine ihrer Lösungen hat für mich funktioniert. Ich habe versucht, INCLUDE_DIR
und LIBRARY_DIR
in das ursprüngliche Verzeichnis zu setzen, und nicht ein wenig helfen. Ich bin wirklich frustriert. Ich schätze jede Hilfe sehr. Vielen Dank!
Update: Vielen Dank oLen für den Hinweis! Es war hilfreich. Ich habe meine CMakeList.txt aktualisiert werden:
set(BOOST_ROOT C:/Boost)
set(BOOST_INCLUDEDIR C:/Boost/include)
set(BOOST_LIBRARYDIR C:/Boost/lib)
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
Allerdings ist mir eine neue Fehlermeldung angezeigt:
"D:\Program Files (x86)\JetBrains\CLion 2017.1\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Workspace_cpp\BoostTest
CMake Warning at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:744 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:848 (_Boost_COMPONENT_DEPENDENCIES)
D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1435 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:9 (find_package)
CMake Error at D:/Program Files (x86)/JetBrains/CLion 2017.1/bin/cmake/share/cmake-3.7/Modules/FindBoost.cmake:1793 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:9 (find_package)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Boost_INCLUDE_DIR (ADVANCED)
Ich denke, es erfolgreich das Verzeichnis kann aber nicht verarbeiten. Ich bitte um Entschuldigung, diese Fehler machen für mich absolut keinen Sinn. Darf ich auch wissen, ob ich Boost bauen sollte, bevor ich es benutze, da es auf der offiziellen Boost Get Started Seite nicht heißt es zu bauen. Die Fehlermeldung will mich auch an set BOOST_INCLUDE_DIR
. Könnten Sie bitte etwas mehr Licht werfen? Ich danke dir sehr.