中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

佛山網(wǎng)站建設(shè)專家長沙企業(yè)seo服務(wù)

佛山網(wǎng)站建設(shè)專家,長沙企業(yè)seo服務(wù),b2b專門做機(jī)械的網(wǎng)站,短鏈接生成 草料使用conan包 - 安裝依賴項(xiàng) 主目錄 conan Using packages1 Requires2 Optional user/channel3 Overriding requirements4 Generators5 Options 本文是基于對conan官方文檔Installing dependencies的翻譯而來, 更詳細(xì)的信息可以去查閱conan官方文檔。 This section s…

使用conan包 - 安裝依賴項(xiàng)

  • 主目錄 conan Using packages
  • 1 Requires
  • 2 Optional user/channel
  • 3 Overriding requirements
  • 4 Generators
  • 5 Options

本文是基于對conan官方文檔Installing dependencies的翻譯而來, 更詳細(xì)的信息可以去查閱conan官方文檔。

This section shows how to setup your project and manage dependencies (i.e., install existing packages) with Conan.
本節(jié)將介紹如何使用 Conan 設(shè)置項(xiàng)目和管理依賴關(guān)系(即安裝現(xiàn)有軟件包)。

主目錄 conan Using packages

  • Installing dependencies
    • Requires
    • Generators
    • Options
  • Using profiles
  • Workflows
    • Single configuration
    • Multi configuration
  • Debugging packages

In Getting started we used the conan install command to download the Poco library and build an example.
在 "Getting started "部分,我們使用 conan install 命令下載了 Poco 庫并構(gòu)建了一個(gè)示例。

If you inspect the conanbuildinfo.cmake file that was created when running conan install, you can see there that there are many CMake variables declared. For example CONAN_INCLUDE_DIRS_ZLIB, that defines the include path to the zlib headers, and CONAN_INCLUDE_DIRS that defines include paths for all dependencies headers.
如果檢查運(yùn)行 conan install 時(shí)創(chuàng)建的 conanbuildinfo.cmake 文件,可以看到其中聲明了許多 CMake 變量。例如,CONAN_INCLUDE_DIRS_ZLIB 定義了 zlib 頭文件的包含路徑,而 CONAN_INCLUDE_DIRS 則定義了所有依賴頭文件的包含路徑。
在這里插入圖片描述
If you check the full path that each of these variables defines, you will see that it points to a folder under your folder. Together, these folders are the local cache. This is where package recipes and binary packages are stored and cached, so they don’t have to be retrieved again. You can inspect the local cache with conan search, and remove packages from it with conan remove command.
如果查看這些變量定義的完整路徑,你會發(fā)現(xiàn)它們都指向 <userhome> 文件夾下的一個(gè)文件夾。這些文件夾就是本地緩存。這就是軟件包recipes和二進(jìn)制軟件包的存儲和緩存位置,因此無需再次檢索。您可以使用 conan search 查看本地緩存,也可以使用 conan remove 命令刪除緩存中的軟件包。

If you navigate to the folders referenced in conanbuildinfo.cmake you will find the headers and libraries for each package.
如果您瀏覽 conanbuildinfo.cmake 中引用的文件夾,就會發(fā)現(xiàn)每個(gè)軟件包的頭文件和庫。

If you execute a conan install poco/1.9.4@ command in your shell, Conan will download the Poco package and its dependencies (openssl/1.0.2t and zlib/1.2.11) to your local cache and print information about the folder where they are installed. While you can install each of your dependencies individually like that, the recommended approach for handling dependencies is to use a conanfile.txt file. The structure of conanfile.txt is described below.
如果在 shell 中執(zhí)行 conan install poco/1.9.4@ 命令,Conan 會將 Poco 軟件包及其依賴包(openssl/1.0.2tzlib/1.2.11)下載到本地緩存,并打印安裝文件夾的相關(guān)信息。您可以像這樣單獨(dú)安裝每個(gè)依賴項(xiàng),但處理依賴項(xiàng)的推薦方法是使用 conanfile.txt 文件。conanfile.txt 的結(jié)構(gòu)如下描述所示。

1 Requires

The required dependencies should be specified in the [requires] section. Here is an example:
應(yīng)在 [requires] 部分指定所需的依賴項(xiàng)。下面是一個(gè)例子:

[requires]
mypackage/1.0.0@company/stable

