tartarus's bolg tartarus's bolg
  • Linux and Unix Guide
  • CMake
  • gcc
  • gdb
  • bash
  • GNU Make
  • DDCA-ETH
  • CS106L
  • CS144
  • NJU PA
  • NJU OS(jyy)
  • C
  • C++
  • Python
  • reveal-md
  • LaTex
  • Paper Reading
  • TBD
  • Linux and Unix Guide
  • CMake
  • gcc
  • gdb
  • bash
  • GNU Make
  • DDCA-ETH
  • CS106L
  • CS144
  • NJU PA
  • NJU OS(jyy)
  • C
  • C++
  • Python
  • reveal-md
  • LaTex
  • Paper Reading
  • TBD
  • pdb

  • make

  • cmake

    • Introduction
    • Basic Intro
    • Basic 01-hello-cmake
    • Basic 02-hello-headers
    • Basic 03-static-library
    • Basic 04-shared-library
    • Basic 05-installing
    • Basic 06-build-type
    • Basic 07-complie-flags
    • Basic 08-third-party-library
    • Basic 09-compiling-with-clang
    • Basic 10-building-with-ninjia
    • Basic 11-cpp-standard
    • Intermediate sub-projects
    • Intermediate static-analysis
    • packge-management 04-conan
      • 介绍
      • 安装conan
      • Conan配置
      • 寻找包
      • 检查包
      • 举例
    • packge-management 05-vcpkg
    • Offical Tutorial(未完成)
  • Linux and Unix

  • Basic_Software
  • cmake
tartarus
2023-04-18
目录

packge-management 04-conan

笔者暂时不打算学习使用 conan 了,目前第三方库都使用 vcpkg 进行管理,之后再回来完成这部分内容。

----------------------------------------------------- 未完成 -----------------------------------------------------

因为做 CS106L 用到了 CPP 的包管理工具 vcpkg ,就对包管理工具比较好奇。所以就先来学习一下和 vcpkg 类似的 conan 。

# 介绍

conan 是一个开源的、去中心化 (什么是去中心化? (opens new window)) 的多平台包管理工具。它支持多种构建系统,比如 CMake, Visual Studio, Makefile...

书上使用的是 Conan1.X 版本,但是现在已经过时了。下面使用 Conan2.0 (官方手册 (opens new window)) 进行介绍。

# 安装 conan

$ sudo apt-get install python3 python3-pip
$ pip3 install conan
1
2

# Conan 配置

在 Conan 中配置文件 (profiles) 用来控制编译器,环境信息使用动态库还是静态库等信息。

通过检测当前操作系统,构建工具和编译器设置创建一个默认的配置。

conan profile detect --force
1

会输出一下信息:

Found gcc 9
Found clang 10.0
gcc>=5, using the major as version
gcc C++ standard library: libstdc++11
Detected profile:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux

WARN: This profile is a guess of your environment, please check it.
WARN: The output of this command is not guaranteed to be stable and can change in future Conan versions.
WARN: Use your own profile files for stability.
Saving detected profile to /home/tartarus/.conan2/profiles/default
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

配置文件被保存到了: /home/tartarus/.conan2/profiles/default 中
构建类型会被默认配置为 Realse
conan 将会设置 C++ 标准为检测到的默认标准,如果你想更改 C++ 标准,直接进入文件配置文件更改即可。

# 寻找包

默认的,推荐的寻找包的方式是使用 conan-center (opens new window) 直接进行查找。

当然也可以使用 conan search 进行查找:

conan search fmt
1

(有时候会查找失败,这个得看网络状况)

# 检查包

可以使用 conan inspect 命令检查包

# 举例

上次更新: 12/27/2023, 8:55:47 AM
Intermediate static-analysis
packge-management 05-vcpkg

← Intermediate static-analysis packge-management 05-vcpkg→

Theme by Vdoing | Copyright © 2023-2023 tartarus | CC BY-NC-SA 4.0
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式