問題を再現するには... download Boost、次にbooststrap
とb2 --build-dir=C:\Users\xxx\Downloads\my_boost_build_dir --prefix=C:\Users\xxx\Downloads\my_boost_install_dir --layout=system variant=release link=static install
を実行します。すべてが今のところとても良いようです。指定された接頭辞(インストール)ディレクトリには、headersとlibsが入力されます。MSVC build Boost but Cmake findBoostは機能しませんか?
しかし、ここで問題が起こり始めるところです。私は、次のcmakeのファイル...
find_package(Boost REQUIRED)
message("Boost_FOUND" ${Boost_FOUND})
message("Boost_INCLUDE_DIRS" ${Boost_INCLUDE_DIRS})
message("Boost_LIBRARY_DIRS" ${Boost_LIBRARY_DIRS})
message("Boost_LIBRARIES" ${Boost_LIBRARIES})
message("Boost_CHRONO_FOUND" ${Boost_CHRONO_FOUND})
message("Boost_CHRONO_LIBRARY" ${Boost_CHRONO_LIBRARY})
add_executable(main main.cpp)
target_link_libraries(main PRIVATE Boost::boost Boost::chrono)
を書く...と私はブーストへのパスとそれを構成するcmake .. -DCMAKE_PREFIX_PATH=C:\Users\xxx\Downloads\my_boost_install_dir
ディレクトリをインストールした場合、私は...
Boost_FOUND1
Boost_INCLUDE_DIRSC:/Users/xxx/Downloads/my_boost_install_dir/include
Boost_LIBRARY_DIRSC:/Users/xxx/Downloads/my_boost_install_dir/lib
Boost_LIBRARIES
Boost_CHRONO_FOUND
Boost_CHRONO_LIBRARY
-- Configuring done
CMake Error at CMakeLists.txt:14 (add_executable):
Target "main" links to target "Boost::chrono" but the target was not found.
Perhaps a find_package() call is missing for an IMPORTED target, or an
ALIAS target is missing?
を次のように出力し、エラーを取得します
Boostが見つかりました.includeとlibディレクトリが見つかりましたが、chronoライブラリ(および他のすべてのライブラリ)は見つかりませんでした。私のコンポーネントに明示的に名前を付ける必要があるかもしれませんか?だから私は、代わりにこのcmakeの...
find_package(Boost REQUIRED COMPONENTS chrono)
message("Boost_FOUND" ${Boost_FOUND})
message("Boost_INCLUDE_DIRS" ${Boost_INCLUDE_DIRS})
message("Boost_LIBRARY_DIRS" ${Boost_LIBRARY_DIRS})
message("Boost_LIBRARIES" ${Boost_LIBRARIES})
message("Boost_CHRONO_FOUND" ${Boost_CHRONO_FOUND})
message("Boost_CHRONO_LIBRARY" ${Boost_CHRONO_LIBRARY})
add_executable(main main.cpp)
target_link_libraries(main PRIVATE Boost::boost Boost::chrono)
を試してみました。しかし、これは次のように出力し、エラーを生成します。前と同様に
CMake Error at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1877 (message):
Unable to find the requested Boost libraries.
Boost version: 1.64.0
Boost include path: C:/Users/xxx/Downloads/my_boost_install_dir/include
Could not find the following Boost libraries:
boost_chrono
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:5 (find_package)
Boost_FOUND0
Boost_INCLUDE_DIRSC:/Users/xxx/Downloads/my_boost_install_dir/include
Boost_LIBRARY_DIRS
Boost_LIBRARIES
Boost_CHRONO_FOUND
Boost_CHRONO_LIBRARY
、それはブーストとヘッダを見つけましたが、何らかの理由でそれがライブラリを見つけることができません。
ブーストの「クロノ」コンポーネントが必要な場合は、それを 'find_package'コールで指定します:' find_package(Boost REQUIRED chrono) '。質問をクリーンアップしてください:以前の問題が解決されたので、それに対応するテキストを削除してください(現在の問題を記述するために必要でない限り)。 Stack Overflowは、投稿の以前のコンテンツを表示したいすべての人物の編集履歴を保持します。 – Tsyvarev
@Tsyvarev質問を整理してコンポーネントのリストを表示しようとしましたが、それでも問題は解決しませんでした。 : -/ –
あなたは '.lib'ファイルを持っているので、' find_package() 'の前に' Boost_USE_STATIC_LIBS'をONに設定する必要があります。 – Tsyvarev