代码之家  ›  专栏  ›  技术社区  ›  souki

Cmake找不到-lboost_系统

  •  0
  • souki  · 技术社区  · 6 年前

    boost asio . 下面是 CMakeLists.txt 看起来像:

    project(server_c++) 
    cmake_minimum_required(VERSION 2.8.4)
    set(CMAKE_BINARY_DIR D:\\Sources\\server_c++\\build)
    
    message(STATUS "start running cmake...")
        set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/u/refdev64/boost/v1.66.0/include/")
        set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "/u/refdev64/boost/v1.66.0/")
        FIND_PACKAGE(Boost)
    
    if (Boost_FOUND)
        INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
        set(Boost_USE_STATIC_LIBS OFF)
        ADD_DEFINITIONS( "-DHAS_BOOST" )
    endif()
    
    add_executable(Server src/main.cpp src/TcpServer.cpp include/TcpServer.h src/Server.cpp include/Server.h include/ServerParameters.h include/StreamParameters.h include/Message.h src/MessageHandler.cpp include/MessageHandler.h src/Channel_setup.cpp include/Channel_setup.h)
    set_property(TARGET Server PROPERTY CXX_STANDARD 11)
    find_package(Boost REQUIRED COMPONENTS system)
    target_link_libraries(Server boost_system)
    

    cmake CMakeLists.txt ,我得到以下错误:

    -- start running cmake...
    -- Boost version: 1.66.0
    -- Boost version: 1.66.0
    -- Found the following Boost libraries:
    --   system
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /root/Documents
    Linking CXX executable Server
    /usr/bin/ld: cannot find -lboost_system
    collect2: ld returned 1 exit status
    gmake[2]: *** [Server] Error 1
    gmake[1]: *** [CMakeFiles/Server.dir/all] Error 2
    gmake: *** [all] Error 2
    

    因为所有的目录都是正确的,而cmake发现 boost ,我不明白我做错了什么。我有什么遗漏吗 CMakeLists.txt文件 ?

    g++版本是:5.1.0。

    提前谢谢!

    1 回复  |  直到 6 年前
        1
  •  0
  •   aicastell    6 年前

    检查主机中是否安装了boost_系统库。

    在Ubuntu16.04发行版中,您可以使用:

    $ dpkg -l | grep libboost
    

    $ sudo apt-get install  libboost-system1.58  libboost-system1.58-dev