首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用cmake和travis增强1.67静态库

使用cmake和travis增强1.67静态库
EN

Stack Overflow用户
提问于 2019-03-23 22:29:57
回答 1查看 367关注 0票数 0

大家听好了。我尝试在travis-ci中使用cmake和boost1.67来构建我的c++项目。下面是源文件。

在我的linux计算机上,cmake 3.13.4是从源代码安装的,boost-1.67是从源代码安装的,所有的库(静态的和动态的)都在"/usr/local/lib/“目录中,所有的工作都很好。但在travis-ci中,我每次都会看到这样的信息:

代码语言:javascript
复制
Unable to find the requested Boost libraries.
  Boost version: 1.67.0
  Boost include path: /usr/include
  Could not find the following static Boost libraries:
          boost_program_options
  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.

yml文件:

代码语言:javascript
复制
language: cpp
dist: xenial
sudo: false
os: linux


matrix:
  include:
    - env: COMPILER=g++-8 BUILD=Debug STANDARD=14
      compiler: gcc
      addons:
        apt:
          update: true
          sources:
            - sourceline: 'ppa:mhier/libboost-latest'
            - ubuntu-toolchain-r-test
          packages:
            - g++-8
            - boost1.67
    - env: COMPILER=g++-8 BUILD=Release STANDARD=14
      compiler: gcc
      addons:
        apt:
          update: true
          sources:
            - sourceline: 'ppa:mhier/libboost-latest'
            - ubuntu-toolchain-r-test
          packages:
            - g++-8
            - boost1.67

before_script:
  - wget https://cmake.org/files/v3.13/cmake-3.13.4-Linux-x86_64.sh
  - sudo sh cmake-3.13.4-Linux-x86_64.sh -- --skip-license --prefix=/usr

script:
  - cmake .
  - cmake --build .
  - cmake --build . --target package

cmake:

代码语言:javascript
复制
cmake_minimum_required(VERSION 3.10)  
project(hcch VERSION 0.1.${VERSION_BUILD})

set(BOOST_ROOT /usr/include/boost/)

# For my linux
#set(BOOST_LIBRARYDIR /usr/local/lib)

# For travis-ci host
set(BOOST_LIBRARYDIR /usr/lib/x86_64-linux-gnu)

set(Boost_USE_STATIC_LIBS ON)
include_directories (${Boost_INCLUDE_DIRS})
link_directories (${Boost_LIBRARY_DIRS})

find_package(Boost 1.67 COMPONENTS program_options REQUIRED)
find_package(LLVM REQUIRED CONFIG)

configure_file (
        "${PROJECT_SOURCE_DIR}/version.h.in"
        "${PROJECT_BINARY_DIR}/version.h"
)

set(CMAKE_CXX_STANDARD 14)

add_executable(hcch hcch.cpp SourcesCreator.cpp SourcesCreator.h)

set_target_properties(hcch PROPERTIES
        CXX_STANDARD 14
        CXX_STANDARD_REQUIRED ON
        COMPILE_OPTIONS -Wpedantic -Wall -Wextra
        )

TARGET_LINK_LIBRARIES( hcch ${BOOST_LIBRARYDIR}/libboost_program_options.a )

也许静态库不是从ppa安装的:mhier/libboost-latest?告诉我如果有人遇到了该怎么处理。

这是我的项目,https://github.com/angelskieglazki/hcch致敬,最大

EN

回答 1

Stack Overflow用户

发布于 2019-07-04 00:22:00

我可以确认从ppa:mhier/ libboost -latest构建的libboost当前没有构建静态库,只构建了共享的库。

如果你必须使用比libboost-all-dev提供的版本更高的Boost版本,那么你将需要从源代码编译boost,尽管你会有超时的风险。有关此操作的说明,请参阅Boost's best practice handbook

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55314745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档