• 1 Packaging Existing Binaries
    • 1.1 Packaging Pre-built Binaries
    • 1.2 Downloading and Packaging Pre-built Binaries

本文是基于对conan官方文档Packaging Existing Binaries翻译而来, 更详细的信息可以去查阅conan官方文档。

1 Packaging Existing Binaries

There are specific scenarios in which it is necessary to create packages from existing binaries, for example from 3rd parties or binaries previously built by another process or team that are not using Conan. Under these circumstances building from sources is not what you want. You should package the local files in the following situations:
在某些特殊情况下,有必要从现有二进制文件创建软件包,例如从第三方或由其他未使用 Conan 的流程或团队构建的二进制文件。在这种情况下,从源代码构建软件包并不是您想要的。在以下情况下,应打包本地文件:

  • When you cannot build the packages from sources (when only pre-built binaries are available).
  • 无法从源代码构建软件包时(只有预构建的二进制文件可用)。
  • When you are developing your package locally and you want to export the built artifacts to the local cache. As you don’t want to rebuild again (clean copy) your artifacts, you don’t want to call conan create. This method will keep your build cache if you are using an IDE or calling locally to the conan build command.
  • 当您在本地开发软件包,并希望将构建的工件导出到本地缓存时。由于您不想再次重建(清空副本)您的工件,所以您不想调用 conan create。如果您使用集成开发环境或在本地调用 conan build 命令,此方法将保留您的构建缓存。

1.1 Packaging Pre-built Binaries

Running the build() method, when the files you want to package are local, results in no added value as the files copied from the user folder cannot be reproduced. For this scenario, run conan export-pkg command directly.
当要打包的文件是本地文件时,运行 build() 方法不会带来任何附加值,因为从用户文件夹复制的文件无法再现。在这种情况下,请直接运行 conan export-pkg 命令。

A Conan recipe is still required, but is very simple and will only include the package meta information. A basic recipe can be created with the conan new command:
Conan 配方仍是必需的,但非常简单,只包含软件包元信息。可以使用 conan new 命令创建基本配方:

$ conan new hello/0.1 --bare

This will create and store the following package recipe in the local cache:

class HelloConan(ConanFile):
    name = "hello"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"

    def package(self):

    def package_info(self):
        self.cpp_info.libs = self.collect_libs()

The provided package_info() method scans the package files to provide end-users with the name of the libraries to link to. This method can be further customized to provide additional build flags (typically dependent on the settings). The default package_info() applies as follows: it defines headers in the “include” folder, libraries in the “lib” folder, and binaries in the “bin” folder. A different package layout can be defined in the package_info() method.
所提供的 package_info() 方法会扫描软件包文件,为最终用户提供要链接的库名称。该方法可进一步定制,以提供额外的构建标志(通常取决于设置)。默认的 package_info() 应用如下:在 "include "文件夹中定义头文件,在 "lib "文件夹中定义库,在 "bin "文件夹中定义二进制文件。可以在 package_info() 方法中定义不同的软件包布局。

This package recipe can be also extended to provide support for more configurations (for example, adding options: shared/static, or using different settings), adding dependencies (requires), and more.

Based on the above, we can assume that our current directory contains a lib folder with a number binaries for this “hello” library libhello.a, compatible for example with Windows MinGW (gcc) version 4.9:
根据上述情况,我们可以假设当前目录下有一个 lib 文件夹,其中包含 "hello "库 libhello.a 的若干二进制文件,例如与 Windows MinGW (gcc) 4.9 版本兼容:

$ conan export-pkg . hello/0.1@myuser/testing  -s os=Windows -s compiler=gcc -s compiler.version=4.9 ...

Having a test_package folder is still highly recommended for testing the package locally before upload. As we don’t want to build the package from the sources, the flow would be:
我们仍然强烈建议在上传软件包前在本地测试 test_package 文件夹。由于我们不想从源代码构建软件包,因此流程如下

$ conan new hello/0.1 --bare --test
# customize test_package project
# customize package recipe if necessary
$ cd my/path/to/binaries
$ conan export-pkg PATH/TO/conanfile.py hello/0.1@myuser/testing  -s os=Windows -s compiler=gcc -s compiler.version=4.9 ...
$ conan test PATH/TO/test_package/conanfile.py hello/0.1@myuser/testing -s os=Windows -s compiler=gcc -s ...

The last two steps can be repeated for any number of configurations.

1.2 Downloading and Packaging Pre-built Binaries

