尊龙凯时人生就是搏

ʹÓÃAutotoolsÔÚLinuxϵͳÉϾÙÐÐ×Ô¶¯»¯¹¹½¨µÄÉèÖü¼ÇÉ

ʹÓÃautotoolsÔÚlinuxϵͳÉϾÙÐÐ×Ô¶¯»¯¹¹½¨µÄÉèÖü¼ÇÉ

ÔÚ¿ª·¢ºÍÖÎÀíLinuxÉϵÄÈí¼þÏîĿʱ £¬×Ô¶¯»¯¹¹½¨ÊÇÒ»ÏîºÜÊÇÖ÷ÒªµÄÊÂÇé £¬¿ÉÒÔ´ó´ó¼ò»¯¿ª·¢Á÷³ÌºÍïÔÌ­¹ýʧ¡£AutotoolsÊÇÒ»¸ö±»ÆÕ±éʹÓõÄ×Ô¶¯»¯¹¹½¨¹¤¾ß £¬ËüÌṩÁËÒ»Ì×ÓÃÓÚÌìÉú¿ÉÒÆÖ²µÄMakefileµÄ¹¤¾ßÁ´¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃautotoolsÔÚlinuxϵͳÉϾÙÐÐ×Ô¶¯»¯¹¹½¨µÄÉèÖü¼ÇÉ £¬²¢¸ø³öһЩÊÊÓõĴúÂëʾÀý¡£

Ò»¡¢×°ÖÃAutotools

ÔÚLinuxϵͳÉÏ×°ÖÃAutotoolsºÜÊǼòÆÓ £¬Ö»ÐèÒªÔËÐÐÒÔÏÂÏÂÁî¼´¿É£º

$ sudo apt-get install autoconf automake libtool

µÇ¼ºó¸´ÖÆ

¶þ¡¢Ä¿Â¼½á¹¹

ÔÚʹÓÃAutotools¾ÙÐÐ×Ô¶¯»¯¹¹½¨Ö®Ç° £¬ÐèÒªÏÈÏàʶһÏÂÏîÄ¿µÄĿ¼½á¹¹¡£Ò»¸öµä·¶µÄÏîĿĿ¼½á¹¹Í¨³£°üÀ¨ÒÔÏÂÎļþºÍĿ¼£º

configure.ac£ºÕâÊÇAutotoolsµÄÉèÖÃÎļþ £¬ËüÐÎòÁËÏîÄ¿µÄ¹¹½¨ºÍ×°ÖÃÑ¡Ïî¡£

Makefile.am£ºÕâÊÇ×Ô¶¯ÌìÉúµÄMakefileÄ£°å £¬ÓÃÓÚÖ¸¶¨±àÒë¹æÔòºÍÒÀÀµ¹Øϵ¡£

src£ºÕâÊÇÔ´´úÂëĿ¼ £¬ÓÃÓÚ´æ·ÅÏîÄ¿µÄÔ´´úÂëÎļþ¡£

include£ºÕâÊÇÍ·ÎļþĿ¼ £¬ÓÃÓÚ´æ·ÅÏîÄ¿µÄÍ·Îļþ¡£

lib£ºÕâÊÇ¿âÎļþĿ¼ £¬ÓÃÓÚ´æ·ÅÏîÄ¿µÄ¾²Ì¬¿âºÍ¶¯Ì¬¿â¡£

Èý¡¢±àдconfigure.acÎļþ

ÔÚÏîÄ¿µÄ¸ùĿ¼Ï½¨ÉèÒ»¸öÃûΪconfigure.acµÄÎļþ £¬ÕâÊÇAutotoolsµÄÉèÖÃÎļþ £¬¿ØÖÆ×ÅÏîÄ¿µÄ¹¹½¨Ñ¡Ïî¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄÉèÖÃÎļþʾÀý£º

