ºìÁªLinuxÃÅ»§
Linux°ïÖú

LinuxÉϱàÒëºÍ°²×°GCC

·¢²¼Ê±¼ä:2008-04-15 00:48:27À´Ô´:ºìÁª×÷Õß:ketto
×÷Õß: A.TNG
ÓÊÏä: jiyucn@163.com
²Î¿¼: Installation document of GCC
ʱ¼ä: 4/13/2008

Ç°ÑÔ
×î½üÔÚ¹¹½¨Ò»Ì׿ª·¢»·¾³£¬¶ÔGCCÓÐÌØÊâµÄÒªÇó£¬Ê¹ÓÃRPM°ü°²×° µÄGCCÒѾ­²»ÄÜÂú×ãÒªÇóÁË£¬Òò´Ë¾ö¶¨ÊÖ¶¯±àÒë°²×°GCC¡£

Ô­±¾Ïë×ßһЩ½Ý¾¶£¬Ï£ÍûRPM°ü°²×°Ò²¿ÉÒÔ´ïµ½ÊÖ¶¯°²×°µÄÁé»îÐÔ£¬ ºóÀ´·¢ÏÖ´Ë·²»Í¨£»½ÓÏÂÀ´ÓÖÏëÕÒÍøÂçÉÏÊÇ·ñÌṩ±àÒëºÃµÄtar°üÏ ÔØ£¬½âѹºó¾Í¿ÉÖ±½ÓÔËÐУ¬ºóÀ´·¢ÏÖGCCƽ̨ÒÀÀµÐÔºÜÇ¿£¬´Ë·Òà ²»Í¨¡£

ÓÚÊÇÖ»ÄÜÑ¡ÔñÔ´´úÂë±àÒëºÍ°²×°GCCÁË¡£

µÚÒ»²½£º×¼±¸¹¤×÷
ÎÒÊÇ´Óһ̨×îС»¯°²×°CentOS 5µÄLinux PCÉÏ¿ªÊ¼°²×°GCCµÄ£¬ ÆäʵÈç¹ûÄãÓÐһ̨°²×°ÁË¿ª·¢»·¾³µÄLinux PC£¬Ôò¿ÉÒÔÌø¹ýÕâÒ» ²½¡£

Ê×ÏÈ£¬»úÆ÷ÉϱØÐë°²×°ºÃGCC£¬²ÅÄܹ»´ÓÔ´´úÂë±àÒëºÍ°²×°ÐµÄGCC£¬ Òò´ËÎÒ°²×°ÁËÏÂÁÐRPM°ü×÷Ϊ¿ª·¢»·¾³¡££¨×¢Ò⣬ÎÒµÄϵͳÊÇ CentOS 5£¬ÆäËûƽ̨¿ÉÒÔÑ¡ÔñÏà¹ØµÄ¿ª·¢¹¤¾ß°ü£©¡£

rpm -ivh cpp-4.1.1-52.el5.i386.rpm
rpm -ivh glibc-headers-2.5-12.i386.rpm
rpm -ivh glibc-devel-2.5-12.i386.rpm
rpm -ivh libgomp-4.1.1-52.el5.i386.rpm
rpm -ivh gcc-4.1.1-52.el5.i386.rpm
rpm -ivh libstdc++-devel-4.1.1-52.el5.i386.rpm
rpm -ivh gcc-c++-4.1.1-52.el5.i386.rpm
rpm -ivh zlib-devel-1.2.3-3.i386.rpm

°²×°ÍêÒÔÉϵŤ¾ß°üºó£¬ÏµÍ³ÖÐgcc/g++ÃüÁî¾Í¿ÉÓÃÁË¡£

GCCµÄtar°üÀïÃæÌṩÁËtest suite£¬±àÒëÍê³Éºó¿ÉÒÔÖ´ÐÐÕâЩ²âÊÔ£¬ ÓÃÒÔ·ÖÎö±àÒëÊÇ·ñ³É¹¦¡£Òò´ËϵͳÖÐÐèÒª°²×°ÁíÍâµÄ¹¤¾ß°ü£º

rpm -ivh expect-5.43.0-5.1.i386.rpm
rpm -ivh dejagnu-1.4.4-5.1.noarch.rpm

°²×°ÍêÒÔÉϹ¤¾ß°üºó£¬ÏµÍ³ÖÐruntestÃüÁî¾Í¿ÉÒÔÓÃÁË¡£

µÚ¶þ²½£ºconfigureºÍmake
configure
configureÊǸöºÜ¹Ø¼üµÄ²½Ö裬Èç¹ûÓöµ½±àÒë´íÎó£¬Ê×ÏÈÓ¦¸ÃÏëµ½ ¿ÉÄÜÊÇconfigureµÄÎÊÌ⣬½ÓÏÂÀ´Ïëµ½¿ÉÄÜÊÇϵͳÖÐȱÉÙÏà¹ØµÄÈí ¼þ°ü£¬±àÒë¹ý³ÌÖÐÕÒ²»µ½Í·ÎļþµÈ¡£

ÎÒʹÓõıàÒë²ÎÊýÊÇ£º
./configure --prefix=/opt/gcc-x.y.z --enable-shared \--enable-threads=posix --enable-clocale=gnu \--enable-__cxa_atexit --disable-checking \--enable--long-long

