找不到以下Boost库:boost_fiber

时间:2018-10-25 10:34:45

标签: c++ boost cmake coroutine

我对加速不熟悉。我想在boost中使用该类,例如boost :: context :: fiber和boost :: context :: continuation。因此,我下载了Boost 1.68的最新版本。通过官方网站上的instruction进行构建。

首先,运行引导程序并生成b2文件。

$ ./bootstrap.sh --with-libraries=all --prefix=/usr/local/boost_168_build

然后通过安装运行它。

@--:/usr/local/boost_1_68_0$ ./b2 --show-libraries
The following libraries require building:
- atomic
- chrono
- container
- context
- contract
- coroutine
- date_time
- exception
- fiber
- filesystem
- graph
- graph_parallel
- iostreams
- locale
- log
- math
- mpi
- program_options
- python
- random
- regex
- serialization
- signals
- stacktrace
- system
- test
- thread
- timer
- type_erasure
- wave
@--:/usr/local/boost_1_68_0$ sudo ./b2 install

然后我做一个cmake项目来创建一个Cmakelist。

cmake_minimum_required(VERSION 3.12)
project(boost_context)

set(Boost_USE_STATIC_LIBS        OFF) # only find static libs
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)

set(CMAKE_CXX_STANDARD 11)

set (BOOST_ROOT
    "/usr/local/boost_1_68_0")
set (BOOST_LIBRARYDIR
    "/usr/local/boost_1_68_0/lib")

find_package( Boost REQUIRED COMPONENTS context fiber)
if(Boost_FOUND)
ADD_DEFINITIONS( "-DHAS_BOOST" )
message(STATUS ${Boost_INCLUDE_DIRS})
#    include_directories(${Boost_INCLUDE_DIRS})
message(STATUS ${Boost_LIBRARIES})
message(STATUS ${BOOST_LIBRARYDIR})
message(STATUS ${Boost_LIBRARIES})
message(STATUS ${Boost_LIBRARIES})
message(STATUS ${Boost_LIBRARIES})
endif()

add_executable(boost_context main.cpp)

但是当我打开Boost_USE_STATIC_LIBS时 cmake将报告:

/clion-2018.2.5/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" 
/Other_Project/boost-context
CMake Error at /clion-2018.2.5/bin/cmake/linux/share/cmake-
3.12/Modules/FindBoost.cmake:2048 (message):
Unable to find the requested Boost libraries.

Boost version: 1.68.0

Boost include path: /usr/local/boost_168_build/include

Could not find the following static Boost libraries:

      boost_fiber

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:15 (find_package)

关闭Boost_USE_STATIC_LIBS cmake将报告:

/clion-2018.2.5/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Other_Project/boost-context
CMake Error at /clion-2018.2.5/bin/cmake/linux/share/cmake-3.12/Modules/FindBoost.cmake:2048 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.68.0

  Boost include path: /usr/local/boost_168_build/include

  Could not find the following Boost libraries:

          boost_fiber

  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:15 (find_package)

最后,您知道我对为什么能找到它感到真正的困惑吗?

@--0:/usr/local/boost_168_build/include/boost/fiber$ pwd
/usr/local/boost_168_build/include/boost/fiber
@--0:/usr/local/boost_168_build/include/boost/fiber$ ls
algo                   condition_variable.hpp  fiber.hpp            hip             pooled_fixedsize_stack.hpp     scheduler.hpp
all.hpp                context.hpp             fixedsize_stack.hpp  mutex.hpp       properties.hpp                 segmented_stack.hpp
barrier.hpp            cuda                    fss.hpp              numa            protected_fixedsize_stack.hpp  timed_mutex.hpp
buffered_channel.hpp   detail                  future               operations.hpp  recursive_mutex.hpp            type.hpp
channel_op_status.hpp  exceptions.hpp          future.hpp           policy.hpp      recursive_timed_mutex.hpp      unbuffered_channel.hpp

但是lib中没有任何纤维或延续性