Where:

  • mypackage is the name of the package which is usually the same as the project/library.
  • mypackage 是軟件包的名稱,通常與項(xiàng)目/庫的名稱相同。
  • 1.0.0 is the version which usually matches that of the packaged project/library. This can be any string; it does not have to be a number, so, for example, it could indicate if this is a “develop” or “master” version. Packages can be overwritten, so it is also OK to have packages like “nightly” or “weekly”, that are regenerated periodically.
  • 1.0.0 是版本,通常與打包項(xiàng)目/庫的版本一致。它可以是任何字符串,不一定是數(shù)字,例如,它可以表示這是 "develop "還是 "master "版本。軟件包可以被覆蓋,因此也可以使用 "nightly "或 "weekly "這樣的軟件包,它們會定期重新生成。
  • company is the owner of this package. It is basically a namespace that allows different users to have their own packages for the same library with the same name.
  • company是該軟件包的所有者。它基本上是一個(gè)命名空間,允許不同用戶為同一個(gè)庫擁有自己的同名軟件包。
  • stable is the channel. Channels provide another way to have different variants of packages for the same library and use them interchangeably. They usually denote the maturity of the package as an arbitrary string such as “stable” or “testing”, but they can be used for any purpose such as package revisions (e.g., the library version has not changed, but the package recipe has evolved).
  • stable就是channel。channel為同一庫提供了另一種擁有不同變體軟件包并可互換使用的方式。它們通常以任意字符串(如 "stable "或 “testing”)表示軟件包的成熟度,但也可用于任何目的,如軟件包的修訂(例如,庫的版本沒有變化,但軟件包的recipe發(fā)生了變化)。

2 Optional user/channel

If the package was created and uploaded without specifying the user and channel you can omit the user/channel when specifying a reference:
如果創(chuàng)建和上傳軟件包時(shí)沒有指定userchannel,則可以在指定引用時(shí)省略user/channel

[requires]
packagename/1.2.0

3 Overriding requirements

You can specify multiple requirements and override transitive “require’s requirements”. In our example, Conan installed the Poco package and all its requirements transitively:
您可以指定多個(gè)需求,并覆蓋傳遞性的 “require’s requirements”。在我們的示例中,conan安裝了 Poco 軟件包及其所有需求:

  • openssl/1.0.2t
  • zlib/1.2.11

Tip
This is a good example of overriding requirements given the importance of keeping the OpenSSL library updated.
鑒于保持更新 OpenSSL 庫的重要性,這是一個(gè)overriding requirements的好例子。
Consider that a new release of the OpenSSL library has been released, and a new corresponding Conan package is available. In our example, we do not need to wait until pocoproject (the author) generates a new package of POCO that includes the new OpenSSL library.
考慮到 OpenSSL 庫的新版本已經(jīng)發(fā)布,相應(yīng)的新 Conan 軟件包也已可用。在我們的示例中,我們不需要等到 pocoproject(作者)生成包含新 OpenSSL 庫的 POCO 新軟件包。

We can simply enter the new version in the [requires] section:
我們只需在【requires】部分輸入新版本即可:

[requires]
poco/1.9.4
openssl/1.0.2u

The second line will override the openssl/1.0.2t required by POCO with the currently non-existent openssl/1.0.2u.
第二行將用目前不存在的 openssl/1.0.2u 覆蓋 POCO 所需的 openssl/1.0.2t。

Another example in which we may want to try some new zlib alpha features: we could replace the zlib requirement with one from another user or channel.
另一個(gè)例子是,我們可能想嘗試一些新的 zlib alpha 功能:我們可以用另一個(gè)user 或 channel的 zlib 需求來替換。

[requires]
poco/1.9.4
openssl/1.0.2u
zlib/1.2.11@otheruser/alpha

Note
You can use environment variable CONAN_ERROR_ON_OVERRIDE to raise an error for every overridden requirement not marked explicitly with the override keyword.
你可以使用環(huán)境變量 CONAN_ERROR_ON_OVERRIDE,為每一個(gè)未明確標(biāo)記覆蓋關(guān)鍵字的覆蓋需求引發(fā)錯(cuò)誤。

4 Generators

