New translations library-project.mdx (Russian)

[ci skip]
This commit is contained in:
2026-07-06 02:21:28 +08:00
parent 57c35a1c99
commit 7203996588

View File

@@ -1,16 +1,15 @@
--- ---
sidebar_label: Library project sidebar_label: Проект библиотеки
--- ---
# Library Project # Проект библиотеки
Creating a static library and using it in another project. Создание статической библиотеки и её использование в другом проекте.
## Step 1: Create the library ## Шаг 1: Создать библиотеку
```bash ```bash
dcr new my-lib dcr new my-lib
cd my-lib
``` ```
`dcr.toml`: `dcr.toml`:
@@ -19,11 +18,11 @@ cd my-lib
[package] [package]
name = "my-lib" name = "my-lib"
version = "0.1.0" version = "0.1.0"
type = "none" type = "lib"
[build] [build]
language = "c" language = "c"
standard = "c11" standard = "c17"
kind = "staticlib" kind = "staticlib"
``` ```
@@ -43,28 +42,29 @@ int add(int a, int b);
int add(int a, int b) { return a + b; } int add(int a, int b) { return a + b; }
``` ```
## Step 2: Build ## Шаг 2: Собрать
```bash ```bash
cd my-lib
dcr build --release dcr build --release
``` ```
Artifacts: Артефакты:
* `target/\<triple>/release/libmy-lib.a` (Linux) * `target/release/libmy-lib.a` (Linux/macOS)
* `target/release/my-lib.lib` (Windows) * `target/release/my-lib.lib` (Windows)
* `target/include/` — header files * `target/include/` — заголовочные файлы
## Step 3: Use in another project ## Шаг 3: Использовать в проекте
```bash ```bash
dcr new my-app dcr new my-app
cd my-app cd my-app
dcr add my-lib ../my-lib dcr add ../my-lib
``` ```
Automatically: Автоматически:
* Adds include path to `target/include/` of the library * Добавляется include path на `target/include/` библиотеки
* Adds lib path to `target/\<triple>/release/` * Добавляется lib path на `target/release/`
* Links `libmy-lib.a` / `my-lib.lib` * Линкуется `libmy-lib.a` / `my-lib.lib`