glibc.xml 42 KB

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