In this scenario, creating a complete Conan recipe, with the detailed retrieval of the binaries could be the preferred method, because it is reproducible, and the original binaries might be traced. Follow our sample recipe for this purpose:
在这种情况下,创建一个完整的conan recipe并详细检索二进制文件可能是首选方法,因为这种方法具有可重复性,而且可以追踪到原始的二进制文件。为此,请参考我们的示例配方:

class HelloConan(ConanFile):
    name = "hello"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"

    def build(self):
        if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
            url = ("https://<someurl>/downloads/hello_binary%s_%s.zip"
                   % (str(self.settings.compiler.version), str(self.settings.build_type)))
        elif ...:
            url = ...
            raise Exception("Binary does not exist for these settings")

    def package(self):
        self.copy("*") # assume package as-is, but you can also copy specific files or rearrange

    def package_info(self):  # still very useful for package consumers
        self.cpp_info.libs = ["hello"]

Typically, pre-compiled binaries come for different configurations, so the only task that the build() method has to implement is to map the settings to the different URLs.
通常情况下,预编译的二进制文件会有不同的配置,因此 build() 方法需要执行的唯一任务就是将设置映射到不同的 URL。


  • This is a standard Conan package even if the binaries are being retrieved from elsewhere. The recommended approach is to use conan create, and include a small consuming project in addition to the above recipe, to test locally and then proceed to upload the Conan package with the binaries to the Conan remote with conan upload.
  • 即使二进制文件是从其他地方获取的,这也是一个标准的 Conan 软件包。建议的方法是使用 conan create,并在上述配方中加入一个小型消耗项目,在本地进行测试,然后使用 conan upload 将包含二进制文件的 Conan 软件包上传到远端 Conan。
  • The same building policies apply. Having a recipe fails if no Conan packages are created, and the --build argument is not defined. A typical approach for this kind of packages could be to define a build_policy=“missing”, especially if the URLs are also under the team control. If they are external (on the internet), it could be better to create the packages and store them on your own Conan server, so that the builds do not rely on third party URL being available.
  • 同样的构建策略也适用。如果没有创建conan软件包,也没有定义 --build 参数,配方就会失效。对于这类软件包,典型的方法是定义 build_policy="missing",尤其是当 URL 也在团队控制之下时。如果它们是外部的(在互联网上),最好是创建软件包并将其存储在自己的 Conan 服务器上,这样编译就不会依赖于第三方 URL 的可用性。




问题:HTTP method names must be tokens

问题&#xff1a;HTTP method names must be tokens 2023-12-04T09:43:16.65408:00 INFO 7808 --- [nio-6600-exec-1] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request headerNote: further occurrences of HTTP request parsing errors will be logg…


