使用Boost的CMake找不到静态库

 mobiledu2502901317 发布于 2023-02-09 14:58

我在使用CMake和Boost库时遇到了一些麻烦.我有以下错误:

CMake Error at C:/Program Files (x86)/CMake
2.8/share/cmake-2.8/Modules/FindBoost.cmake:1111 (message):   Unable to find the requested Boost libraries.

  Boost version: 1.55.0

  Boost include path: C:/local/boost_1_55_0

  Could not find the following static Boost libraries:

          boost_system
          boost_date_time
          boost_regex

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


-- Configuring incomplete, errors occurred!

我在我的CMakeLists.txt中做了我在互联网上找到的所有内容,但它不起作用,我不明白.我正在使用Windows 8和Visual Studio 12,并且Boost安装在默认目录中.(C:/本地/ boost_1_55_0)

这是我的CMakeLists.txt:

cmake_minimum_required(VERSION 2.6)

project (server)

set(BOOST_ROOT "c:\\local\\boost_1_55_0")

set (Boost_USE_STATIC_LIBS ON) set (Boost_MULTITHREADED ON) set
(Boost_USE_STATIC_RUNTIME OFF)

find_package(Boost 1.55 COMPONENTS system date_time regex REQUIRED)
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})

set(SRCS main.cpp Server.cpp Client.cpp)

set(HEADERS Server.h Client.h)

include_directories(${Boost_INCLUDE_DIR})

add_executable(babel_server ${SRCS} ${HEADERS})

target_link_libraries(babel_server ${Boost_LIBRARIES})

有人可以帮我吗?

谢谢

2 个回答
  • 我有同样的问题

    通过使用命令解决

    bjam install --prefix="<your boost install folder>" --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi
    

    2023-02-09 15:01 回答
  • 我猜你的编译库不在你的BOOST_ROOT/lib /文件夹中.在这种情况下,您需要设置lib文件夹目录路径.

    set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib/)
    

    要么

    set(BOOST_LIBRARYDIR path/to/your/lib/folder)
    

    2023-02-09 15:01 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有