AC_PREREQ([2.69])
AC_INIT([myproject], [1.0], [myemail@example.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([src/myfile.c])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

µÇ¼ºó¸´ÖÆ

ÉÏÊöʾÀýÖÐ £¬AC_INITÖ¸¶¨ÁËÏîÄ¿µÄÃû×Ö¡¢°æ±¾ºÍÁªÏµ·½·¨¡£AM_INIT_AUTOMAKEÓÃÓÚ³õʼ»¯Autotools £¬²¢Ö¸¶¨ÁËһЩ±àÒëÑ¡Ïî¡£AC_CONFIG_SRCDIRºÍAC_CONFIG_HEADERS»®·ÖÓÃÓÚÖ¸¶¨Ô´´úÂëÎļþºÍÉèÖÃÎļþµÄλÖá£AC_PROG_CCʹÓüì²â³ÌÐòÀ´È·¶¨ÏµÍ³ÉÏ¿ÉÓõÄC±àÒëÆ÷¡£AC_CONFIG_FILESÖ¸¶¨ÁËÒªÌìÉúµÄMakefileÎļþ¡£

ËÄ¡¢±àдMakefile.amÎļþ

ÔÚÏîÄ¿µÄ¸ùĿ¼Ï½¨ÉèÒ»¸öÃûΪMakefile.amµÄÎļþ £¬ÕâÊÇ×Ô¶¯ÌìÉúµÄMakefileÄ£°å¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀý£º

AUTOMAKE_OPTIONS = foreign
SUBDIRS = src

µÇ¼ºó¸´ÖÆ

ÉÏÊöʾÀýÖÐ £¬AUTOMAKE_OPTIONSÓÃÓÚÖ¸¶¨Ò»Ð©×Ô¶¯»¯¹¹½¨Ñ¡Ïî¡£SUBDIRSÖ¸¶¨ÁËÒª¹¹½¨µÄ×ÓĿ¼ £¬ÕâÀïÊÇsrcĿ¼¡£

Îå¡¢±àдMakefile.inÎļþ

ͨ¹ýÔËÐÐÒÔÏÂÏÂÁî £¬Autotools½«Æ¾Ö¤Ç°ÃæµÄconfigure.acºÍMakefile.amÎļþÌìÉúMakefile.inÎļþ£º

$ autoreconf -f -i

µÇ¼ºó¸´ÖÆ

Áù¡¢ÌìÉúMakefileÎļþ

ͨ¹ýÔËÐÐÒÔÏÂÏÂÁî £¬Autotools½«Æ¾Ö¤Makefile.inÎļþÌìÉúMakefileÎļþ£º

$ ./configure

µÇ¼ºó¸´ÖÆ

Æß¡¢¹¹½¨ÏîÄ¿

ͨ¹ýÔËÐÐÒÔÏÂÏÂÁî £¬Autotools½«Æ¾Ö¤MakefileÎļþ¾ÙÐÐÏîÄ¿¹¹½¨£º

$ make

µÇ¼ºó¸´ÖÆ

°Ë¡¢×°ÖÃÏîÄ¿

ͨ¹ýÔËÐÐÒÔÏÂÏÂÁî £¬Autotools½«Æ¾Ö¤MakefileÎļþ¾ÙÐÐÏîĿװÖãº

$ make install

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁ°ÑÏîÄ¿µÄ¿ÉÖ´ÐÐÎļþ¡¢¿âÎļþºÍÍ·Îļþ¸´ÖƵ½Ö¸¶¨µÄĿ¼ÖС£

¾Å¡¢´úÂëʾÀý

¼ÙÉèÎÒÃÇÓÐÒ»¸ö¼òÆÓµÄÏîÄ¿ £¬°üÀ¨Ò»¸öÃûΪmyprojectµÄ¿ÉÖ´ÐÐÎļþºÍÒ»¸öÃûΪmylibµÄ¾²Ì¬¿â¡£ÏÂÃæÊÇÒ»¸öʾÀýµÄMakefile.amÎļþµÄ´úÂ룺

AUTOMAKE_OPTIONS = foreign
SUBDIRS = src lib

bin_PROGRAMS = myproject
myproject_SOURCES = src/main.c
myproject_LDADD = lib/libmylib.a

noinst_LIBRARIES = libmylib.a
libmylib_a_SOURCES = lib/mylib.c

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀýÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸ö¿ÉÖ´ÐÐÎļþmyproject £¬ÔÚsrcĿ¼ÏÂÓÐÒ»¸ömain.cÔ´Îļþ¡£ÎÒÃÇ»¹½ç˵ÁËÒ»¸ö¾²Ì¬¿âlibmylib.a £¬ÔÚlibĿ¼ÏÂÓÐÒ»¸ömylib.cÔ´Îļþ¡£

ÔÚʹÓÃAutotoolsµÄÀú³ÌÖÐ £¬¿ÉÒÔƾ֤ÏÖÕæÏàÐζÔÉèÖÃÎļþºÍMakefileÎļþ¾ÙÐе÷½â £¬Öª×ãÏîÄ¿µÄÐèÇó¡£

×ܽ᣺

±¾ÎļòÒªÏÈÈÝÁËÔõÑùʹÓÃautotoolsÔÚlinuxϵͳÉϾÙÐÐ×Ô¶¯»¯¹¹½¨µÄÉèÖü¼ÇÉ £¬²¢¸ø³öÁËһЩÊÊÓõĴúÂëʾÀý¡£Í¨¹ýʹÓÃAutotools £¬ÎÒÃÇ¿ÉÒÔÀû±ãµØÌìÉú¿ÉÒÆÖ²µÄMakefileÎļþ £¬¼ò»¯ÏîÄ¿µÄ¹¹½¨ºÍ×°ÖÃÁ÷³Ì¡£Ï£Íû±¾ÎĶÔÄúÔÚLinuxÉϾÙÐÐÈí¼þ¿ª·¢ºÍÖÎÀíʱÓÐËù×ÊÖú£¡

ÒÔÉϾÍÊÇʹÓÃAutotoolsÔÚLinuxϵͳÉϾÙÐÐ×Ô¶¯»¯¹¹½¨µÄÉèÖü¼ÇɵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