我試圖導入Boost 1.61.0(從SourceForge - Boost 1.61.0下載爲.7z),但失敗。將Boost 1.61.0導入到C++項目時出錯
控制檯:
"D:\Program Files (x86)\JetBrains\CLion 2016.2\bin\cmake\bin\cmake.exe" --build C:\Users\Marczak\.CLion2016.2\system\cmake\generated\WsServer-e351c9f9\e351c9f9\Debug --target WsServer -- -j 4
[ 50%] Linking CXX executable WsServer.exe
CMakeFiles\WsServer.dir\build.make:96: recipe for target 'WsServer.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/WsServer.dir/all' failed
CMakeFiles\WsServer.dir/objects.a(main.cpp.obj): In function `_static_initialization_and_destruction_0':
C:/Users/Marczak/boost_1_61_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
C:/Users/Marczak/boost_1_61_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/Users/Marczak/boost_1_61_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [WsServer.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/WsServer.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/WsServer.dir/rule] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/WsServer.dir/rule' failed
mingw32-make.exe: *** [WsServer] Error 2
Makefile:117: recipe for target 'WsServer' failed
的CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(WsServer)
set(BOOST_ROOT "C:/Users/Marczak/boost_1_61_0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(SOURCE_FILES src/main.cpp)
find_package(Boost)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(WsServer ${SOURCE_FILES})
如果我做find_package(Boost 1.61.0 COMPONENTS system filesystem REQUIRED)
我得到:
Error: Unable to find the requested Boost libraries.
Boost version: 1.61.0
Boost include path: C:/Users/Marczak/boost_1_61_0
Could not find the following static 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.
我試圖設置Boost_USE_STATIC_LIBRARIES
,但是失敗了。我使用CLion 2016.2。
更新:我也試過舊版本。同樣的錯誤。什麼是.7z壓縮內部:
在其他議題我看到lib
文件夾。但在這裏我沒有看到它。我應該輸入BOOST_LIBRARYDIR
?
UPDATE 2:從https://sourceforge.net/projects/boost/files/boost-binaries/1.61.0/安裝的二進制文件。我注意到有新的文件夾:lib64-msvc-14.0
。它包含許多.dll和.lib文件,例如boost_atomic-vc140-mt-1_61.dll
。
Boost.org說:
如果您打算使用工具從Windows命令提示符下,你在正確的地方。如果你打算從Cygwin bash shell構建,你實際上是在一個POSIX平臺上運行,並且應該按照說明開始使用Unix變體。其他命令shell,如MinGW的MSYS,不支持 - 它們可能會或可能不會工作。
我會嘗試使用Cygwin。
你用這裏使用的任何編譯器編譯boost嗎?聽起來就像是剛剛在'C:/ Users/Marczak/boost_1_61_0'上提取了源代碼' – drescherjm
@drescherjm號。我是C++新手。如何編譯它? –
也許爲mingw增加一個二進制下載對你會更好。有了這個說法,我不確定什麼編譯器/工具包'CLion'在windows下使用。它是mingw/gcc? – drescherjm