conan2 基础入门(03)-使用(msvc为例)

conan2 基础入门(03)-使用(msvc为例)

⭐准备

在阅读和学习本文前,希望有一定的cmake基础。

cmake基础:

(CMake) 从下载到构建第一个CMake应用

(CMake) 库的生成和链接

Build a simple CMake project using Conan — conan 2.3.0 documentation

在conan官网中有简单的示例教程。

在这里插入图片描述

生成profile文件

在使用conan前,需要先准备一个profile文件。下面指令会自动生成默认的。

# 生成默认profile文件,名字为`default`
# --force 表示强制生成,即若原来有`default`会被覆盖
# --name 表示指定生成名称
conan profile detect
conan profile detect --force
conan profile detect --name <指定名称>

# 查看名为`default`的profile文件的路径
conan profile path default
conan profile path <名称>

# 查看已经存在的eprofile
conan profile list

在笔者测试机(装有vs2019)上会出现如下显示。其实就是一个.ini格式的配置文件(但并非完全的ini,conan有自己的特殊处理)。

detect_api: Found msvc 16

Detected profile:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.version=192
os=Windows

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 C:\Users\lotus\.conan2\profiles\default
C:.
│  global.conf
│  settings.yml
│  version.txt
│
├─extensions
│  └─plugins
│      │  profile.py
│      │
│      └─compatibility
│              compatibility.py
│              cppstd_compat.py
│
└─profiles
        default

在这里插入图片描述

预备文件和Code

文件名预览

:.
│  CMakeLists.txt
│  conanfile.txt
└─ main.cpp

main.cpp

#include <iostream>

#include "zlib.h"

void test_env() {
   
    std::cout << ">>>" << __fun
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天赐细莲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值