Conan: starting at a text book Hello World

这篇具有很好参考价值的文章主要介绍了Conan: starting at a text book Hello World。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Command Lines

  1. to search libraries from conancenter
    # conan search poco --remote=conancenter
  2. to inspect the metadata of a library
    # conan inspect poco/1.9.4
  3. to install the library and the dependency but also the transitive dependencies, and generate the information for the build system(be sure there is a recipe in current directory)
    # conan install
  4. to search for packages in the local cache
    # conan search “ ∗ *
E:\workplace\Conan\Repository\examples\libraries\poco\md5>conan search "*"
Existing package recipes:

bzip2/1.0.8
expat/2.5.0
openssl/1.1.1t
pcre/8.45
poco/1.9.4
sqlite3/3.40.1
zlib/1.2.13

  1. to inspect the different binary packages of a reference. The @ symbol at the end of the package name is important to search for a specific package. If you don’t add the @, Conan will interpret the argument as a pattern search and return all the packages that match the poco/1.9.4 pattern and may have different user and channel.
    # conan search poco/1.9.4@
E:\workplace\Conan\Repository\examples\libraries\poco\md5>conan search poco/1.9.4@
Existing packages for recipe poco/1.9.4:

    Package_ID: 827d0093fffd24b2cf1576c6515a7f7707d5d2b9
        [options]
            enable_apacheconnector: False
            enable_cppparser: False
            enable_crypto: True
            enable_data: True
            enable_data_odbc: False
            enable_data_sqlite: True
            enable_encodings: True
            enable_json: 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_redis: True
            enable_sevenzip: False
            enable_util: True
            enable_xml: True
            enable_zip: True
            shared: False
        [settings]
            arch: x86_64
            build_type: Release
            compiler: Visual Studio
            compiler.runtime: MD
            compiler.version: 16
            os: Windows
        [requires]
            bzip2/1.0.8:d16a91eadaaf5829b928b12d2f836ff7680d3df5
            expat/2.5.0:ce5788ba7e3bb7dc834e36b06df66c481f42c99a
            openssl/1.1.1t:3fb49604f9c2f729b85ba3115852006824e72cab
            pcre/8.45:e87a8a0d1a34c63e57cfcfa8aa6088b17582df41
            sqlite3/3.40.1:1cb7125758648b3fd39bd045f772ec43fd26f71a
            zlib/1.2.13:3fb49604f9c2f729b85ba3115852006824e72cab
        Outdated from recipe: False

  1. to inspect all your current project’s dependencies use the conan info command by pointing it to the location of the conanfile.txt folder
    # conan info . . .. ..
    to generate a graph of your dependencies using Dot or HTML formats:
    # conan info . . .. .. --graph=file.html
E:\workplace\Conan\Repository\examples\libraries\poco\md5\build>conan info ..
WARN: pcre/8.45: requirement zlib/[>=1.2.11 <2] overridden by poco/1.9.4 to zlib/1.2.13
conanfile.txt
    ID: 4f96d5e60086be3b241f3740593e45556da2a223
    BuildID: None
    Context: host
    Requires:
        poco/1.9.4
bzip2/1.0.8
    ID: d16a91eadaaf5829b928b12d2f836ff7680d3df5
    BuildID: None
    Context: host
    ...
    ...
    

Configurations

  1. How to change the directory of Conan native repository or local cache?
    For Windows, open the configuration file C:\Users\Administrator.conan\conan.conf and modify the storage field:
    [storage]
    path = your_path

  2. ~/.conan/profiles/default, the file default is the configuration file detected by Conan, and this configuration is known as the default profile. A profile needs to be available prior to running commands such as conan install. When running the command, your settings are automatically detected (compiler, architecture. . . ) and stored as the default profile. You can edit these settings ~/.conan/profiles/default or create new profiles with your desired configuration.

point some self configurations:

# conan install .. --profile=gcc_x86
# conan install .. --settings arch=x86

default

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
build_type=Release
[options]
[build_requires]
[env]


Preparation

Download the project of the example:
# git clone https://github.com/conan-io/examples.git

50105@DESKTOP-2PP2ND2 MINGW64 /e/workplace/Conan/Repository/examples/libraries/poco/md5 (master)
$ ls
CMakeLists.txt  README.md  build/  build.bat  build.sh*  conanfile.txt  md5.cpp
  1. md5.cpp, the source codes
#include "Poco/MD5Engine.h"
#include "Poco/DigestStream.h"

#include <iostream>


int main(int argc, char** argv)
{
    Poco::MD5Engine md5;
    Poco::DigestOutputStream ds(md5);
    ds << "abcdefghijklmnopqrstuvwxyz";
    ds.close();
    std::cout << Poco::DigestEngine::digestToHex(md5.digest()) << std::endl;
    return 0;
}

  1. From the source codes of md5.cpp, one can see that this application relies on the Poco libraries, which can be installed from ConanCenter remote:
# conan search poco --remote=conancenter
Existing package recipes:

poco/1.8.1
poco/1.9.3
poco/1.9.4
...
poco/1.13.0
# 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.
...
...
  1. And the poco/1.9.4 is the interested version. The metadata of the 1.9.4 version are showed above.
  2. conanfile.txt, the crucial recipe that determines the package. In this example CMake is used to build the project, which is why the cmake generator is specified.
[requires]
poco/1.9.4

[generators]
cmake

  1. install the required dependencies and generate the information for the build system:
# mkdir build && cd build
# conan install ..
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

