glibc.xml 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-system-glibc" role="wrap">
  8. <?dbhtml filename="glibc.html"?>
  9. <sect1info condition="script">
  10. <productname>glibc</productname>
  11. <productnumber>&glibc-version;</productnumber>
  12. <address>&glibc-url;</address>
  13. </sect1info>
  14. <title>Glibc-&glibc-version;</title>
  15. <indexterm zone="ch-system-glibc">
  16. <primary sortas="a-Glibc">Glibc</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <!--para>The Glibc package contains the main C library. This library provides
  21. the basic routines for allocating memory, searching directories, opening and
  22. closing files, reading and writing files, string handling, pattern matching,
  23. arithmetic, and so on.</para-->
  24. <para>Glibc 软件包包含主要的 C 语言库。它提供用于分配内存、检索目录、
  25. 打开和关闭文件、读写文件、字符串处理、模式匹配、
  26. 算术等用途的基本子程序。</para>
  27. <segmentedlist>
  28. <segtitle>&buildtime;</segtitle>
  29. <segtitle>&diskspace;</segtitle>
  30. <seglistitem>
  31. <seg>&glibc-ch6-sbu;</seg>
  32. <seg>&glibc-ch6-du;</seg>
  33. </seglistitem>
  34. </segmentedlist>
  35. </sect2>
  36. <sect2 role="installation">
  37. <title>安装 Glibc</title>
  38. <note><!--para>The Glibc build system is self-contained and will install
  39. perfectly, even though the compiler specs file and linker are still
  40. pointing to <filename class="directory">/tools</filename>. The specs
  41. and linker cannot be adjusted before the Glibc install because the
  42. Glibc autoconf tests would give false results and defeat the goal
  43. of achieving a clean build.</para-->
  44. <para> Glibc 构建系统是自给自足的,
  45. 即使编译器 specs 文件和链接器仍然指向
  46. <filename class="directory">/tools</filename>,
  47. 也能完美地安装 Glibc 。在安装 Glibc 之前不能调整工具链,
  48. 否则 Glibc 的 autoconf 测试会给出错误结果,
  49. 结果无法达成干净地构建 Glibc 这一目的。</para>
  50. </note>
  51. <!--para>Some of the Glibc programs use the non-FHS compilant
  52. <filename class="directory">/var/db</filename> directory to store
  53. their runtime data. Apply the following patch to make such programs
  54. store their runtime data in the FHS-compliant locations:</para-->
  55. <para>某些 Glibc 程序使用与 FHS 不兼容的
  56. <filename class="directory">/var/db</filename>
  57. 目录存放运行时数据。应用下列补丁,
  58. 使得这些程序在 FHS 兼容的位置存储运行时数据:</para>
  59. <screen><userinput remap="pre">patch -Np1 -i ../&glibc-fhs-patch;</userinput></screen>
  60. <!--
  61. <para>Fix a minor security issue with glob functions:</para>
  62. <screen><userinput remap="pre">patch -Np1 -i ../&glibc-glob-patch;</userinput></screen>
  63. -->
  64. <!--para>First create a compatibility symlink to avoid references to /tools in
  65. our final glibc:</para-->
  66. <para>创建一个与最终的 LFS 系统兼容的符号链接,
  67. 避免最终的 Glibc 包含对 /tools 的引用:
  68. </para>
  69. <screen><userinput remap="pre">ln -sfv /tools/lib/gcc /usr/lib</userinput></screen>
  70. <!--para>Determine the GCC include directory and create a symlink for LSB
  71. compliance. Additionally, for x86_64, create a compatibility symlink
  72. required for the dynamic loader to function correctly:</para-->
  73. <para>判定 GCC 包含文件目录,并为了兼容 LSB 创建一个符号链接。另外,
  74. 对于 x86_64 ,还要创建一个动态链接器的兼容性符号链接,
  75. 使它能够正常工作:</para>
  76. <screen><userinput remap="pre">case $(uname -m) in
  77. i?86) GCC_INCDIR=/usr/lib/gcc/$(uname -m)-pc-linux-gnu/&gcc-version;/include
  78. ln -sfv ld-linux.so.2 /lib/ld-lsb.so.3
  79. ;;
  80. x86_64) GCC_INCDIR=/usr/lib/gcc/x86_64-pc-linux-gnu/&gcc-version;/include
  81. ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64
  82. ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
  83. ;;
  84. esac</userinput></screen>
  85. <!--para>Remove a file that may be left over from a previous build attempt:
  86. </para-->
  87. <para>删除上次编译时可能留下的文件:</para>
  88. <note><title>译注</title>
  89. <para>译者的惨痛教训表明,如果存在这个文件,
  90. 构建系统会无限循环。</para>
  91. </note>
  92. <screen><userinput remap="pre">rm -f /usr/include/limits.h</userinput></screen>
  93. <!--para>The Glibc documentation recommends building Glibc
  94. in a dedicated build directory:</para-->
  95. <para>Glibc 文档推荐在专用目录中构建它:</para>
  96. <screen><userinput remap="pre">mkdir -v build
  97. cd build</userinput></screen>
  98. <para>准备安装 Glibc:</para>
  99. <screen><userinput remap="configure">CC="gcc -isystem $GCC_INCDIR -isystem /usr/include" \
  100. ../configure --prefix=/usr \
  101. --disable-werror \
  102. --enable-kernel=&min-kernel; \
  103. --enable-stack-protector=strong \
  104. libc_cv_slibdir=/lib
  105. unset GCC_INCDIR</userinput></screen>
  106. <variablelist>
  107. <title>新的配置选项和参数的含义:</title>
  108. <varlistentry>
  109. <term><parameter>CC="gcc -isystem $GCC_INCDIR -isystem /usr/include"</parameter></term>
  110. <listitem>
  111. <!--para>Setting the location of both gcc and system include directories
  112. avoids introduction of invalid paths in debugging symbols.</para-->
  113. <para>设定 GCC 和系统的包含文件目录,避免调试符号中包含无效路径。
  114. </para>
  115. </listitem>
  116. </varlistentry>
  117. <varlistentry>
  118. <term><parameter>--disable-werror</parameter></term>
  119. <listitem>
  120. <!--para>This option disables the -Werror option passed to
  121. GCC. This is necessary for running the test suite.</para-->
  122. <para>该选项禁用 GCC 的 -Werror 选项,
  123. 这对于运行测试套件来说是必须的。</para>
  124. </listitem>
  125. </varlistentry>
  126. <varlistentry>
  127. <term><parameter>--enable-stack-protector=strong</parameter></term>
  128. <listitem>
  129. <!--para>This option increases system security by adding
  130. extra code to check for buffer overflows, such as stack
  131. smashing attacks.</para-->
  132. <para>该选项通过加入额外代码,
  133. 对栈溢出攻击等导致的缓冲区溢出进行检查,以提高系统安全性。
  134. </para>
  135. </listitem>
  136. </varlistentry>
  137. <varlistentry>
  138. <term><parameter>libc_cv_slibdir=/lib</parameter></term>
  139. <listitem>
  140. <para>这个变量纠正库文件安装位置,
  141. 我们不希望使用 lib64 目录。</para>
  142. </listitem>
  143. </varlistentry>
  144. </variablelist>
  145. <para>编译该软件包:</para>
  146. <screen><userinput remap="make">make</userinput></screen>
  147. <important>
  148. <!--para>In this section, the test suite for Glibc is considered critical.
  149. Do not skip it under any circumstance.</para-->
  150. <para>在本节中, Glibc 的测试套件十分关键,在任何情况下都不能跳过。
  151. </para>
  152. </important>
  153. <!--para>Generally a few tests do not pass. The test failures listed below
  154. are usually safe to ignore.</para-->
  155. <para>通常来说,可能会有极少数测试不能通过,
  156. 下面列出的失败结果一般可以安全地忽略。执行以下命令进行测试:
  157. </para>
  158. <screen><userinput remap="test">make check</userinput></screen>
  159. <!--para>You may see some test failures. The Glibc test suite is
  160. somewhat dependent on the host system. This is a list of the most common
  161. issues seen for some versions of LFS:</para-->
  162. <para>您可能看到一些失败结果。
  163. Glibc 的测试套件和宿主系统之间有某种依赖关系,以下是在一些版本的
  164. LFS 上最常见的问题:</para>
  165. <itemizedlist>
  166. <listitem>
  167. <para>已知 <emphasis>misc/tst-ttyname</emphasis>
  168. 在 LFS chroot 环境中会失败。</para>
  169. </listitem>
  170. <listitem>
  171. <para>已知 <emphasis>posix/tst-getaddrinfo4</emphasis> 和
  172. <emphasis>posix/tst-getaddrinfo5</emphasis>
  173. 在某些硬件架构上会失败。</para>
  174. </listitem>
  175. <!--
  176. <listitem>
  177. <para>The <emphasis>rt/tst-cputimer1</emphasis> and
  178. <emphasis>rt/tst-cpuclock2</emphasis> tests have been known to
  179. fail. The reason is not completely understood, but indications are
  180. that minor timing issues can trigger these failures.</para>
  181. </listitem>
  182. <listitem>
  183. <para>The math tests sometimes fail when running on
  184. systems where the CPU is not a relatively new Intel or
  185. AMD processor.</para>
  186. </listitem>
  187. <listitem>
  188. <para>The
  189. <emphasis>nptl/tst-thread-affinity-{pthread,pthread2,sched}</emphasis>
  190. tests may fail for reasons that have not been determined. </para>
  191. </listitem>
  192. <listitem>
  193. <para>Other tests known to fail on some architectures are
  194. malloc/tst-malloc-usable and nptl/tst-cleanupx4. </para>
  195. </listitem>
  196. -->
  197. </itemizedlist>
  198. <!--para>Though it is a harmless message, the install stage of Glibc will
  199. complain about the absence of <filename>/etc/ld.so.conf</filename>.
  200. Prevent this warning with:</para-->
  201. <para>在安装 Glibc 时,它会抱怨文件 <filename>/etc/ld.so.conf</filename>
  202. 不存在。尽管这是一条无害的消息,执行以下命令即可防止这个警告:
  203. </para>
  204. <screen><userinput remap="install">touch /etc/ld.so.conf</userinput></screen>
  205. <!--para>Fix the generated Makefile to skip an unneeded sanity check
  206. that fails in the LFS partial environment:
  207. </para-->
  208. <para>修正生成的 Makefile ,
  209. 跳过一个在 LFS 的不完整环境中会失败的完整性检查:</para>
  210. <screen><userinput remap="install">sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile</userinput></screen>
  211. <para>安装该软件包:</para>
  212. <screen><userinput remap="install">make install</userinput></screen>
  213. <!--para>Install the configuration file and runtime directory for
  214. <command>nscd</command>:</para-->
  215. <para>安装 <command>nscd</command> 的配置文件和运行时目录:</para>
  216. <screen><userinput remap="install">cp -v ../nscd/nscd.conf /etc/nscd.conf
  217. mkdir -pv /var/cache/nscd</userinput></screen>
  218. <para revision="systemd">安装
  219. <command>nscd</command> 的 systemd 支持文件:</para>
  220. <screen revision="systemd"><userinput remap="install">install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
  221. install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.service</userinput></screen>
  222. <!--para>Next, install the locales that can make the system respond in a
  223. different language. None of the locales are required, but if some of them
  224. are missing, the test suites of future packages would skip important
  225. testcases.</para-->
  226. <para>下面,安装一些 locale ,它们可以使得系统用不同语言响应用户请求。
  227. 这些 locale 都不是必须的,但是如果缺少了它们中的某些,
  228. 在将来运行软件包的测试套件时,可能跳过重要的测试。</para>
  229. <!--para>Individual locales can be installed using the
  230. <command>localedef</command> program. E.g., the first
  231. <command>localedef</command> command below combines the
  232. <filename>/usr/share/i18n/locales/cs_CZ</filename>
  233. charset-independent locale definition with the
  234. <filename>/usr/share/i18n/charmaps/UTF-8.gz</filename>
  235. charmap definition and appends the result to the
  236. <filename>/usr/lib/locale/locale-archive</filename> file.
  237. The following instructions will install the minimum set of
  238. locales necessary for the optimal coverage of tests:</para-->
  239. <para>可以用 <command>localedef</command> 程序安装单独的 locale 。
  240. 例如,下面的第一个 <command>localedef</command> 命令将
  241. <filename>/usr/share/i18n/locales/cs_CZ</filename>
  242. 中的字符集无关 locale 定义和
  243. <filename>/usr/share/i18n/charmaps/UTF-8.gz</filename>
  244. 中的字符映射定义组合起来,并附加到
  245. <filename>/usr/lib/locale/locale-archive</filename> 文件。
  246. 以下命令将会安装能够覆盖测试所需的最小 locale 集合:</para>
  247. <screen role="nodump"><userinput remap="locale-test">mkdir -pv /usr/lib/locale
  248. localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
  249. localedef -i de_DE -f ISO-8859-1 de_DE
  250. localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
  251. localedef -i de_DE -f UTF-8 de_DE.UTF-8
  252. localedef -i en_GB -f UTF-8 en_GB.UTF-8
  253. localedef -i en_HK -f ISO-8859-1 en_HK
  254. localedef -i en_PH -f ISO-8859-1 en_PH
  255. localedef -i en_US -f ISO-8859-1 en_US
  256. localedef -i en_US -f UTF-8 en_US.UTF-8
  257. localedef -i es_MX -f ISO-8859-1 es_MX
  258. localedef -i fa_IR -f UTF-8 fa_IR
  259. localedef -i fr_FR -f ISO-8859-1 fr_FR
  260. localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
  261. localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
  262. localedef -i it_IT -f ISO-8859-1 it_IT
  263. localedef -i it_IT -f UTF-8 it_IT.UTF-8
  264. localedef -i ja_JP -f EUC-JP ja_JP
  265. localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
  266. localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
  267. localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
  268. localedef -i zh_CN -f GB18030 zh_CN.GB18030</userinput></screen>
  269. <!--para>In addition, install the locale for your own country, language and
  270. character set.</para-->
  271. <para>另外,安装适合您自己国家、语言和字符集的 locale 。</para>
  272. <note><title>译注</title><para>
  273. 建议中文用户安装 zh_CN.UTF-8 作为日常使用的 locale。GB18030
  274. 是为了后向兼容古老的 GB2312 而设计的编码,
  275. 在现代 Linux 系统和互联网使用时会引起一些奇怪的问题。
  276. 中华人民共和国国家标准化管理委员会的官方网站已经切换到 UTF-8。
  277. </para></note>
  278. <!--para>Alternatively, install all locales listed in the
  279. <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
  280. (it includes every locale listed above and many more) at once with the
  281. following time-consuming command:</para-->
  282. <para>或者,也可以一次安装
  283. <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename>
  284. 中列出的所有 locale (包括上面列出的所有 locale,以及其他很多)。
  285. 执行下面这个需要很长时间的命令:</para>
  286. <screen><userinput remap="locale-full">make localedata/install-locales</userinput></screen>
  287. <!--para>Then use the <command>localedef</command> command to create and
  288. install locales not listed in the
  289. <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename> file
  290. in the unlikely case you need them.</para-->
  291. <para>如果需要,再使用 <command>localedef</command> 命令创建和安装
  292. <filename>glibc-&glibc-version;/localedata/SUPPORTED</filename>
  293. 中没有列出的 locale ,当然您不太可能需要它们。</para>
  294. </sect2>
  295. <sect2 id="conf-glibc" role="configuration">
  296. <title>配置 Glibc</title>
  297. <indexterm zone="conf-glibc">
  298. <primary sortas="e-/etc/nsswitch.conf">/etc/nsswitch.conf</primary>
  299. </indexterm>
  300. <indexterm zone="conf-glibc">
  301. <primary sortas="e-/etc/localtime">/etc/localtime</primary>
  302. </indexterm>
  303. <sect3>
  304. <title>添加 nsswitch.conf</title>
  305. <!--para>The <filename>/etc/nsswitch.conf</filename> file needs to be created
  306. because the Glibc defaults do not work well in a networked environment.
  307. </para-->
  308. <para>由于 Glibc 的默认值在网络环境下不能很好地工作,
  309. 需要创建配置文件 <filename>/etc/nsswitch.conf</filename>。</para>
  310. <!--para>Create a new file <filename>/etc/nsswitch.conf</filename> by running the
  311. following:</para-->
  312. <para>执行以下命令创建新的 <filename>/etc/nsswitch.conf</filename>:
  313. </para>
  314. <screen><userinput>cat &gt; /etc/nsswitch.conf &lt;&lt; "EOF"
  315. <literal># Begin /etc/nsswitch.conf
  316. passwd: files
  317. group: files
  318. shadow: files
  319. hosts: files dns
  320. networks: files
  321. protocols: files
  322. services: files
  323. ethers: files
  324. rpc: files
  325. # End /etc/nsswitch.conf</literal>
  326. EOF</userinput></screen>
  327. </sect3>
  328. <sect3 id="conf-zone">
  329. <title>添加时区数据</title>
  330. <!--para>Install and set up the time zone data with the following:</para-->
  331. <para>输入以下命令,安装并设置时区数据:</para>
  332. <screen><userinput>tar -xf ../../tzdata&tzdata-version;.tar.gz
  333. ZONEINFO=/usr/share/zoneinfo
  334. mkdir -pv $ZONEINFO/{posix,right}
  335. for tz in etcetera southamerica northamerica europe africa antarctica \
  336. asia australasia backward pacificnew systemv; do
  337. zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
  338. zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
  339. zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
  340. done
  341. cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
  342. zic -d $ZONEINFO -p America/New_York
  343. unset ZONEINFO</userinput></screen>
  344. <variablelist>
  345. <title>zic 命令的含义:</title>
  346. <varlistentry>
  347. <term><parameter>zic -L /dev/null ...</parameter></term>
  348. <listitem>
  349. <!--para>This creates posix time zones, without any leap seconds. It is
  350. conventional to put these in both
  351. <filename class="directory">zoneinfo</filename> and
  352. <filename class="directory">zoneinfo/posix</filename>. It is
  353. necessary to put the POSIX time zones in
  354. <filename class="directory">zoneinfo</filename>, otherwise various
  355. test-suites will report errors. On an embedded system, where space is
  356. tight and you do not intend to ever update the time zones, you could save
  357. 1.9MB by not using the <filename class="directory">posix</filename>
  358. directory, but some applications or test-suites might produce some
  359. failures.</para-->
  360. <para>该命令创建没有闰秒的 POSIX 时区。一般的惯例是将它们安装在
  361. <filename class="directory">zoneinfo</filename> 和
  362. <filename class="directory">zoneinfo/posix</filename>
  363. 两个目录中。前者是必须的,否则若干测试套件会报告错误。
  364. 在嵌入式系统上,如果存储空间十分紧张,
  365. 而且您永远不会更新时区信息,您可以不使用
  366. <filename class="directory">posix</filename> 目录,
  367. 以节约 1.9 MB,
  368. 但个别程序或测试套件可能会失败。</para>
  369. </listitem>
  370. </varlistentry>
  371. <varlistentry>
  372. <term><parameter>zic -L leapseconds ...</parameter></term>
  373. <listitem>
  374. <!--para>This creates right time zones, including leap seconds. On an
  375. embedded system, where space is tight and you do not intend to
  376. ever update the time zones, or care about the correct time, you could
  377. save 1.9MB by omitting the <filename class="directory">right</filename>
  378. directory.</para-->
  379. <para>该命令创建正确的,包含闰秒的时区。在嵌入式系统上,
  380. 如果存储空间十分紧张,而且您永远不会更新时区信息,
  381. 也不关心系统时间是否正确,您可以跳过
  382. <filename class="directory">right</filename> 目录,
  383. 以节约 1.9 MB。</para>
  384. </listitem>
  385. </varlistentry>
  386. <varlistentry>
  387. <term><parameter>zic ... -p ...</parameter></term>
  388. <listitem>
  389. <!--para>This creates the <filename>posixrules</filename> file. We use
  390. New York because POSIX requires the daylight savings time rules
  391. to be in accordance with US rules.</para-->
  392. <para>该命令创建 <filename>posixrule</filename> 文件。
  393. 我们使用纽约时区,因为 POSIX 要求与美国一致的夏令时规则。
  394. </para>
  395. </listitem>
  396. </varlistentry>
  397. </variablelist>
  398. <!--para>One way to determine the local time zone is to run the following
  399. script:</para-->
  400. <para>一种确定本地时区的方法是运行脚本:</para>
  401. <screen role="nodump"><userinput>tzselect</userinput></screen>
  402. <!--para>After answering a few questions about the location, the script will
  403. output the name of the time zone (e.g.,
  404. <emphasis>America/Edmonton</emphasis>). There are also some other possible
  405. time zones listed in <filename
  406. class='directory'>/usr/share/zoneinfo</filename> such as
  407. <emphasis>Canada/Eastern</emphasis> or <emphasis>EST5EDT</emphasis> that
  408. are not identified by the script but can be used.</para>
  409. <para>Then create the <filename>/etc/localtime</filename> file by
  410. running:</para-->
  411. <para>在回答关于当前位置的若干问题后,脚本会输出对应时区的名字
  412. (例如<emphasis>America/Edmonton</emphasis>)。
  413. 在 <filename class="directory">/usr/share/zoneinfo</filename>
  414. 中还有一些该脚本不能识别,但可以使用的时区,如
  415. <emphasis>Canada/Eastern</emphasis> 或者
  416. <emphasis>EST5EDT</emphasis>。</para>
  417. <para>确定时区后,执行以下命令,创建
  418. <filename>/etc/localtime</filename>:</para>
  419. <screen revision="sysv"><userinput>cp -v /usr/share/zoneinfo/<replaceable>&lt;xxx&gt;</replaceable> /etc/localtime</userinput></screen>
  420. <screen revision="systemd"><userinput>ln -sfv /usr/share/zoneinfo/<replaceable>&lt;xxx&gt;</replaceable> /etc/localtime</userinput></screen>
  421. <!--para>Replace <replaceable>&lt;xxx&gt;</replaceable> with the name of the
  422. time zone selected (e.g., Canada/Eastern).</para-->
  423. <para>将 <replaceable>&lt;xxx&gt;</replaceable> 替换成选定时区的名称
  424. (例如 Canada/Eastern)。</para>
  425. </sect3>
  426. <sect3 id="conf-ld" role="configuration">
  427. <title>配置动态加载器</title>
  428. <indexterm zone="conf-ld">
  429. <primary sortas="e-/etc/ld.so.conf">/etc/ld.so.conf</primary>
  430. </indexterm>
  431. <!--para>By default, the dynamic loader (<filename
  432. class="libraryfile">/lib/ld-linux.so.2</filename>) searches through
  433. <filename class="directory">/lib</filename> and <filename
  434. class="directory">/usr/lib</filename> for dynamic libraries that are
  435. needed by programs as they are run. However, if there are libraries in
  436. directories other than <filename class="directory">/lib</filename> and
  437. <filename class="directory">/usr/lib</filename>, these need to be added
  438. to the <filename>/etc/ld.so.conf</filename> file in order for the
  439. dynamic loader to find them. Two directories that are commonly known
  440. to contain additional libraries are <filename
  441. class="directory">/usr/local/lib</filename> and <filename
  442. class="directory">/opt/lib</filename>, so add those directories to the
  443. dynamic loader's search path.</para-->
  444. <para>默认情况下,动态加载器
  445. (<filename class="libraryfile">/lib/ld-linux.so.2</filename>)
  446. 在 <filename class="directory">/lib</filename> 和
  447. <filename class="directory">/usr/lib</filename>
  448. 中搜索程序运行时需要的动态库。然而,如果在其他目录中有动态库,
  449. 为了使动态加载器能够找到它们,需要把这些目录添加到文件
  450. <filename>/etc/ld.so.conf</filename> 中。
  451. 有两个目录 <filename class="directory">/usr/local/lib</filename>
  452. 和 <filename class="directory">/opt/lib</filename>
  453. 经常包含附加的共享库,所以现在将它们添加到动态加载器的搜索目录中。
  454. </para>
  455. <!--para>Create a new file <filename>/etc/ld.so.conf</filename> by running the
  456. following:</para-->
  457. <para>运行以下命令,创建一个新的 <filename>/etc/ld.so.conf</filename>:
  458. </para>
  459. <screen><userinput>cat &gt; /etc/ld.so.conf &lt;&lt; "EOF"
  460. <literal># Begin /etc/ld.so.conf
  461. /usr/local/lib
  462. /opt/lib
  463. </literal>
  464. EOF</userinput></screen>
  465. <!--para>If desired, the dynamic loader can also search a directory and
  466. include the contents of files found there. Generally the files in
  467. this include directory are one line specifying the desired library path.
  468. To add this capability run the following commands:</para-->
  469. <para>如果希望的话,动态加载器也可以搜索一个目录,并将其中的文件包含在
  470. <filename>ld.so.conf</filename> 中。
  471. 通常包含文件目录中的文件只有一行,指定一个期望的库文件目录。
  472. 如果需要这项功能,执行以下命令:</para>
  473. <screen role="nodump"><userinput>cat &gt;&gt; /etc/ld.so.conf &lt;&lt; "EOF"
  474. <literal># Add an include directory
  475. include /etc/ld.so.conf.d/*.conf
  476. </literal>
  477. EOF
  478. mkdir -pv /etc/ld.so.conf.d</userinput></screen>
  479. </sect3>
  480. </sect2>
  481. <sect2 id="contents-glibc" role="content">
  482. <title>Glibc 的内容</title>
  483. <segmentedlist>
  484. <segtitle>安装的程序</segtitle>
  485. <segtitle>安装的库</segtitle>
  486. <segtitle>安装的目录</segtitle>
  487. <seglistitem>
  488. <seg>catchsegv, gencat, getconf, getent, iconv, iconvconfig, ldconfig,
  489. ldd, lddlibc4, locale, localedef, makedb, mtrace, nscd,
  490. pldd, sln, sotruss, sprof, tzselect, xtrace,
  491. zdump, 以及 zic</seg>
  492. <seg>ld-&glibc-version;.so, libBrokenLocale.{a,so}, libSegFault.so, libanl.{a,so},
  493. libc.{a,so}, libc_nonshared.a, libcidn.so,
  494. libcrypt.{a,so}, libdl.{a,so}, libg.a, libieee.a, libm.{a,so},
  495. libmcheck.a, libmemusage.so, libnsl.{a,so}, libnss_compat.so,
  496. libnss_dns.so, libnss_files.so, libnss_hesiod.so, libnss_nis.so,
  497. libnss_nisplus.so, libpthread.{a,so},
  498. libpthread_nonshared.a, libresolv.{a,so}, librpcsvc.a, librt.{a,so},
  499. libthread_db.so, 以及 libutil.{a,so}</seg>
  500. <seg>/usr/include/arpa, /usr/include/bits, /usr/include/gnu,
  501. /usr/include/net, /usr/include/netash, /usr/include/netatalk,
  502. /usr/include/netax25, /usr/include/neteconet, /usr/include/netinet,
  503. /usr/include/netipx, /usr/include/netiucv, /usr/include/netpacket,
  504. /usr/include/netrom, /usr/include/netrose, /usr/include/nfs,
  505. /usr/include/protocols, /usr/include/rpc, /usr/include/rpcsvc,
  506. /usr/include/sys, /usr/lib/audit, /usr/lib/gconv, /usr/lib/locale,
  507. /usr/libexec/getconf, /usr/share/i18n, /usr/share/zoneinfo,
  508. /var/cache/nscd, 以及 /var/lib/nss_db</seg>
  509. </seglistitem>
  510. </segmentedlist>
  511. <variablelist>
  512. <bridgehead renderas="sect3">简要描述</bridgehead>
  513. <?dbfo list-presentation="list"?>
  514. <?dbhtml list-presentation="table"?>
  515. <varlistentry id="catchsegv">
  516. <term><command>catchsegv</command></term>
  517. <listitem>
  518. <para>在程序因为段错误而终止时创建栈跟踪</para>
  519. <indexterm zone="ch-system-glibc catchsegv">
  520. <primary sortas="b-catchsegv">catchsegv</primary>
  521. </indexterm>
  522. </listitem>
  523. </varlistentry>
  524. <varlistentry id="gencat">
  525. <term><command>gencat</command></term>
  526. <listitem>
  527. <para>生成消息目录</para>
  528. <indexterm zone="ch-system-glibc gencat">
  529. <primary sortas="b-gencat">gencat</primary>
  530. </indexterm>
  531. </listitem>
  532. </varlistentry>
  533. <varlistentry id="getconf">
  534. <term><command>getconf</command></term>
  535. <listitem>
  536. <para>显示文件系统指定的系统配置变量值</para>
  537. <indexterm zone="ch-system-glibc getconf">
  538. <primary sortas="b-getconf">getconf</primary>
  539. </indexterm>
  540. </listitem>
  541. </varlistentry>
  542. <varlistentry id="getent">
  543. <term><command>getent</command></term>
  544. <listitem>
  545. <para>从管理数据库取得条目</para>
  546. <indexterm zone="ch-system-glibc getent">
  547. <primary sortas="b-getent">getent</primary>
  548. </indexterm>
  549. </listitem>
  550. </varlistentry>
  551. <varlistentry id="iconv">
  552. <term><command>iconv</command></term>
  553. <listitem>
  554. <para>转换给定文件的编码</para>
  555. <indexterm zone="ch-system-glibc iconv">
  556. <primary sortas="b-iconv">iconv</primary>
  557. </indexterm>
  558. </listitem>
  559. </varlistentry>
  560. <varlistentry id="iconvconfig">
  561. <term><command>iconvconfig</command></term>
  562. <listitem>
  563. <para>创建快速装入 <command>iconv</command> 模块配置文件</para>
  564. <indexterm zone="ch-system-glibc iconvconfig">
  565. <primary sortas="b-iconvconfig">iconvconfig</primary>
  566. </indexterm>
  567. </listitem>
  568. </varlistentry>
  569. <varlistentry id="ldconfig">
  570. <term><command>ldconfig</command></term>
  571. <listitem>
  572. <para>设置运行时动态链接</para>
  573. <indexterm zone="ch-system-glibc ldconfig">
  574. <primary sortas="b-ldconfig">ldconfig</primary>
  575. </indexterm>
  576. </listitem>
  577. </varlistentry>
  578. <varlistentry id="ldd">
  579. <term><command>ldd</command></term>
  580. <listitem>
  581. <para>报告给定程序或共享库依赖于哪些共享库</para>
  582. <indexterm zone="ch-system-glibc ldd">
  583. <primary sortas="b-ldd">ldd</primary>
  584. </indexterm>
  585. </listitem>
  586. </varlistentry>
  587. <varlistentry id="lddlibc4">
  588. <term><command>lddlibc4</command></term>
  589. <listitem>
  590. <para>辅助 <command>ldd</command> 处理对象文件</para>
  591. <indexterm zone="ch-system-glibc lddlibc4">
  592. <primary sortas="b-lddlibc4">lddlibc4</primary>
  593. </indexterm>
  594. </listitem>
  595. </varlistentry>
  596. <varlistentry id="locale">
  597. <term><command>locale</command></term>
  598. <listitem>
  599. <para>给出当前区域的一些信息</para>
  600. <indexterm zone="ch-system-glibc locale">
  601. <primary sortas="b-locale">locale</primary>
  602. </indexterm>
  603. </listitem>
  604. </varlistentry>
  605. <varlistentry id="localedef">
  606. <term><command>localedef</command></term>
  607. <listitem>
  608. <para>编译 locale 规范</para>
  609. <indexterm zone="ch-system-glibc localedef">
  610. <primary sortas="b-localedef">localedef</primary>
  611. </indexterm>
  612. </listitem>
  613. </varlistentry>
  614. <varlistentry id="makedb">
  615. <term><command>makedb</command></term>
  616. <listitem>
  617. <para>从文本输入创建简单的数据库</para>
  618. <indexterm zone="ch-system-glibc makedb">
  619. <primary sortas="b-makedb">makedb</primary>
  620. </indexterm>
  621. </listitem>
  622. </varlistentry>
  623. <varlistentry id="mtrace">
  624. <term><command>mtrace</command></term>
  625. <listitem>
  626. <para>读取并解析内存跟踪文件,以人类可读的形式输出内存跟踪信息
  627. </para>
  628. <indexterm zone="ch-system-glibc mtrace">
  629. <primary sortas="b-mtrace">mtrace</primary>
  630. </indexterm>
  631. </listitem>
  632. </varlistentry>
  633. <varlistentry id="nscd">
  634. <term><command>nscd</command></term>
  635. <listitem>
  636. <para>一个缓存最常见命名服务请求的守护进程</para>
  637. <indexterm zone="ch-system-glibc nscd">
  638. <primary sortas="b-nscd">nscd</primary>
  639. </indexterm>
  640. </listitem>
  641. </varlistentry>
  642. <varlistentry id="pldd">
  643. <term><command>pldd</command></term>
  644. <listitem>
  645. <para>列出正在运行的进程使用的共享库</para>
  646. <indexterm zone="ch-system-glibc pldd">
  647. <primary sortas="b-pldd">pldd</primary>
  648. </indexterm>
  649. </listitem>
  650. </varlistentry>
  651. <varlistentry id="sln">
  652. <term><command>sln</command></term>
  653. <listitem>
  654. <para>静态链接的 <command>ln</command> 程序</para>
  655. <indexterm zone="ch-system-glibc sln">
  656. <primary sortas="b-sln">sln</primary>
  657. </indexterm>
  658. </listitem>
  659. </varlistentry>
  660. <varlistentry id="sotruss">
  661. <term><command>sotruss</command></term>
  662. <listitem>
  663. <para>跟踪特定命令对共享库中子程序的调用</para>
  664. <indexterm zone="ch-system-glibc sotruss">
  665. <primary sortas="b-sotruss">sotruss</primary>
  666. </indexterm>
  667. </listitem>
  668. </varlistentry>
  669. <varlistentry id="sprof">
  670. <term><command>sprof</command></term>
  671. <listitem>
  672. <para>读取并显示共享库性能剖析数据</para>
  673. <indexterm zone="ch-system-glibc sprof">
  674. <primary sortas="b-sprof">sprof</primary>
  675. </indexterm>
  676. </listitem>
  677. </varlistentry>
  678. <varlistentry id="tzselect">
  679. <term><command>tzselect</command></term>
  680. <listitem>
  681. <para>询问用户系统所在的位置并报告对应的时区</para>
  682. <indexterm zone="ch-system-glibc tzselect">
  683. <primary sortas="b-tzselect">tzselect</primary>
  684. </indexterm>
  685. </listitem>
  686. </varlistentry>
  687. <varlistentry id="xtrace">
  688. <term><command>xtrace</command></term>
  689. <listitem>
  690. <para>显示正在执行的函数以跟踪程序执行</para>
  691. <indexterm zone="ch-system-glibc xtrace">
  692. <primary sortas="b-xtrace">xtrace</primary>
  693. </indexterm>
  694. </listitem>
  695. </varlistentry>
  696. <varlistentry id="zdump">
  697. <term><command>zdump</command></term>
  698. <listitem>
  699. <para>输出当前时间在多个时区中的表示</para>
  700. <indexterm zone="ch-system-glibc zdump">
  701. <primary sortas="b-zdump">zdump</primary>
  702. </indexterm>
  703. </listitem>
  704. </varlistentry>
  705. <varlistentry id="zic">
  706. <term><command>zic</command></term>
  707. <listitem>
  708. <para>时区编译器</para>
  709. <indexterm zone="ch-system-glibc zic">
  710. <primary sortas="b-zic">zic</primary>
  711. </indexterm>
  712. </listitem>
  713. </varlistentry>
  714. <varlistentry id="ld.so">
  715. <term><filename class="libraryfile">ld-&glibc-version;.so</filename></term>
  716. <listitem>
  717. <para>动态链接器/加载器</para>
  718. <indexterm zone="ch-system-glibc ld.so">
  719. <primary sortas="c-ld.so">ld-&glibc-version;.so</primary>
  720. </indexterm>
  721. </listitem>
  722. </varlistentry>
  723. <varlistentry id="libBrokenLocale">
  724. <term><filename class="libraryfile">libBrokenLocale</filename></term>
  725. <listitem>
  726. <para>被 Glibc 内部用作使某些不正确的程序(例如某些 Motif 程序)
  727. 正常运行的粗糙手段,参阅
  728. <filename>glibc-&glibc-version;/locale/broken_cur_max.c</filename>
  729. 中的注释了解更多信息</para>
  730. <indexterm zone="ch-system-glibc libBrokenLocale">
  731. <primary sortas="c-libBrokenLocale">libBrokenLocale</primary>
  732. </indexterm>
  733. </listitem>
  734. </varlistentry>
  735. <varlistentry id="libSegFault">
  736. <term><filename class="libraryfile">libSegFault</filename></term>
  737. <listitem>
  738. <para><command>catchsegv</command> 使用的段错误信号处理程序
  739. </para>
  740. <indexterm zone="ch-system-glibc libSegFault">
  741. <primary sortas="c-libSegFault">libSegFault</primary>
  742. </indexterm>
  743. </listitem>
  744. </varlistentry>
  745. <varlistentry id="libanl">
  746. <term><filename class="libraryfile">libanl</filename></term>
  747. <listitem>
  748. <para>异步的命名查找库</para>
  749. <indexterm zone="ch-system-glibc libanl">
  750. <primary sortas="c-libanl">libanl</primary>
  751. </indexterm>
  752. </listitem>
  753. </varlistentry>
  754. <varlistentry id="libc">
  755. <term><filename class="libraryfile">libc</filename></term>
  756. <listitem>
  757. <para>主要的 C 运行库</para>
  758. <indexterm zone="ch-system-glibc libc">
  759. <primary sortas="c-libc">libc</primary>
  760. </indexterm>
  761. </listitem>
  762. </varlistentry>
  763. <varlistentry id="libcidn">
  764. <term><filename class="libraryfile">libcidn</filename></term>
  765. <listitem>
  766. <para>被 Glibc 内部的 <function>getaddrinfo</function> 函数
  767. 用于处理国际化域名</para>
  768. <indexterm zone="ch-system-glibc libcidn">
  769. <primary sortas="c-libcidn">libcidn</primary>
  770. </indexterm>
  771. </listitem>
  772. </varlistentry>
  773. <varlistentry id="libcrypt">
  774. <term><filename class="libraryfile">libcrypt</filename></term>
  775. <listitem>
  776. <para>密码学库</para>
  777. <indexterm zone="ch-system-glibc libcrypt">
  778. <primary sortas="c-libcrypt">libcrypt</primary>
  779. </indexterm>
  780. </listitem>
  781. </varlistentry>
  782. <varlistentry id="libdl">
  783. <term><filename class="libraryfile">libdl</filename></term>
  784. <listitem>
  785. <para>动态链接接口库</para>
  786. <indexterm zone="ch-system-glibc libdl">
  787. <primary sortas="c-libdl">libdl</primary>
  788. </indexterm>
  789. </listitem>
  790. </varlistentry>
  791. <varlistentry id="libg">
  792. <term><filename class="libraryfile">libg</filename></term>
  793. <listitem>
  794. <para>没有功能的空库,曾经是 <command>g++</command> 的运行库。
  795. </para>
  796. <indexterm zone="ch-system-glibc libg">
  797. <primary sortas="c-libg">libg</primary>
  798. </indexterm>
  799. </listitem>
  800. </varlistentry>
  801. <varlistentry id="libieee">
  802. <term><filename class="libraryfile">libieee</filename></term>
  803. <listitem>
  804. <!--para>Linking in this module forces error handling rules for math
  805. functions as defined by the Institute of Electrical and Electronic
  806. Engineers (IEEE). The default is POSIX.1 error handling</para-->
  807. <para>链接该库以使用国际电气电子工程师学会(IEEE)
  808. 定义的数学函数错误处理规则,而不是默认的 POSIX.1 错误处理。
  809. </para>
  810. <indexterm zone="ch-system-glibc libieee">
  811. <primary sortas="c-libieee">libieee</primary>
  812. </indexterm>
  813. </listitem>
  814. </varlistentry>
  815. <varlistentry id="libm">
  816. <term><filename class="libraryfile">libm</filename></term>
  817. <listitem>
  818. <para>数学库</para>
  819. <indexterm zone="ch-system-glibc libm">
  820. <primary sortas="c-libm">libm</primary>
  821. </indexterm>
  822. </listitem>
  823. </varlistentry>
  824. <varlistentry id="libmcheck">
  825. <term><filename class="libraryfile">libmcheck</filename></term>
  826. <listitem>
  827. <para>链接到该库时启用内存分配检查</para>
  828. <indexterm zone="ch-system-glibc libmcheck">
  829. <primary sortas="c-libmcheck">libmcheck</primary>
  830. </indexterm>
  831. </listitem>
  832. </varlistentry>
  833. <varlistentry id="libmemusage">
  834. <term><filename class="libraryfile">libmemusage</filename></term>
  835. <listitem>
  836. <para>被 <command>memusage</command> 用于收集程序内存使用信息
  837. </para>
  838. <indexterm zone="ch-system-glibc libmemusage">
  839. <primary sortas="c-libmemusage">libmemusage</primary>
  840. </indexterm>
  841. </listitem>
  842. </varlistentry>
  843. <varlistentry id="libnsl">
  844. <term><filename class="libraryfile">libnsl</filename></term>
  845. <listitem>
  846. <para>网络服务库</para>
  847. <indexterm zone="ch-system-glibc libnsl">
  848. <primary sortas="c-libnsl">libnsl</primary>
  849. </indexterm>
  850. </listitem>
  851. </varlistentry>
  852. <varlistentry id="libnss">
  853. <term><filename class="libraryfile">libnss</filename></term>
  854. <listitem>
  855. <para>命名服务开关库,包含用于解析域名、用户名、组名、代号、
  856. 服务、协议等的函数。</para>
  857. <indexterm zone="ch-system-glibc libnss">
  858. <primary sortas="c-libnss">libnss</primary>
  859. </indexterm>
  860. </listitem>
  861. </varlistentry>
  862. <varlistentry id="libpthread">
  863. <term><filename class="libraryfile">libpthread</filename></term>
  864. <listitem>
  865. <para>POSIX 线程库</para>
  866. <indexterm zone="ch-system-glibc libpthread">
  867. <primary sortas="c-libpthread">libpthread</primary>
  868. </indexterm>
  869. </listitem>
  870. </varlistentry>
  871. <varlistentry id="libresolv">
  872. <term><filename class="libraryfile">libresolv</filename></term>
  873. <listitem>
  874. <para>包含用于创建、发送和解析因特网域名服务数据包的函数。</para>
  875. <indexterm zone="ch-system-glibc libresolv">
  876. <primary sortas="c-libresolv">libresolv</primary>
  877. </indexterm>
  878. </listitem>
  879. </varlistentry>
  880. <varlistentry id="librpcsvc">
  881. <term><filename class="libraryfile">librpcsvc</filename></term>
  882. <listitem>
  883. <para>包含一些 RPC 服务函数</para>
  884. <indexterm zone="ch-system-glibc librpcsvc">
  885. <primary sortas="c-librpcsvc">librpcsvc</primary>
  886. </indexterm>
  887. </listitem>
  888. </varlistentry>
  889. <varlistentry id="librt">
  890. <term><filename class="libraryfile">librt</filename></term>
  891. <listitem>
  892. <para>包含 POSIX.1b 实时扩展要求的多数接口</para>
  893. <indexterm zone="ch-system-glibc librt">
  894. <primary sortas="c-librt">librt</primary>
  895. </indexterm>
  896. </listitem>
  897. </varlistentry>
  898. <varlistentry id="libthread_db">
  899. <term><filename class="libraryfile">libthread_db</filename></term>
  900. <listitem>
  901. <para>包含用于构建多线程程序调试的函数器</para>
  902. <indexterm zone="ch-system-glibc libthread_db">
  903. <primary sortas="c-libthread_db">libthread_db</primary>
  904. </indexterm>
  905. </listitem>
  906. </varlistentry>
  907. <varlistentry id="libutil">
  908. <term><filename class="libraryfile">libutil</filename></term>
  909. <listitem>
  910. <para>包含许多 Unix 工具使用的 <quote>标准</quote> 函数</para>
  911. <indexterm zone="ch-system-glibc libutil">
  912. <primary sortas="c-libutil">libutil</primary>
  913. </indexterm>
  914. </listitem>
  915. </varlistentry>
  916. </variablelist>
  917. </sect2>
  918. </sect1>