1. 程式人生 > >ubuntu安裝man中文幫助文件:man c/c++

ubuntu安裝man中文幫助文件:man c/c++

4. C++
sudo apt-get install libstdc++6-4.5-doc   //通過補齊查詢具體的檔案
//sudo apt-get install libstdc++6-4.3-doc //C++ API  




1.新增庫函式手冊
ubuntu預設是沒有安裝c語言的庫函式man手冊的,所以你在man perror 和sendto之類的函式時會顯示沒有相關文件的問題,這個問題讓我鬱悶了我好久。解決方法:
sudo apt-get install manpages-dev
2.讓man顯示中文
ubuntu源裡面已經包含了中文的man包,所以不用從其他地方down了,直接
sudo apt-get install manpages-zh
但是這樣man預設顯示的還不是中文,還需要以下兩步
a.把中文man包轉換成utf8格式的
新建一個指令碼檔案
gedit t.sh
把下面內容新增進去
#!/bin/bashcd /usr/share/man/zh_CN/for k in *docd $kfor i in *.gzdo j=`echo ${i%.gz}` gunzip $i iconv -f gb18030 -t utf8 $j >tmp mv tmp $j gzip $jdonecd ..done

           #!/bin/bash
           cd /usr/share/man/zh_CN/
            for k in *
            do
            cd $k
            for i in *.gz
            do
            j=`echo ${i%\.gz}`
           gunzip $i
           iconv -f gb18030 -t utf8 $j >tmp
           mv tmp $j
           gzip $j
           done
           cd ..
           done

#我用上面裝完再試著亂碼顯示。解除安裝重灌 只裝上面整個一句話成功。
然後
sudo chmod a+rwx t.sh
sudo ./t.sh
b.修改man預設的語言
sudo gedit /etc/manpath.config 把裡面的所有的 /usr/share/man 改成 /usr/share/man/zh_CN
儲存後退出,然後你再試一下man ls
3.讓沒有中文幫助的顯示英文
做完上面第二部還不夠,這時你再man 一下一些c語言函式(不要用printf,socket之類比較有名的函式,這些已經有中文幫助了)的時候就會發現竟然沒有幫助,而剛才明明在第一步已經安裝了啊。這是因為你上面 把/usr/share/man 改成 /usr/share/man/zh_CN的操作使man只在中文幫助中搜索,如果沒有就直接放棄,因此還需要以下操作,才能讓man在沒有中文幫助的時候自動顯示英文的幫助,如果英文的也沒有,哪就真的沒有了。
sudo gedit /etc/manpath.config
然後搜尋你剛才改過的地方,然後在其後面新增同樣的一行,只是後面的目錄還用原來的/usr/share/man(所有的),比如在修改後的
MANPATH_MAP /bin          /usr/share/man/zh_CN
再新增一行
MANPATH_MAP /bin          /usr/share/man

 
# manpath.config
#
# This file is used by the man-db package to configure the man and cat paths.
# It is also used to provide a manpath for those without one by examining
# their PATH environment variable. For details see the manpath(5) man page.
#
# Lines beginning with `#' are comments and are ignored. Any combination of
# tabs or spaces may be used as `whitespace' separators.
#
# There are three mappings allowed in this file:
# --------------------------------------------------------
# MANDATORY_MANPATH			manpath_element
# MANPATH_MAP		path_element	manpath_element
# MANDB_MAP		global_manpath	[relative_catpath]
#---------------------------------------------------------
# every automatically generated MANPATH includes these fields
#
#MANDATORY_MANPATH 			/usr/src/pvm3/man
#
MANDATORY_MANPATH			/usr/man
MANDATORY_MANPATH			/usr/share/man/zh_CN
MANDATORY_MANPATH			/usr/local/share/man

#MANDATORY_MANPATH			/usr/share/man 
#---------------------------------------------------------
# set up PATH to MANPATH mapping
# ie. what man tree holds man pages for what binary directory.
#
#		*PATH*        ->	*MANPATH*
#

MANPATH_MAP	/bin			/usr/share/man/zh_CN
MANPATH_MAP	/usr/bin		/usr/share/man/zh_CN
MANPATH_MAP	/sbin			/usr/share/man/zh_CN
MANPATH_MAP	/usr/sbin		/usr/share/man/zh_CN
MANPATH_MAP	/usr/local/bin		/usr/local/man
MANPATH_MAP	/usr/local/bin		/usr/local/share/man
MANPATH_MAP	/usr/local/sbin		/usr/local/man
MANPATH_MAP	/usr/local/sbin		/usr/local/share/man
MANPATH_MAP	/usr/X11R6/bin		/usr/X11R6/man
MANPATH_MAP	/usr/bin/X11		/usr/X11R6/man
MANPATH_MAP	/usr/games		/usr/share/man/zh_CN
MANPATH_MAP	/opt/bin		/opt/man
MANPATH_MAP	/opt/sbin		/opt/man