pcre/8.45: Not found in local cache, looking in remotes...
pcre/8.45: Trying with 'conancenter'...
Downloading conanmanifest.txt
Downloading conanfile.py
Downloading conan_export.tgz
pcre/8.45: Downloaded recipe revision 0
bzip2/1.0.8: Not found in local cache, looking in remotes...
...
...
poco/1.9.4: Package installed 827d0093fffd24b2cf1576c6515a7f7707d5d2b9
poco/1.9.4: Downloaded package revision 0
conanfile.txt: Generator cmake created conanbuildinfo.cmake
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo

  1. cmake, the generator. To inject the Conan information, include the generated conanbuildinfo.cmake

CMakeLists.txt文章来源地址https://www.toymoban.com/news/detail-815257.html

cmake_minimum_required(VERSION 2.8.12)
project(MD5Encrypter)

if(CMAKE_VERSION VERSION_LESS 3.0.0)
    include(CheckCXXCompilerFlag)
    check_cxx_compiler_flag(-std=c++11 COMPILER_SUPPORTS_CXX11)
    check_cxx_compiler_flag(-std=c++0x COMPILER_SUPPORTS_CXX0X)
    if(COMPILER_SUPPORTS_CXX11)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    elseif(COMPILER_SUPPORTS_CXX0X)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
    endif()
else()
    SET(CMAKE_CXX_STANDARD 11)
    SET(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(md5 md5.cpp)
target_link_libraries(md5 ${CONAN_LIBS})

  1. build and run MD5 app, in windows system case
> cmake .. -G "Visual Studio 16"
> cmake --build . --config Release

E:\workplace\Conan\Repository\examples\libraries\poco\md5\build\bin>md5.exe
c3fcd3d76192e4007dfb496cca67e13b
Press any key to continue. . .

到了这里,关于Conan: starting at a text book Hello World的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ROS Hello World

    ROS 系列学习教程(总目录) 万物始于Hello World,为了体验ROS,使用Hello World介绍ROS的简单使用。 首先需要创建工程,流程为: 创建工作空间目录(即工程根目录,注意此时还不是ROS工作空间,只是一个目录) 初始化工作空间(即把当前目录初始化为一个ROS工作空间) 创建功能

    2024年02月06日
    浏览(41)
  • C++输出Hello,World

    在 C 语言中输出 \\\"Hello, World\\\" 可以使用下面的代码: #include stdio.h int main() { printf(\\\"Hello, Worldn\\\"); return 0; } 代码的意思是:首先使用 #include stdio.h 告诉编译器我们要使用输入/输出函数,然后定义一个名为 main 的函数,在函数中使用 printf 函数来输出字符串 \\\"Hello, World\\\",最后使用

    2024年02月07日
    浏览(49)
  • java 输出hello world

    在 Java 中,可以使用 System.out.println 来输出 \\\"hello world\\\"。 例如: 在这段代码中, System.out.println 会将字符串 \\\"hello world\\\" 输出到控制台。 注意: 在 Java 中,类名的首字母必须大写。 main 方法是程序的入口点,必须要有这个方法才能运行程序。 `

    2024年02月10日
    浏览(41)
  • C++打印hello world

    首先我们要知道: C++中有一个很重要的东西,那就是面向对象,其中,C++中的打印和输入都是一个对象,而不是像C一样是一个函数,所以打印和输入都有一定的区别 打印是C++最基础的东西,下面我们先放代码,再逐条分析 首先是程序的入口:主函数。他先对于C有一定的区别

    2024年02月02日
    浏览(64)
  • Dart 入门Hello world

    1、下载Dart sdk IntelliJ Android Studio | Dart 2、安装Dart 插件 3、安装后重启IDEA,创建Dart项目   4、创建dart文件 5、编写函数:    6、运行:   官网学习:Dart 语言开发文档 | Dart

    2024年02月12日
    浏览(55)
  • C++,从“hello world“开始

    一、\\\"hello world\\\" 1.1 #include:预处理标识 1.2 iostream:输入输出流类所在头文件         1.2.1 istream:输入流类         1.2.2 ostream:输出流类 1.3 using namespace std:标准命名空间         1.3.1 using:使用命名空间         1.3.2 namespace:命名空间         1.3.2 std:标准命名空

    2024年02月11日
    浏览(32)
  • 用Rust打印hello world!

    桌面新建1个名为 rustDemo 的文件夹(文件夹名字随便取) 打开新建的文件夹,在地址输入栏输入 cmd  按回车键进入命令行窗口 打开编译器,按 Ctrl + S ,保存文件到 rustDemo 文件夹中,保存的文件我取名为 hello_world.rs 。文件名是随便取的,但是后缀一定要是 .rs 回到编译器中,

    2024年02月10日
    浏览(46)
  • 【Express.js】Hello World

    本节我们将创建并运行我们的第一个express.js项目,并使用最简单的请求响应 本书系统环境为 windows10 64Bit 请事先在你的开发环境中安装 Node.js ,本书使用的是 node v16.17.1 推荐使用 VsCode 作为开发工具,有良好的代码提示功能 事先安装一个api调试工具,如 postman , apipost 等 创建

    2024年02月09日
    浏览(63)
  • SpringBoot-Hello World

    创建Springboot工程,并勾选web开发相关依赖 定义HelloController类,添加方法hello,并添加相关注释 运行测试 几个注意的点: Name:基本上不用管,会根据下面的Arifact变更 Loaction:存储地址 Language:Java项目就选java呗 Type:我这里选的是Maven Group:域名反写(例如:com.taob),跟公司走

    2024年02月13日
    浏览(22)
  • 【03】第一行代码Hello World

    01.下载 地址:http://www.android-studio.org 下载完成后,先傻瓜式安装即可 02.创建第一行代码 打开Android Studio  选择Next  点击Finish,进入页面  启用模拟器:  选择Next后  选择系统版本号  选择Finish  运行 遇到的问题 1. 解决方法:  网上办法不可解决,后重新下载Android Studio即

    2024年02月16日
    浏览(42)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包