-
Notifications
You must be signed in to change notification settings - Fork 16
Luojh add library in dev #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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
…1-docs into luojh-add-library-in-dev
这个 build CI failed 是正常的吧 @RTXUX |
ef01039
to
8d404dd
Compare
- Golang: dev/language/golang.md | ||
- 版本管理与合作: dev/git.md | ||
- SSH 使用技巧: dev/ssh.md | ||
- dev/index.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要修改这个文件的 indentation
- Golang: dev/language/golang.md | ||
- 版本管理与合作: dev/git.md | ||
- SSH 使用技巧: dev/ssh.md | ||
- Linux 上的链接库: dev/library.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
层级需在「编程语言概览」下面,预期是在 cxx.md 里面。现在的内容量没法单列一个 page。
@@ -0,0 +1,118 @@ | |||
--- | |||
icon: simple/cplusplus |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换个图标,和 C/C++ 的重复了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
material/book 或者 material/book-cog 不错,material/bookmark-box 也行
icon: simple/cplusplus | ||
--- | ||
|
||
# 链接库 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
主标题名称需与 nav 里面一致。
|
||
!!! comment "适用范围" | ||
|
||
本文介绍 Linux 上的**静态链接库** (一般为 `.a` 文件) 和**动态链接库** (一般为 `.so` 文件)。注意:这里的链接库是指包含了可执行二进制代码的库,并不是头文件 (Header file)、Python 库等。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
括号内包含中文的情况下使用全角括号,下面其他的也一样。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header file 不需要大写,header file 就够了
header["头文件 (*.h)"] --- source | ||
target --> linker["链接器"] | ||
staticlib["**静态链接库** (链接步骤加入)"] --> linker | ||
linker --> executable["可执行文件 (ELF等)"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linker --> executable["可执行文件 (ELF等)"] | |
linker --> executable["可执行文件(ELF 等)"] |
以便其他使用链接库的程序**知道如何使用这个函数** (即使这些程序不知道函数内部的实现)。 | ||
|
||
因为链接库不是完整的、可以独立运行的程序,因此不需要入口点 (比如 `main` 函数)。 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
介绍一下 extern
。
docs/dev/library.md
Outdated
header["头文件 (*.h)"] --- source | ||
target -->|链接| executable["可执行文件 (ELF等)"] | ||
target -->|ar rcs| staticlib["静态链接库 (*.a)"] | ||
target -->|gcc -shared| dynamiclib["动态链接库 (*.a)"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target -->|gcc -shared| dynamiclib["动态链接库 (*.a)"] | |
target -->|<code>gcc -shared</code>| dynamiclib["动态链接库 (*.a)"] |
上面的 ar rcs
也可以这么做。
int square(int x); | ||
``` | ||
|
||
以便其他使用链接库的程序**知道如何使用这个函数** (即使这些程序不知道函数内部的实现)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有必要讲一下预处理。
|
||
这里,`-L./lib` 表示要求链接器在 `./lib` 中寻找链接库,`-lsquare` 表示需要链接 `libsquare.a` 这个静态链接库文件。 | ||
|
||
编译好之后,就可以正常使用了。由于静态链接库中的代码会被直接合并到链接产生的可执行文件 `main` 中,因此运行时不需要文件 `libsquare.a`。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frankly 读到这里结束我稍微有点意外,更期待一点 in-depth 的内容……
目前这个内容量大概可以作为 101 的拓展内容……?如果介绍一些 LD_LIBRARY_PATH(例如不同 CUDA 版本等)/打包相关的也许更适合放在 201 一些。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在这个分量确实是不够的
…1-docs into luojh-add-library-in-dev
目前内容确实是偏少的,也和我最近正在准备这个稿子有关系。对于201来说,这个部分可能不只写链接库,可能更偏向于一个稍微丰富一些的C构建系统的介绍? |
No description provided.