Conan reads the [generators] section from conanfile.txt and creates files for each generator with all the information needed to link your program with the specified requirements. The generated files are usually temporary, created in build folders and not committed to version control, as they have paths to local folders that will not exist in another machine. Moreover, it is very important to highlight that generated files match the given configuration (Debug/Release, x86/x86_64, etc) specified when running conan install. If the configuration changes, the files will change accordingly.
Conan 會讀取 conanfile.txt 中的 [generators] 部分,并為每個(gè)生成器(generator)創(chuàng)建文件,其中包含將程序與指定要求鏈接到您自己程序所需的所有信息。生成的文件通常是臨時(shí)文件,創(chuàng)建在構(gòu)建文件夾中,不會提交到版本控制中,因?yàn)樗鼈兊穆窂街赶虮镜匚募A,而這些文件夾在另一臺機(jī)器中并不存在。此外,必須確保生成的文件與運(yùn)行 conan install 時(shí)指定的配置(Debug/Release、x86/x86_64 等)相匹配。如果配置更改,文件也會相應(yīng)更改。

For a full list of generators, please refer to the complete generators reference.、
有關(guān)generators的完整列表,請參閱完整的generators參考資料。

5 Options

We have already seen that there are some settings that can be specified during installation. For example, conan install .. -s build_type=Debug. These settings are typically a project-wide configuration defined by the client machine, so they cannot have a default value in the recipe. For example, it doesn’t make sense for a package recipe to declare “Visual Studio” as a default compiler because that is something defined by the end consumer, and unlikely to make sense if they are working in Linux.
我們已經(jīng)看到,在安裝過程中可以指定一些設(shè)置。例如,conan install ... -s build_type=Debug。這些設(shè)置通常是由客戶機(jī)器定義的項(xiàng)目范圍內(nèi)的配置,因此它們在recipe中不可能有默認(rèn)值。例如,在軟件包配方中將 "Visual Studio "聲明為默認(rèn)編譯器是不合理的,因?yàn)檫@是由最終用戶定義的,如果他們在 Linux 中工作,就不可能將其作為默認(rèn)編譯器。

On the other hand, options are intended for package specific configuration that can be set to a default value in the recipe. For example, one package can define that its default linkage is static, and this is the linkage that should be used if consumers don’t specify otherwise.
另一方面,options用于軟件包的特定配置,可以在recipe中設(shè)置為默認(rèn)值。例如,一個(gè)軟件包可以定義其默認(rèn)鏈接為靜態(tài)鏈接,如果消費(fèi)者沒有另行指定,就應(yīng)該使用這種鏈接。

Note
You can see the available options for a package by inspecting the recipe with conan get <reference> command:
使用 conan get <reference> 命令查看配方,可以看到軟件包的可用選項(xiàng):

$ conan get poco/1.9.4@

To see only specific fields of the recipe you can use the conan inspect command instead:
如果只想查看配方的特定字段,可以使用 conan inspect 命令:

$ conan inspect poco/1.9.4@ -a=options
$ conan inspect poco/1.9.4@ -a=default_options

For example, we can modify the previous example to use dynamic linkage instead of the default one, which was static, by editing the [options] section in conanfile.txt:
例如,我們可以通過編輯 conanfile.txt 中的 [options] 部分,修改前面的示例,使用動態(tài)鏈接,而不是默認(rèn)的靜態(tài)鏈接:

[requires]
poco/1.9.4[generators]
cmake[options]
poco:shared=True # PACKAGE:OPTION=VALUE
openssl:shared=True

Install the requirements and compile from the build folder (change the CMake generator if not in Windows):
安裝requirements并從構(gòu)建文件夾編譯(如果不是在 Windows 系統(tǒng)中,請更改 CMake 生成器):

$ conan install ..
$ cmake .. -G "Visual Studio 14 Win64"
$ cmake --build . --config Release

As an alternative to defining options in the conanfile.txt file, you can specify them directly in the command line:
除了在 conanfile.txt 文件中定義選項(xiàng)外,還可以直接在命令行中指定選項(xiàng):

$ conan install .. -o poco:shared=True -o openssl:shared=True
# or even with wildcards, to apply to many packages
$ conan install .. -o *:shared=True

Conan will install the binaries of the shared library packages, and the example will link with them. You can again inspect the different binaries installed. For example, conan search zlib/1.2.11@.
Conan 將安裝共享庫軟件包的二進(jìn)制文件,示例將與它們鏈接。你可以再次檢查安裝的不同二進(jìn)制文件。例如,Conan 搜索 zlib/1.2.11@。

Finally, launch the executable:
最后,加載可執(zhí)行文件:

$ ./bin/md5

What happened? It fails because it can’t find the shared libraries in the path. Remember that shared libraries are used at runtime, so the operating system, which is running the application, must be able to locate them.
發(fā)生了什么?失敗的原因是在路徑中找不到共享庫。請記住,共享庫是在運(yùn)行時(shí)使用的,因此運(yùn)行應(yīng)用程序的操作系統(tǒng)必須能夠找到它們。

