Libtool´´½¨ºÍʹÓÃlinux϶¯Ì¬¿â
Îļþfun.c£¬fun.h£¬hello.c£¬hello.h£¬main.c¶¯Ì¬¿âº¯Êý¶¼ÔÚfun.cºÍhello.cÀïÃæ
----------------------------
fun.c:
int add(int a, int b)
{
return a+b;
}
fun.h:
#ifndef _FUN_H_11
#define _FUN_H_11
int add(int a, int b);
#endif
----------------------------
hello.c:
££i nclude <stdio.h>
void output(char *ss)
{
printf("HELLO %s\n", ss);
}
hello.h
#ifndef HELLO_H_111
#define HELLO_H_111
void output(char *ss);
#endif
----------------------------
main.c:
££i nclude <stdio.h>
££i nclude "hello.h"
££i nclude "fun.h"
void
main()
{
output("world");
printf("Test Value:%d\n", add(1, 2));
}
---------------------------------
ʹÓÃlibtools´´½¨ºÍʹÓð²×°¶¯Ì¬¿â²½Öè:
(1)
libtool --mode=compile gcc -g -O -c hello.c
libtool --mode=compile gcc -g -O -c fun.c
libtool --mode=compile gcc -g -O -c main.c
#Éú³É¸÷×ÔµÄoÎļþ
(2)
libtool --mode=link gcc -g -O -o libhello.la hello.lo fun.lo -rpath /usr/local/lib -lm
#Á¬½Ó³É¶¯Ì¬¿âÎļþ
(3)
libtool --mode=link gcc -g -O -o test main.o libhello.la -lm
#Á¬½ÓÉú³É¿ÉÖ´ÐÐÎļþtest
(4)
libtool --mode=install cp libhello.la /usr/local/lib/libhello.la
libtool --mode=install install -c libhello.la /usr/local/lib/libhello.la
libtool -n --mode=finish /usr/local/lib
libtool install -c test /usr/local/bin/test
#°²×°¶¯Ì¬¿â
È»ºó¾Í¿ÉÒÔÔËÐÐ/usr/local/bin/testÁË,µ±È»Â·¾¶¿ÉÒÔÈÎÒâÉèÖÃ,ÕâÊÇÊÖ¶¯¹ý³Ì,д³ÉMakefileÎļþΪ:
OBJS = fun.o hello.o
LO_OBJS = main.lo fun.lo hello.lo
PACKAGE_VERSION = 1:1:1
LIBDIR=/usr/local/lib
all : test
install : libhello.la
test : libhello.la main.o
libtool --mode=link gcc -g -O -o test main.o libhello.la -lm
libhello.la : $(OBJS)
libtool gcc -g -O -o libhello.la $(LO_OBJS) -rpath ${LIBDIR} -lm -version-info ${PACKAGE_VERSION}
main.o : main.c fun.h hello.h
libtool --mode=compile gcc -g -O -c main.c
fun.o : fun.c fun.h
libtool --mode=compile gcc -g -O -c fun.c
hello.o : hello.c hello.h
libtool --mode=comp
Ïà¹ØÎĵµ£º
/*
* Ò»ÄêÇ°ÕûµÄһЩ×ÊÁÏ£¬ÔÚ²»Åª³öÀ´Õæ²»ÖªµÀÄÇÌì¾ÍûÁË£¬±¾ÉíÎÒÊǸöÀÁÉ¢µÄÈË£¬Ò²²»ÏëÔÙÕÒµÚ¶þ´Î£¡
* ÏÂÃæµÄÄÚÈÝÒ²ÊÇÒÔÇ°baidu/GoogleµÄ£¬È»ºóÕûÀíÁËÏÂÃæµÄ×ÊÁÏ¡£ÍüÁËÊDz»ÊǶ¼ÄÜÓÃÁË£¬µ±Ê±Ö»ÊÔÁËÒ»²¿·Ö¡£¡£¡£
*/
ҪʹÓÃ×Ô¶¯Æô¶¯½ø³ÌµÄ¹¦ÄÜ,¾ÍÐèÒªÕÆÎÕÒÔϼ¸¸öÆô¶¯ÃüÁî:
at ÃüÁî
========== ......
Èç¹û·þÎñÆ÷ÊÇ×Ô¼ºµÄ£¬²¢ÇÒ»úÆ÷¾ÍÔÚÉí±ß£¬ÄÇʲô¶¼²»ÓÃ˵ÁË£¬È±ÉÙgcc¶¥¶à¾ÍÊÇÖØзÅÈë°²×°ÅÌ£¬°Ñ¿ª·¢¹¤¾ß°ü°²×°ÉÏ¡£µ«ÊÇÈç¹ûÊÇ×âµÄ·þÎñÆ÷£¬ÍйܷþÎñ·½ÄÇ°ïÈËÓָ㲻¶®Äã˵µÄɶ×Ógcc£¬Òª°²×°gccʵÔÚÊÇÌ«Âé·³ÁË¡£ÄãµÃÈ¥ÕÒgccÏà¹ØµÄ°ü£¬°æ±¾ºÅ»¹µÃ±ØÐë¶ÔÓ¦ÉÏ£¬·ñÔò²»¼æÈÝ¡£×î½ü¸øÒ»¸öÅóÓÑ×°gcc£¬ ......
ls -l|grep ^d ----Áгöµ±Ç°Ä¿Â¼ÏµÄÎļþ¼Ð
ls -l|grep ^d|grep "tmp" ----Áгöµ±Ç°Ä¿Â¼ÏÂÃ÷×Óº¬ÓÐ"tmp"µÄÎļþ¼Ð
for dir in `ls -l ~/dxy/|grep ^d | awk '{print $9}'` ---- awk '{print $9}' ,Ö»print Îļþ¼ÐµÄÃû×Ö
do
echo "==== $dir"
cd ~/dxy;cd ......
ÍøÉÏÕÒµ½ÁËÐí¶à¹ØÓÚÕâ·½ÃæµÄÎÄÕ£¬ÄÚÈÝ»ù±¾Ïàͬ¡£¾¹ýʵ¼ù£¬·¢ÏÖÄÚÈÝÀïÆÕ±é´æÔÚÎÊÌâ¡£ÒÔÏÂÊÇ×Ô¼ºÊµ¼ùÖ®ºó£¬ÐÞ¸ÄÁËÆäÖеĴíÎ󣬲¢¼Ç¼ÏÂÀ´µÄ±Ê¼Ç¡£
ÔÚ Linux »ò UNIX Ï嵀 Apache ·þÎñÆ÷ÖиøÍøÒ³ÉèÖÃÃÜÂë—ÕâÊÇÒ»Öֺܼòµ¥µÄ»ùÓÚÓû§Ãû/¿ÚÁîµÄÈÏÖ¤·½Ê½£ ......