一.动态创建任务 1.函数xTaskCreate() BaseType_t xTaskCreate( TaskFunction_t pxTaskCode, // 函数指针, 任务函数const char * const pcName, // 任务的名字const configSTACK_DEPTH_TYPE usStackDepth, // 栈大小,单位为word,10表示40字节void * const pvParameters, // …


文章目录 Rust开发入门Rust的特性Rust的应用场景Rust安装——环境配置1. 安装rustup具体执行步骤 2. 验证安装 Rust的卸载基本语法变量与数据类型控制流函数 Rust的所有权系统错误处理实战&#xff1a;构建一个小项目创建新项目编写代码运行项目安装相关链接器运行 删除项目 Ru…

【云原生 | Docker】Docker核心概念 应用上手最佳流程

&#x1f935;‍♂️ 个人主页: AI_magician &#x1f4e1;主页地址&#xff1a; 作者简介&#xff1a;CSDN内容合伙人&#xff0c;全栈领域优质创作者。 &#x1f468;‍&#x1f4bb;景愿&#xff1a;旨在于能和更多的热爱计算机的伙伴一起成长&#xff01;&#xff01;&…



ESP32-Web-Server编程-通过 Web 下载文本

ESP32-Web-Server编程-通过 Web 下载文本 概述 当你希望通过网页导出设备的数据时&#xff0c;可以在 ESP32 上部署一个简单的文件 Web 服务器。 需求及功能解析 本节演示如何在 ESP32 上部署一个最简单的 Web 服务器&#xff0c;来接收浏览器或者 wget 指令请求文件数据。…

基于APM(PIX)飞控和mission planner制作遥控无人车-从零搭建自主pix无人车普通舵机转向无人车-1(以乐迪crossflight飞控为例)

1.前期准备 准备通过舵机转向的无人车地盘、遥控器、地面站电脑、飞控等。安装驱动程序、端口程序、netframwork等&#xff0c;不再赘述。 2.安装固件 安装ardurover固件&#xff0c;如果在线失败&#xff0c;选择官方最新的固件下载到本地&#xff0c;选择本地安装。 3.调试…


wimlib-imagex是个第三方工具&#xff0c;可对系统映像进行操作&#xff0c;下载地址&#xff1a; https://wimlib.net/downloads/index.html 程序主要用到以下这两个文件&#xff1a;libwim-15.dll和wimlib-imagex.exe wimlib-imagex.exe的调用命令参数&#xff0c;可以通过…


声明&#xff1a; 该文章为学习使用&#xff0c;严禁用于商业用途和非法用途&#xff0c;违者后果自负&#xff0c;由此产生的一切后果均与作者无关 一、找出需要加密的参数 js运行 atob(‘aHR0cDovL2JpcmRyZXBvcnQuY24vaG9tZS9hY3Rpdml0eS9wYWdlLmh0bWw’) 拿到网址&#xf…


&#x1f383;个人专栏&#xff1a; &#x1f42c; 算法设计与分析&#xff1a;算法设计与分析_IT闫的博客-CSDN博客 &#x1f433;Java基础&#xff1a;Java基础_IT闫的博客-CSDN博客 &#x1f40b;c语言&#xff1a;c语言_IT闫的博客-CSDN博客 &#x1f41f;MySQL&#xff1a…


文章目录 前言1.安装Node.js环境2.创建node.js服务3. 访问node.js 服务4.内网穿透4.1 安装配置cpolar内网穿透4.2 创建隧道映射本地端口 5.固定公网地址 前言 Node.js 是能够在服务器端运行 JavaScript 的开放源代码、跨平台运行环境。Node.js 由 OpenJS Foundation&#xff0…


官方文档 PHP: Zip - Manual 在PHP中&#xff0c;zip扩展提供了处理ZIP文件的功能。它允许你创建、读取、更新和提取ZIP文件。 首先&#xff0c;确保你的PHP环境已经安装了zip扩展。你可以在php.ini文件中找到以下行来检查&#xff1a; extensionzip 如果没有注释掉&#xf…


目录 Nginx简介Nginx的作用Nginx的安装方法方法一方法二方法三 本文主要介绍在Linux系统下&#xff0c;三种常见Nginx安装方法。 Nginx简介 Nginx是一个高性能的HTTP和反向代理服务器&#xff0c;也可以作为邮件代理服务器和通用的TCP/UDP代理服务器。它最初由Igor Sysoev创建…


文章目录 一、数据库概述二、数据库分类Mysql数据库连接方法 三、识别数据库四、SQL语法4.1 SQL基本语法4.2 高级操作 一、数据库概述 数据库&#xff08;database&#xff09;&#xff1a;存储在磁盘、磁带、光盘或其他外存介质上、按一定结构组织在一起的相关数据的集合。数…


前端面试大全JS浮点数精度问题及解决方案 &#x1f31f;经典真题 &#x1f31f;浮点数精度常见问题 &#x1f31f;为什么会有这样的问题 &#x1f31f;真题解答 &#x1f31f;总结 &#x1f31f;经典真题 为什么 console.log( 得到的值为 false &#x1f31f;…


4台机器的集群两台centos&#xff0c;两台麒麟v10 问题1.执行到集群和节点加入集群时候报错 ERRO[18:48:06 CST] Failed to add master to cluster: Failed to exec command: sudo env PATH$PATH:/sbin:/usr/sbin /bin/sh -c “/usr/local/bin/kubeadm join --config/etc/kube…


要实现一个正六边形嵌套圆心&#xff0c;可以使用CSS的::before和::after伪元素以及border-radius属性。以下是具体的解析和代码&#xff1a; 使用::before和::after伪元素创建正六边形。设置正六边形的背景色。使用border-radius属性使正六边形的内角为60度。在正六边形内部创…

网络安全(二)-- Linux 基本安全防护技术

4.1. 概述 安全防护基础主要是会用Linux系统&#xff0c; 熟悉Linux基本操作命令。 在这个章节中&#xff0c;我们主要探讨自主访问控制&#xff08;许可位、ACL&#xff09;、文件属性、 PAM技术、能力机制等。 4.1.1. 补充命令 本章节中&#xff0c;涉及一些新的命令&#…


哈喽&#xff01;大家好。 几天不见&#xff0c;今天给大家带来一款海外的神器&#xff0c;官方宣布完全免费&#xff0c;但仅限于个人与教育用途&#xff0c;切勿商用噢&#xff01; 不要看这个软件名字普普通通&#xff0c;实际上内蕴乾坤&#xff01; 接下来看我给大家炫一…


代码 private static SqlSessionFactory sqlSessionFactory;static { ​try { // 获得核心配置文件String resource "mybits-config.xml"; // 加载核心配置文件InputStream inputStream Resources.getResourceAsStream(resource…