两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 |
public:it:cplusplus:conan [2022/03/02 10:35] – oakfire | public:it:cplusplus:conan [2024/11/07 16:31] (当前版本) – [Conan 1 笔记] oakfire |
---|
====== Conan ====== | ====== Conan ====== |
* [[https://conan.io/|conan.io]] - the C/C++ Package Manager, | * [[https://conan.io/|conan.io]] - the C/C++ Package Manager, |
| * 仓库:https://conan.io/center/ |
| |
| ==== Conan 2 笔记 ==== |
| * 安装 conan2:<code bash> |
| sudo pip install conan |
| conan profile detect --force |
| </code>生成的默认配置文件在 ''~/.conan2/profiles/default '' |
| * 更新<code bash>sudo pip install conan --upgrade</code> |
| * 二进制包管理私有仓创建: |
| * https://docs.conan.io/2/tutorial/conan_repositories/setting_up_conan_remotes.html |
| * https://docs.conan.io/2/tutorial/conan_repositories/setting_up_conan_remotes/artifactory/artifactory_ce_cpp.html |
| ==== Conan 1 笔记 ==== |
* 结合 [[https://jfrog.com/|JFrog]] 可构建私有C/C++二进制包管理 | * 结合 [[https://jfrog.com/|JFrog]] 可构建私有C/C++二进制包管理 |
* 私有仓创建下载 [[https://conan.io/downloads.html]] | * 私有仓创建下载 [[https://conan.io/downloads.html]] |
* 关于打包[[https://docs.conan.io/en/latest/creating_packages/understand_packaging.html|understand_packaging]] | * 关于打包[[https://docs.conan.io/en/latest/creating_packages/understand_packaging.html|understand_packaging]] |
* 添加 bincrafter 仓:https://bincrafters.readthedocs.io/en/latest/using_packages.html#adding-the-bincrafters-repository-as-a-conan-remote | * 添加 bincrafter 仓:https://bincrafters.readthedocs.io/en/latest/using_packages.html#adding-the-bincrafters-repository-as-a-conan-remote |
| * 调整仓库顺序:<code bash> |
| conan remote clean |
| conan remote add myconan <your private conan artifactory url> |
| conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/public-conan |
| conan remote add conancenter https://center.conan.io |
| # conan remote add conan-center https://conan.bintray.com # 此仓库已被官方废弃 |
| </code> |
| * 更新conan: <code bash>pip install conan --upgrade # Might need sudo or --user</code> |
| * vscode 整合 conan 头文件:在 ''c/c++'' 插件设置里 ''includePath'' 添加 ''~/.conan/data/**'' |
| |
| === Android NDK 交叉编译 === |
| * 官方文档参考这个链接 https://docs.conan.io/en/latest/integrations/cross_platform/android.html, 而不是这个链接<del>https://docs.conan.io/en/latest/systems_cross_building/cross_building.html</del>, 后者的示例在 armv8 会错误编译成 armv7。 |
| * 可直接使用官方[[https://docs.conan.io/en/latest/integrations/cross_platform/android.html|这个链接]]的第一种办法,即在 profile 里直接使用 ''android-ndk''包作为 tool_requires, 比如编译 armv8:<code ini>include(default) |
| [settings] |
| arch=armv8 |
| build_type=Release |
| compiler=clang |
| compiler.libcxx=libc++ |
| compiler.version=11 |
| os=Android |
| os.api_level=21 |
| [tool_requires] |
| android-ndk/r22b |
| [options] |
| [env]</code> 然后install 或 create 时指定跨平台编译 <code bash>conan install .. --build=missing -pr:h android-armv8 -pr:b default</code> |
| * [[https://docs.conan.io/en/latest/systems_cross_building/cross_building.html|这个链接里android 示例]] 错误的原因是, Android 与 CMake 结合时, CMake 除了指定 android.toolchain.cmake, 还需要额外[[https://developer.android.com/ndk/guides/cmake#variables|指定变量]] ''ANDROID_ABI'' ''ANDROID_PLATFORM'' 才能正确编译出目标版本。 而 conan 并[[https://docs.conan.io/en/latest/reference/env_vars.html|没有办法在 profile 里直接设置]]这两个 cmake 变量, 所以就算你的工程的 CMakefile.txt 设置了这两变量,你的依赖包在cmake building 时也会默认选择了错误的arch。 |