@--0:/usr/local/boost_168_build/lib$ pwd
/usr/local/boost_168_build/lib
@--0:/usr/local/boost_168_build/lib$ ls
libboost_atomic.a              libboost_iostreams.so         libboost_numpy27.a                       libboost_stacktrace_backtrace.so.1.68.0
libboost_atomic.so             libboost_iostreams.so.1.68.0  libboost_numpy27.so                      libboost_stacktrace_basic.a
libboost_atomic.so.1.68.0      libboost_locale.a             libboost_numpy27.so.1.68.0               libboost_stacktrace_basic.so
libboost_chrono.a              libboost_locale.so            libboost_prg_exec_monitor.a              libboost_stacktrace_basic.so.1.68.0
libboost_chrono.so             libboost_locale.so.1.68.0     libboost_prg_exec_monitor.so             libboost_stacktrace_noop.a
libboost_chrono.so.1.68.0      libboost_log.a                libboost_prg_exec_monitor.so.1.68.0      libboost_stacktrace_noop.so
libboost_container.a           libboost_log_setup.a          libboost_program_options.a               libboost_stacktrace_noop.so.1.68.0
libboost_container.so          libboost_log_setup.so         libboost_program_options.so              libboost_system.a
libboost_container.so.1.68.0   libboost_log_setup.so.1.68.0  libboost_program_options.so.1.68.0       libboost_system.so
libboost_context.a             libboost_log.so               libboost_python27.a                      libboost_system.so.1.68.0
libboost_context.so            libboost_log.so.1.68.0        libboost_python27.so                     libboost_test_exec_monitor.a
libboost_context.so.1.68.0     libboost_math_c99.a           libboost_python27.so.1.68.0              libboost_thread.a
libboost_contract.a            libboost_math_c99f.a          libboost_random.a                        libboost_thread.so
libboost_contract.so           libboost_math_c99f.so         libboost_random.so                       libboost_thread.so.1.68.0
libboost_contract.so.1.68.0    libboost_math_c99f.so.1.68.0  libboost_random.so.1.68.0                libboost_timer.a
libboost_coroutine.a           libboost_math_c99l.a          libboost_regex.a                         libboost_timer.so
libboost_coroutine.so          libboost_math_c99l.so         libboost_regex.so                        libboost_timer.so.1.68.0
libboost_coroutine.so.1.68.0   libboost_math_c99l.so.1.68.0  libboost_regex.so.1.68.0                 libboost_type_erasure.a
libboost_date_time.a           libboost_math_c99.so          libboost_serialization.a                 libboost_type_erasure.so
libboost_date_time.so          libboost_math_c99.so.1.68.0   libboost_serialization.so                libboost_type_erasure.so.1.68.0
libboost_date_time.so.1.68.0   libboost_math_tr1.a           libboost_serialization.so.1.68.0         libboost_unit_test_framework.a
libboost_exception.a           libboost_math_tr1f.a          libboost_signals.a                       libboost_unit_test_framework.so
libboost_filesystem.a          libboost_math_tr1f.so         libboost_signals.so                      libboost_unit_test_framework.so.1.68.0
libboost_filesystem.so         libboost_math_tr1f.so.1.68.0  libboost_signals.so.1.68.0               libboost_wave.a
libboost_filesystem.so.1.68.0  libboost_math_tr1l.a          libboost_stacktrace_addr2line.a          libboost_wave.so
libboost_graph.a               libboost_math_tr1l.so         libboost_stacktrace_addr2line.so         libboost_wave.so.1.68.0
libboost_graph.so              libboost_math_tr1l.so.1.68.0  libboost_stacktrace_addr2line.so.1.68.0  libboost_wserialization.a
libboost_graph.so.1.68.0       libboost_math_tr1.so          libboost_stacktrace_backtrace.a          libboost_wserialization.so
libboost_iostreams.a           libboost_math_tr1.so.1.68.0   libboost_stacktrace_backtrace.so         libboost_wserialization.so.1.68.0

有人能告诉我我想念的地方吗?谢谢

2 个答案:

答案 0 :(得分:1)

您可以使用use:

b2 cxxflags="-std=c++14" --reconfigure --with-fiber

编译libboost_fiber.a

答案 1 :(得分:0)

fiber是仅标头的库,因此无需链接,也无需将其添加为要查找的组件。

已编译库的列表在文档中:https://www.boost.org/doc/libs/1_68_0/more/getting_started/unix-variants.html#header-only-libraries