Skip to content

Commit 194e623

Browse files
committed
完善《安装》和《快速入门》,纠正错误代码
1 parent 0b6d485 commit 194e623

File tree

9 files changed

+524
-167
lines changed

9 files changed

+524
-167
lines changed

docs/guide/2-installation.md

+72-15
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,103 @@
11
# 安装
22

3-
有多种方法安装 LCUI,但在此之前你需要安装以下工具:
3+
本章节将为你介绍多种安装方式,帮助你完成 LCUI 项目的设置。
44

5-
- [XMake](https://xmake.io/#/zh-cn/getting_started?id=%e5%ae%89%e8%a3%85)
6-
- [Git](https://git-scm.com/downloads)
5+
## 先决条件
6+
7+
在开始安装之前,你需要准备以下条件:
8+
9+
- **操作系统:** 推荐使用 Windows。因为 LCUI 主要在 Windows 中开发和测试,所以对 Windows 的支持度更高。
10+
- **终端:** 用于执行命令。
11+
- **文本编辑器:** 推荐使用 [Visual Studio Code](https://code.visualstudio.com/)
12+
- [Node.js](https://nodejs.org/zh-cn):JavaScript 运行时环境,用于运行开发工具。
13+
- [XMake](https://xmake.io/#/zh-cn/getting_started?id=%e5%ae%89%e8%a3%85):C/C++ 构建工具。
14+
- [Git](https://git-scm.com/downloads):代码库版本管理工具,用于下载和管理代码库。
15+
16+
## 使用命令行工具安装
17+
18+
:::note
19+
本方法适合创建一个新的 LCUI 项目。
20+
:::
21+
22+
首先,打开一个终端(如果你使用的是 [Visual Studio Code](https://code.visualstudio.com/), 则可以打开[集成终端](https://code.visualstudio.com/docs/editor/integrated-terminal)),然后运行以下命令安装 LCUI 的命令行开发工具。
23+
24+
```bash
25+
npm install -g @lcui/cli
26+
```
27+
28+
安装完成后,运行 `lcui create` 命令并指定项目名称。在下面的示例中,我们将使用示例项目名称 `my-lcui-app`
29+
30+
```bash
31+
lcui create <项目名称>
32+
```
33+
34+
你应该会看到以下信息:
35+
36+
```text
37+
正在下载项目模板:https://gitee.com/lcui-dev/lcui-quick-start.git
38+
正在为项目初始化 Git 仓库
39+
正在安装依赖项
40+
已成功创建项目 my-lcui-app
41+
使用以下命令开始体验:
42+
43+
$ cd my-lcui-app
44+
$ lcui build
45+
$ xmake run app
46+
```
47+
48+
现在,你已经创建了 LCUI 项目,执行上面信息中给出的命令即可构建和运行它。
749

850
## 从源码目录安装
951

10-
假设应用程序项目目录中有个 vendor 目录专用于存放第三方库的源码,那么我们可以手动下载 LCUI 的源码包然后解压到 vendor 目录中,再将 LCUI 的 xmake.lua 包含进来即可:
52+
:::note
53+
这种方法适合为已有的项目安装 LCUI,不过该项目使用的构建工具必须是 [XMake](https://xmake.io)
54+
:::
55+
56+
假设你的项目目录中有个 `vendor` 目录专用于存放第三方库的源码,那么你可以手动[下载 LCUI 的源码包](https://gitee.com/lc-soft/LCUI/repository/archive/develop.zip)然后解压到 vendor 目录中,再将 LCUI 的 xmake.lua 文件包含进来:
1157

1258
```lua title="xmake.lua"
59+
add_rules("mode.debug", "mode.release")
60+
-- highlight-next-line
1361
includes("vendor/LCUI/xmake.lua")
1462

1563
target("app")
1664
set_kind("binary")
65+
-- highlight-next-line
1766
add_deps("lcui")
67+
add_files("src/*.c")
1868
```
1969

20-
这种方式在需要升级 LCUI 版本的时候比较麻烦,可改用 git submodule 代替它
70+
这种方式在需要升级 LCUI 版本的时候比较麻烦,推荐用 Git 子模块代替它
2171

2272
```sh
2373
git submodule add https://gitee.com/lc-soft/LCUI.git vendor/LCUI
2474
git submodule update --init --recursive
2575
```
2676

27-
更新版本
77+
在需要更新版本的时候,执行以下命令
2878

2979
```sh
30-
git submodule sync --recursive
31-
git submodule update --init --recursive
80+
git submodule update --recursive --remote
3281
```
3382

3483
## 从已编译的文件包安装
3584

36-
下载 LCUI 的已编译的文件包,解压到特定的目录内,例如:vendor 目录,然后添加编译和链接配置:
85+
:::note
86+
本方法能让你使用自己熟悉的构建工具来管理对 LCUI 库的依赖,但由于 LCUI 的依赖库较多,相关配置可能会比较繁琐。
87+
:::
3788

38-
```lua title="xmake.lua"
39-
target("myapp")
40-
add_includedirs("vendor/include")
41-
add_linkdirs("vendor/lib")
42-
add_links("lcui")
43-
```
89+
我们假设你已经熟练掌握一种构建工具,能够配置依赖库的编译参数和链接参数,并能解决常见的编译和链接错误。
90+
91+
首先,访问 [LCUI 的发行版页面](https://gitee.com/lc-soft/LCUI/releases) 下载已编译的文件包,然后解压到特定的目录内,再添加相关编译和链接配置。之后安装 LCUI 的依赖库:
92+
93+
- libyaml
94+
- libpng
95+
- libjpeg
96+
- freetype
97+
- fontconfig (仅在 Linux 系统中使用)
98+
- libx11 (仅在 Linux 系统中使用)
99+
- libomp
100+
- libxml2
44101

45102
## 有其它建议?
46103

0 commit comments

Comments
 (0)