We could inspect the generated executable, and see that it is using the shared libraries. For example, in Linux, we could use the objdump tool and see the Dynamic section:
我們可以檢查生成的可執(zhí)行文件,看看它是否使用了共享庫。例如,在 Linux 中,我們可以使用 objdump 工具查看動態(tài)部分:

$ cd bin
$ objdump -p md5
...
Dynamic Section:NEEDED               libPocoUtil.so.31NEEDED               libPocoXML.so.31NEEDED               libPocoJSON.so.31NEEDED               libPocoMongoDB.so.31NEEDED               libPocoNet.so.31NEEDED               libPocoCrypto.so.31NEEDED               libPocoData.so.31NEEDED               libPocoDataSQLite.so.31NEEDED               libPocoZip.so.31NEEDED               libPocoFoundation.so.31NEEDED               libpthread.so.0NEEDED               libdl.so.2NEEDED               librt.so.1NEEDED               libssl.so.1.0.0NEEDED               libcrypto.so.1.0.0NEEDED               libstdc++.so.6NEEDED               libm.so.6NEEDED               libgcc_s.so.1NEEDED               libc.so.6
http://www.risenshineclean.com/news/2379.html

相關(guān)文章:

  • 遼寧省住房和城鄉(xiāng)建設(shè)廳網(wǎng)站進(jìn)不去長春網(wǎng)站制作公司
  • 做網(wǎng)站模板賺錢關(guān)鍵詞優(yōu)化計(jì)劃
  • 鋼模板規(guī)格尺寸及厚度百度網(wǎng)站怎么優(yōu)化排名靠前
  • 龍采網(wǎng)站建設(shè)揚(yáng)州整站seo
  • 廣州市品牌網(wǎng)站建設(shè)服務(wù)機(jī)構(gòu)電商網(wǎng)絡(luò)推廣怎么做
  • 河南鄭州網(wǎng)站制作公司百度seo營銷
  • 中文網(wǎng)站建設(shè)中模板下載全網(wǎng)熱搜榜第一名
  • 網(wǎng)站案例seo網(wǎng)站優(yōu)化價(jià)格
  • 局域網(wǎng)創(chuàng)建網(wǎng)站路由器優(yōu)化大師
  • 重慶網(wǎng)站推廣外包企業(yè)競價(jià)推廣培訓(xùn)課程
  • 網(wǎng)站自己做服務(wù)器劃算嗎龍崗網(wǎng)站建設(shè)
  • 做網(wǎng)站開視頻網(wǎng)站關(guān)鍵詞排名優(yōu)化易下拉軟件
  • 遵義疫情最新數(shù)據(jù)消息百度小程序優(yōu)化排名
  • 網(wǎng)站開發(fā)和程序開發(fā)的卻別網(wǎng)絡(luò)營銷推廣8種方法
  • 網(wǎng)站備案主體撤銷2023年6月疫情情況
  • 網(wǎng)站設(shè)計(jì)過程南寧關(guān)鍵詞排名公司
  • 余姚網(wǎng)站建設(shè)62752762最佳磁力吧ciliba搜索引擎
  • 貴陽商城網(wǎng)站建設(shè)搜索引擎的工作原理是什么?
  • 廣州網(wǎng)絡(luò)營銷網(wǎng)站建設(shè)揚(yáng)中網(wǎng)站制作
  • 做盜版電影網(wǎng)站犯法嗎十大經(jīng)典事件營銷案例
  • 手機(jī)網(wǎng)站營銷的含義建設(shè)網(wǎng)站的網(wǎng)絡(luò)公司
  • 服務(wù)器平臺有哪些南昌seo網(wǎng)站排名
  • 建個(gè)企業(yè)網(wǎng)站一年多少錢3步打造seo推廣方案
  • 網(wǎng)站域名所有人東莞網(wǎng)站建設(shè)平臺
  • 網(wǎng)站制作關(guān)鍵百度愛采購服務(wù)商查詢
  • 自己制作網(wǎng)站找客源免費(fèi)用哪個(gè)軟件好
  • 北京網(wǎng)頁制作網(wǎng)站軟文代理平臺
  • 烏魯木齊做網(wǎng)站頭條號權(quán)重查詢
  • 如何做視頻網(wǎng)站技術(shù)網(wǎng)站開發(fā)費(fèi)用
  • 網(wǎng)站需求分析文檔網(wǎng)絡(luò)輿情監(jiān)測