ÒÀ´Î½âÊÍ£º
--prefix=/opt/gcc-x.y.z ÊÇÓÃÀ´Ö¸¶¨°²×°Ä¿Â¼£¬×¢Ò⣬¸ÃĿ¼¾¡Á¿²»ÒªÓëÔ´´úÂëÊÇͬһĿ¼£¬ Ò²²»ÄÜÊÇÔ´´úÂëµÄ×ÓĿ¼¡£
--enable-shared ´´½¨¹²Ïí¿â
--enable-threads=posix ÆôÓÃÏß³ÌÖ§³Ö£¬ÔÚijЩƽ̨ÉÏÊÇĬÈÏÖµ¡£Ëü¶ÔObj-CµÄ¿âÒÔ¼°C++¡¢ JavaµÄÒì³£´¦ÀíÓÐÓ°Ïì¡£
--enable-clocale=gnu ±¾²ÎÊýÈ·±£C++¿âÔÚÈκÎÇé¿ö϶¼Ê¹ÓÃÕýÈ·µÄlocale Ä£¿é¡£Èç¹ûÅäÖýű¾²éÕÒµ½de_DEÕâ¸ölocale£¬Ëü¾Í»á ʹÓÃÕýÈ·µÄgnuÄ£¿é¡£È»¶ø£¬ÓеÄÈËûÓа²×°de_DE£¬¾ÍÓпÉÄÜ´´½¨ ³öABI²»¼æÈݵÄC++¿âÎļþ£¬ÕâÊÇÒòΪ´íÎóµÄʹÓÃÁËgeneric×÷Ϊ localeÄ£¿é¡£
--enable-__cxa_atexit ʹÓà __cxa_atexitÀ´´úÌæ atexit,ÓÃÀ´¼Ç¼±¾µØºÍÈ«¾ÖµÄ C++ destructors£¬ÕâÊÇΪÁËÍêÈ«·ûºÏ±ê×¼µÄ¹æ¶¨¡£Ëü»¹»áÓ°Ïìµ½C++ ABI£¬ Òò´ËÉú³ÉµÄC++¹²Ïí¿â£¬ÔÚÆäËûµÄLinux·¢ÐаæÉÏÒ²ÄÜʹÓá£
--disable-checking Ϊ½ÚÊ¡±àÒëʱ¼ä£¬ÎÒÃÇʹÓôËÑ¡Ï¶Ô½á¹ûûÓÐÓ°Ïì¡£
--enable--long-long Ö§³Ölong longÊý¾ÝÀàÐÍ£¬Ä³Ð©¿ªÔ´ÏîĿʹÓÃÁ˸ÃÊý¾ÝÀàÐÍ¡£
Íê³Éconfigure¹¤×÷ºó£¬»á×Ô¶¯Éú³ÉMakefile£¬½ÓÏÂÀ´¾Í¿ÉÒÔ¿ªÊ¼Âþ³¤ µÄ±àÒ빤×÷ÁË¡£

Èç¹ûconfigureµÄ²ÎÊý°ÑÄãÈƵúÜÔΣ¬ ´«µÝ¾¡Á¿ÉٵIJÎÊý¸øconfigure£¬Ä¬ÈÏ µÄ²ÎÊýÔÚ´ó¶àÊýÇé¿öÏÂÊÇÊÊÓõġ£

make

ʹÓÃÈçÏÂÃüÁʼ±àÒ룺
make bootstrap
²»Í¬ÅäÖõĻúÆ÷£¬±àÒëʱ¼äµÄ³¤¶Ì²»Ò»Ñù£¬ÏàͬµÄÊÇ£¬¶¼ÊǼ«ÆäÂþ³¤µÄ ¹ý³Ì¡£

µÚÈý²½£ºÖ´ÐвâÊÔ£¨¿ÉÑ¡£©
GCCµÄtar°üÀïÃæÌṩÁËtest suite£¬°ïÖú½øÐвâÊÔ£¬ÓÃÀ´·ÖÎö±àÒëÊÇ·ñ ³É¹¦¡£

Ö´ÐÐÈçÏÂÃüÁʼ²âÊÔ£º
make -k check > check.log
ͬÑù£¬ÕâÊǸöÂþ³¤µÄ¹ý³Ì¡£

²âÊÔÍê³Éºó£¬¿ÉÒÔ·ÃÎÊ http://gcc.gnu.org/buildstat.html £¬¶Ô±È²âÊÔ½á¹û¡£

µÚËIJ½£º°²×°
Èç¹ûûÓдíÎ󣬽ÓÏÂÀ´¾Í¿ÉÒÔ¿ªÊ¼°²×°ÁË£º

make install
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 2 ÌõÆÀÂÛ

  1. tonforce ÓÚ 2008-04-27 19:19:48·¢±í:

    ÎÒÒ²ÊÔ¹ý
    ¿Éϧû³É¹¦
    ѧϰÁËÒ»¸ö¶àÐÇÆÚ
    ¶Ôlinux¼òÖ±¾ÍÊÇÕ´²»Éϱß
    ±È½ÏÓôÃÆÄÅ
    »¹ºÃÓкìÁª£¬¿ÉÒÔÉÏÕâÀ´Í¸Í¸Æø

  2. sleepnet ÓÚ 2008-04-21 08:38:05·¢±í:

    Ö§³ÖÒ»ÏÂ