#MANPATH_MAP 	/bin         		 /usr/share/man  #讓man在沒有中文幫助的時候自動顯示英文的幫助
#MANPATH_MAP	/usr/bin		/usr/share/man
#MANPATH_MAP	/sbin			/usr/share/man 
#MANPATH_MAP	/usr/sbin		/usr/share/man 
#MANPATH_MAP	/usr/games		/usr/share/man
#---------------------------------------------------------
# For a manpath element to be treated as a system manpath (as most of those
# above should normally be), it must be mentioned below. Each line may have
# an optional extra string indicating the catpath associated with the
# manpath. If no catpath string is used, the catpath will default to the
# given manpath.
#
# You *must* provide all system manpaths, including manpaths for alternate
# operating systems, locale specific manpaths, and combinations of both, if
# they exist, otherwise the permissions of the user running man/mandb will
# be used to manipulate the manual pages. Also, mandb will not initialise
# the database cache for any manpaths not mentioned below unless explicitly
# requested to do so.
#
# In a per-user configuration file, this directive only controls the
# location of catpaths and the creation of database caches; it has no effect
# on privileges.
#
# Any manpaths that are subdirectories of other manpaths must be mentioned
# *before* the containing manpath. E.g. /usr/man/preformat must be listed
# before /usr/man.
#
#		*MANPATH*     ->	*CATPATH*
#
MANDB_MAP	/usr/man		/var/cache/man/fsstnd
MANDB_MAP	/usr/share/man/zh_CN		/var/cache/man
MANDB_MAP	/usr/local/man		/var/cache/man/oldlocal
MANDB_MAP	/usr/local/share/man	/var/cache/man/local
MANDB_MAP	/usr/X11R6/man		/var/cache/man/X11R6
MANDB_MAP	/opt/man		/var/cache/man/opt
#
#---------------------------------------------------------
# Program definitions.  These are commented out by default as the value
# of the definition is already the default.  To change: uncomment a
# definition and modify it.
#
#DEFINE 	pager	pager -s
#DEFINE 	cat	cat
#DEFINE 	tr	tr '\255\267\264\327' '\055\157\047\170'
#DEFINE		grep	grep
#DEFINE 	troff 	groff -mandoc
#DEFINE 	nroff 	nroff -mandoc
#DEFINE 	eqn 	eqn
#DEFINE 	neqn	neqn
#DEFINE 	tbl 	tbl
#DEFINE 	col 	col
#DEFINE 	vgrind 	vgrind
#DEFINE 	refer 	refer
#DEFINE 	grap 	grap
#DEFINE 	pic 	pic -S
#
#DEFINE		compressor	gzip -c7
#---------------------------------------------------------
# Misc definitions: same as program definitions above.
#
#DEFINE		whatis_grep_flags		-i
#DEFINE		apropos_grep_flags		-iEw
#DEFINE		apropos_regex_grep_flags	-iE
#---------------------------------------------------------
# Section names. Manual sections will be searched in the order listed here;
# the default is 1, n, l, 8, 3, 0, 2, 5, 4, 9, 6, 7. Multiple SECTION
# directives may be given for clarity, and will be concatenated together in
# the expected way.
# If a particular extension is not in this list (say, 1mh), it will be
# displayed with the rest of the section it belongs to. The effect of this
# is that you only need to explicitly list extensions if you want to force a
# particular order. Sections with extensions should usually be adjacent to
# their main section (e.g. "1 1mh 8 ...").
#
SECTION		1 n l 8 3 2 3posix 3pm 3perl 5 4 9 6 7
#
#---------------------------------------------------------
# Range of terminal widths permitted when displaying cat pages. If the
# terminal falls outside this range, cat pages will not be created (if
# missing) or displayed.
#
#MINCATWIDTH	80
#MAXCATWIDTH	80
#
# If CATWIDTH is set to a non-zero number, cat pages will always be
# formatted for a terminal of the given width, regardless of the width of
# the terminal actually being used. This should generally be within the
# range set by MINCATWIDTH and MAXCATWIDTH.
#
#CATWIDTH	0
#
#---------------------------------------------------------
# Flags.
# NOCACHE keeps man from creating cat pages.
#NOCACHE





參考:http://blog.csdn.net/linking530/article/details/7284482
http://blog.csdn.net/chang198932/article/details/18728703
http://blog.163.com/fanning_7213/blog/static/2496505201102610539141/