Windows conan环境搭建
1 安装conan
1.1 安装依赖软件
1.1.1 python安装
pip需要依赖python (>= 3.9),我本地安装的3.10.10版本的python。
Python 软件包:
python软件包直接去官网下载比较慢,在安装时选中安装路径添加到环境变量(Add Python to PATH)的选项,其他的默认安装即可。
python的官方网站:
https://www.python.org/downloads/windows/
1.1.2 git bash安装
可以在http://www.git-scm.com/download/下载对应的windows版本的git去安装使用。
1.1.3 安装Visual Studio Community 2019
打开Microsoft Store中搜索Visual Studio Community 2019
,选择安装。
如果选择Visual Studio Community 2022请参考该篇博文:windows环境下VSCode配置C++教程(使用msvc编译器),需要注意的是Visual Studio Community 2022对应的MSVC是17而不是2019版的16,如果使用msvc16去编译需要对应的适配一个msvc17的profile配置文件。
1.1.3.1 选择安装的组件
1.1.3.2 选择要支持的工具以及对应的SDK
1.1.4 vscode安装
可以直接在vscode官网下载Download Visual Studio Code - Mac, Linux, Windows,需要选择System Installer软件包安装。
1.2 安装1.55.0版本的conan
conan在windows上最新的版本是2.xx的,conan的1.xx版本和2.xx版本的差异非常大,我们在开发时目前需要的是conan 1.xx版本去做代码库管理工作,在安装时需要制定要安装的1.xx的conan版本号。
pip install conan=1.55
1.3 验证conan功能
直接在windows的powershell视图执行conan命令即可,执行之后会显示conan的帮助信息。
PS C:\Users\test> conan
Consumer commands
install Installs the requirements specified in a recipe (conanfile.py or conanfile.txt).
config Manages Conan configuration.
get Gets a file or list a directory of a given reference or package.
info Gets information about the dependency graph of a recipe.
search Searches package recipes and binaries in the local cache or a remote. Unless a
remote is specified only the local cache is searched.
Creator commands
new Creates a new package recipe template with a 'conanfile.py' and optionally,
'test_package' testing files.
create Builds a binary package for a recipe (conanfile.py).
upload Uploads a recipe and binary packages to a remote.
export Copies the recipe (conanfile.py & associated files) to your local cache.
export-pkg Exports a recipe, then creates a package from local source and build folders.
test Tests a package consuming it from a conanfile.py with a test() method.
Package development commands
source Calls your local conanfile.py 'source()' method.
build Calls your local conanfile.py 'build()' method.
package Calls your local conanfile.py 'package()' method.
editable Manages editable packages (packages that reside in the user workspace, but are
consumed as if they were in the cache).
workspace Manages a workspace (a set of packages consumed from the user workspace that
belongs to the same project).
Misc commands
profile Lists profiles in the '.conan/profiles' folder, or shows profile details.
remote Manages the remote list and the package recipes associated with a remote.
user Authenticates against a remote with user/pass, caching the auth token.
imports Calls your local conanfile.py or conanfile.txt 'imports' method.
copy Copies conan recipes and packages to another user/channel.
remove Removes packages or binaries matching pattern from local cache or remote.
alias Creates and exports an 'alias package recipe'.
download Downloads recipe and binaries to the local cache, without using settings.
inspect Displays conanfile attributes, like name, version, and options. Works locally,
in local cache and remote.
help Shows help for a specific command.
lock Generates and manipulates lock files.
frogarian Conan The Frogarian
Conan commands. Type "conan <command> -h" for help
PS C:\Users\weihanwu>
1.4 查看conancenter是否包含poco包
PS D:\work> conan search poco --remote=conancenter
Existing package recipes:
poco/1.8.1
poco/1.9.3
poco/1.9.4
poco/1.10.0
poco/1.10.1
poco/1.11.0
poco/1.11.1
poco/1.11.2
poco/1.11.3
poco/1.12.5p1
poco/1.12.0
poco/1.12.1
poco/1.12.2
poco/1.12.3
poco/1.12.4
PS D:\work>
1.5 查看poco/1.9.4的conan信息
PS D:\work> conan inspect poco/1.9.4
name: poco
version: 1.9.4
url: https://github.com/conan-io/conan-center-index
homepage: https://pocoproject.org
license: BSL-1.0
author: None
description: Modern, powerful open source C++ class libraries for building network- and internet-based applications that run on desktop, server, mobile and embedded systems.
topics: ('building', 'networking', 'server', 'mobile', 'embedded')
generators: ['txt']
exports: None
exports_sources: None
short_paths: False
apply_env: True
build_policy: None
revision_mode: hash
settings: ('os', 'arch', 'compiler', 'build_type')
options:
enable_active_record: [True, False, 'deprecated']
enable_activerecord: [True, False]
enable_activerecord_compiler: [True, False]
enable_apacheconnector: [True, False]
enable_cppparser: [True, False]
enable_crypto: [True, False]
enable_data: [True, False]
enable_data_mysql: [True, False]
enable_data_odbc: [True, False]
enable_data_postgresql: [True, False]
enable_data_sqlite: [True, False]
enable_encodings: [True, False]
enable_fork: [True, False]
enable_json: [True, False]
enable_jwt: [True, False]
enable_mongodb: [True, False]
enable_net: [True, False]
enable_netssl: [True, False]
enable_netssl_win: [True, False]
enable_pagecompiler: [True, False]
enable_pagecompiler_file2page: [True, False]
enable_pdf: [True, False]
enable_pocodoc: [True, False]
enable_prometheus: [True, False]
enable_redis: [True, False]
enable_sevenzip: [True, False]
enable_util: [True, False]
enable_xml: [True, False]
enable_zip: [True, False]
fPIC: [True, False]
shared: [True, False]
default_options:
enable_active_record: deprecated
enable_activerecord: True
enable_activerecord_compiler: False
enable_apacheconnector: False
enable_cppparser: False
enable_crypto: True
enable_data: True
enable_data_mysql: True
enable_data_odbc: False
enable_data_postgresql: True
enable_data_sqlite: True
enable_encodings: True
enable_fork: True
enable_json: True
enable_jwt: True
enable_mongodb: True
enable_net: True
enable_netssl: True
enable_netssl_win: False
enable_pagecompiler: False
enable_pagecompiler_file2page: False
enable_pdf: False
enable_pocodoc: False
enable_prometheus: False
enable_redis: True
enable_sevenzip: False
enable_util: True
enable_xml: True
enable_zip: True
fPIC: True
shared: False
deprecated: None
PS D:\work>
1.6 新建conanfile.txt
conanfile.txt
[requires]
poco/1.9.4
[generators]
cmake
1.7 安装所需的依赖项并生成构建系统的信息
mkdir build && cd build
conan install .. --build=missing