glibc.xml 42 KB

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