Open
Conversation
Deploying linux201-docs with
|
| Latest commit: |
2376e8f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b30b932f.linux201-docs.pages.dev |
| Branch Preview URL: | https://luojh-add-library-in-dev.linux201-docs.pages.dev |
…1-docs into luojh-add-library-in-dev
RTXUX
requested changes
Sep 2, 2025
iBug
requested changes
Sep 2, 2025
…1-docs into luojh-add-library-in-dev
Member
Author
|
这个 build CI failed 是正常的吧 @RTXUX |
ef01039 to
8d404dd
Compare
taoky
requested changes
Sep 2, 2025
| - Golang: dev/language/golang.md | ||
| - 版本管理与合作: dev/git.md | ||
| - SSH 使用技巧: dev/ssh.md | ||
| - dev/index.md |
| - Golang: dev/language/golang.md | ||
| - 版本管理与合作: dev/git.md | ||
| - SSH 使用技巧: dev/ssh.md | ||
| - Linux 上的链接库: dev/library.md |
Member
There was a problem hiding this comment.
层级需在「编程语言概览」下面,预期是在 cxx.md 里面。现在的内容量没法单列一个 page。
| @@ -0,0 +1,118 @@ | |||
| --- | |||
| icon: simple/cplusplus | |||
Member
There was a problem hiding this comment.
material/book 或者 material/book-cog 不错,material/bookmark-box 也行
| icon: simple/cplusplus | ||
| --- | ||
|
|
||
| # 链接库 |
|
|
||
| !!! comment "适用范围" | ||
|
|
||
| 本文介绍 Linux 上的**静态链接库** (一般为 `.a` 文件) 和**动态链接库** (一般为 `.so` 文件)。注意:这里的链接库是指包含了可执行二进制代码的库,并不是头文件 (Header file)、Python 库等。 |
| header["头文件 (*.h)"] --- source | ||
| target --> linker["链接器"] | ||
| staticlib["**静态链接库** (链接步骤加入)"] --> linker | ||
| linker --> executable["可执行文件 (ELF等)"] |
Member
There was a problem hiding this comment.
Suggested change
| linker --> executable["可执行文件 (ELF等)"] | |
| linker --> executable["可执行文件(ELF 等)"] |
taoky
requested changes
Sep 2, 2025
| 以便其他使用链接库的程序**知道如何使用这个函数** (即使这些程序不知道函数内部的实现)。 | ||
|
|
||
| 因为链接库不是完整的、可以独立运行的程序,因此不需要入口点 (比如 `main` 函数)。 | ||
|
|
docs/dev/library.md
Outdated
| header["头文件 (*.h)"] --- source | ||
| target -->|链接| executable["可执行文件 (ELF等)"] | ||
| target -->|ar rcs| staticlib["静态链接库 (*.a)"] | ||
| target -->|gcc -shared| dynamiclib["动态链接库 (*.a)"] |
Member
There was a problem hiding this comment.
Suggested change
| target -->|gcc -shared| dynamiclib["动态链接库 (*.a)"] | |
| target -->|<code>gcc -shared</code>| dynamiclib["动态链接库 (*.a)"] |
上面的 ar rcs 也可以这么做。
| int square(int x); | ||
| ``` | ||
|
|
||
| 以便其他使用链接库的程序**知道如何使用这个函数** (即使这些程序不知道函数内部的实现)。 |
tiankaima
reviewed
Sep 4, 2025
|
|
||
| 这里,`-L./lib` 表示要求链接器在 `./lib` 中寻找链接库,`-lsquare` 表示需要链接 `libsquare.a` 这个静态链接库文件。 | ||
|
|
||
| 编译好之后,就可以正常使用了。由于静态链接库中的代码会被直接合并到链接产生的可执行文件 `main` 中,因此运行时不需要文件 `libsquare.a`。 |
Member
There was a problem hiding this comment.
frankly 读到这里结束我稍微有点意外,更期待一点 in-depth 的内容……
目前这个内容量大概可以作为 101 的拓展内容……?如果介绍一些 LD_LIBRARY_PATH(例如不同 CUDA 版本等)/打包相关的也许更适合放在 201 一些。
…1-docs into luojh-add-library-in-dev
Member
Author
|
目前内容确实是偏少的,也和我最近正在准备这个稿子有关系。对于201来说,这个部分可能不只写链接库,可能更偏向于一个稍微丰富一些的C构建系统的介绍? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.