]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/docs/examples/overlay-triplets-linux-dynamic.md
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / docs / examples / overlay-triplets-linux-dynamic.md
CommitLineData
1e59de90
TL
1# Overlay triplets example\r
2\r
3## Building dynamic libraries on Linux\r
4\r
5Using **vcpkg** you can build libraries for many configurations out of the box. However, this doesn't currently include shared libraries on Linux and Mac OS.\r
6\r
7This doesn't mean that you cannot use **vcpkg** to build your dynamic libraries on these platforms! This document will guide you through creating your own custom triplets with `--overlay-triplets` to easily build dynamic libraries on Linux.\r
8\r
9### Step 1: Create the custom triplet files\r
10\r
11To save time, copy the existing `x64-linux.cmake` triplet file.\r
12\r
13```sh\r
14~/git$ mkdir custom-triplets\r
15~/git$ cp vcpkg/triplets/x64-linux.cmake custom-triplets/x64-linux-dynamic.cmake\r
16```\r
17\r
18And modify `custom-triplets/x64-linux-dynamic.cmake` to match the contents below:\r
19```cmake\r
20# ~/git/custom-triplets/x64-linux-dynamic.cmake\r
21set(VCPKG_TARGET_ARCHITECTURE x64)\r
22set(VCPKG_CRT_LINKAGE dynamic)\r
23set(VCPKG_LIBRARY_LINKAGE dynamic) # This changed from static to dynamic\r
24\r
25set(VCPKG_CMAKE_SYSTEM_NAME Linux)\r
26```\r
27\r
28### Step 2: Use `--overlay-triplets` to build dynamic libraries\r
29\r
30Use the `--overlay-triplets` option to include the triplets in the `custom-triplets` directory. \r
31\r
32```\r
33~/git$ vcpkg/vcpkg install sqlite3:x64-linux-dynamic --overlay-triplets=custom-triplets\r
34The following packages will be built and installed:\r
35 sqlite3[core]:x64-linux-dynamic\r
36Starting package 1/1: sqlite3:x64-linux-dynamic\r
37Building package sqlite3[core]:x64-linux-dynamic...\r
38-- Loading triplet configuration from: /home/victor/git/custom-triplets/x64-linux-dynamic.cmake\r
39-- Downloading https://sqlite.org/2019/sqlite-amalgamation-3280000.zip...\r
40-- Extracting source /home/victor/git/vcpkg/downloads/sqlite-amalgamation-3280000.zip\r
41-- Applying patch fix-arm-uwp.patch\r
42-- Using source at /home/victor/git/vcpkg/buildtrees/sqlite3/src/3280000-6a3ff7ce92\r
43-- Configuring x64-linux-dynamic-dbg\r
44-- Configuring x64-linux-dynamic-rel\r
45-- Building x64-linux-dynamic-dbg\r
46-- Building x64-linux-dynamic-rel\r
47-- Performing post-build validation\r
48-- Performing post-build validation done\r
49Building package sqlite3[core]:x64-linux-dynamic... done\r
50Installing package sqlite3[core]:x64-linux-dynamic...\r
51Installing package sqlite3[core]:x64-linux-dynamic... done\r
52Elapsed time for package sqlite3:x64-linux-dynamic: 44.82 s\r
53\r
54Total elapsed time: 44.82 s\r
55\r
56The package sqlite3:x64-linux-dynamic provides CMake targets:\r
57\r
58 find_package(unofficial-sqlite3 CONFIG REQUIRED)\r
59 target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)\r
60```\r
61\r
62Overlay triplets enables your custom triplet files when using `vcpkg install`, `vcpkg update`, `vcpkg upgrade`, and `vcpkg remove`.\r
63\r
64When using the `--overlay-triplets` option, a message like the following lets you know that a custom triplet is being used: \r
65\r
66```\r
67-- Loading triplet configuration from: /home/custom-triplets/x64-linux-dynamic.cmake\r
68```\r
69\r
70## Overriding default triplets\r
71\r
72As you may have noticed, the default triplets for Windows (`x86-windows` and `x64-windows`) install dynamic libraries, while a suffix (`-static`) is needed for static libraries. This is different with Linux and Mac OS where static libraries are built by `x64-linux` and `x64-osx`.\r
73\r
74Using `--overlay-triplets` it is possible to override the default triplets to accomplish the same behavior on Linux:\r
75\r
76* `x64-linux`: Builds dynamic libraries,\r
77* `x64-linux-static`: Builds static libraries.\r
78\r
79### Step 1: Create the overlay triplets\r
80\r
81Using the custom triplet created in the previous example, rename `custom-triplets/x64-linux-dynamic.cmake` to `custom-triplets/x64-linux.cmake`. Then, copy the default `x64-linux` triplet (which builds static libraries) in your `custom-triplets` folder and rename it to `x64-linux-static.cmake`.\r
82\r
83```sh\r
84~/git$ mv custom-triplets/x64-linux-dynamic.cmake custom-triplets/x64-linux.cmake\r
85~/git$ cp vcpkg/triplets/x64-linux.cmake custom-triplets/x64-linux-static.cmake\r
86```\r
87\r
88### Step 2: Use `--overlay-triplets` to override default triplets\r
89\r
90Use the `--overlay-triplets` option to include the triplets in the `custom-triplets` directory.\r
91\r
92```\r
93~/git$ vcpkg/vcpkg install sqlite3:x64-linux --overlay-triplets=custom-triplets\r
94The following packages will be built and installed:\r
95 sqlite3[core]:x64-linux\r
96Starting package 1/1: sqlite3:x64-linux\r
97Building package sqlite3[core]:x64-linux...\r
98-- Loading triplet configuration from: /home/victor/git/custom-triplets/x64-linux.cmake\r
99-- Downloading https://sqlite.org/2019/sqlite-amalgamation-3280000.zip...\r
100-- Extracting source /home/victor/git/vcpkg/downloads/sqlite-amalgamation-3280000.zip\r
101-- Applying patch fix-arm-uwp.patch\r
102-- Using source at /home/victor/git/vcpkg/buildtrees/sqlite3/src/3280000-6a3ff7ce92\r
103-- Configuring x64-linux-dbg\r
104-- Configuring x64-linux-rel\r
105-- Building x64-linux-dbg\r
106-- Building x64-linux-rel\r
107-- Performing post-build validation\r
108-- Performing post-build validation done\r
109Building package sqlite3[core]:x64-linux... done\r
110Installing package sqlite3[core]:x64-linux...\r
111Installing package sqlite3[core]:x64-linux... done\r
112Elapsed time for package sqlite3:x64-linux: 44.82 s\r
113\r
114Total elapsed time: 44.82 s\r
115\r
116The package sqlite3:x64-linux provides CMake targets:\r
117\r
118 find_package(unofficial-sqlite3 CONFIG REQUIRED)\r
119 target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)\r
120```\r
121\r
122Note that the default triplet is masked by your custom triplet:\r
123\r
124```\r
125-- Loading triplet configuration from: /home/victor/git/custom-triplets/x64-linux.cmake\r
126```\r