Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÏÂCÓïÑÔ±à³Ì»ù´¡(Makefile)

 
LinuxÏÂCÓïÑÔ±à³Ì»ù´¡(Makefile)
2005-01-18 10:28:23 À´×Ô£ºÈüµÏÍø
 
¼ÙÉèÎÒÃÇÓÐÏÂÃæÕâÑùµÄÒ»¸ö³ÌÐò£¬Ô´´úÂëÈçÏ£º
/* main.c */
#include "mytool1.h"
#include "mytool2.h"
int main(int argc£¬char **argv)
{
mytool1_print("hello")£»
mytool2_print("hello")£»
}
/* mytool1.h */
#ifndef _MYTOOL_1_H
#define _MYTOOL_1_H
void mytool1_print(char *print_str)£»
#endif
/* mytool1.c */
#include "mytool1.h"
void mytool1_print(char *print_str)
{
printf("This is mytool1 print %s "£¬print_str)£»
}
/* mytool2.h */
#ifndef _MYTOOL_2_H
#define _MYTOOL_2_H
void mytool2_print(char *print_str)£»
#endif
/* mytool2.c */
#include "mytool2.h"
void mytool2_print(char *print_str)
{
printf("This is mytool2 print %s "£¬print_str)£»
}
µ±È»ÓÉÓÚÕâ¸ö³ÌÐòºÜ¶Ì£¬ÎÒÃÇ¿ÉÒÔÕâÑùÀ´±àÒë:
gcc -c main.c
gcc -c mytool1.c
gcc -c mytool2.c
gcc -o main main.o mytool1.o mytool2.o
 
 Õâ
ÑùµÄ»°ÎÒÃÇÒ²¿ÉÒÔ²úÉúmain³ÌÐò£¬¶øÇÒÒ²²»ÊǺÜÂé·³¡£µ«ÊÇÈç¹ûÎÒÃÇ¿¼ÂÇÒ»ÏÂÈç¹ûÓÐÒ»ÌìÎÒÃÇÐÞ¸ÄÁËÆäÖеÄÒ»¸öÎļþ(±ÈÈç˵mytool1.c)ÄÇôÎÒÃÇÄÑ
µÀ»¹ÒªÖØÐÂÊäÈëÉÏÃæµÄÃüÁî?Ò²ÐíÄã»á˵£¬Õâ¸öºÜÈÝÒ×½â¾ö°¡£¬ÎÒдһ¸ö
SHELL½Å±¾£¬ÈÃËü°ïÎÒÈ¥Íê³É²»¾Í¿ÉÒÔÁË¡£ÊǵĶÔÓÚÕâ¸ö³ÌÐòÀ´Ëµ£¬ÊÇ¿ÉÒÔÆðµ½×÷Óõġ£µ«Êǵ±ÎÒÃǰÑÊÂÇéÏëµÄ¸ü¸´ÔÓÒ»µã£¬Èç¹ûÎÒÃǵijÌÐòÓм¸°Ù¸öÔ´³ÌÐòµÄ
ʱºò£¬ÄѵÀÒ²Òª±àÒëÆ÷ÖØÐÂÒ»¸öÒ»¸öµÄÈ¥±àÒë?
Ϊ´Ë£¬´ÏÃ÷µÄ³ÌÐòÔ±ÃÇÏë³öÁËÒ»¸öºÜºÃµÄ¹¤¾ßÀ´×öÕâ¼þÊÂÇ飬Õâ¾ÍÊÇmake¡£ÎÒÃÇÖ»ÒªÖ´ÐÐ
ÒÔÏÂmake£¬¾Í¿ÉÒÔ°ÑÉÏÃæµÄÎÊÌâ½â¾öµô¡£ÔÚÎÒÃÇÖ´ÐÐmake֮ǰ£¬ÎÒÃÇÒªÏȱàдһ¸ö·Ç³£ÖØÒªµÄÎļþ¡£--Makefile¡£¶ÔÓÚÉÏÃæµÄÄǸö³ÌÐòÀ´Ëµ£¬¿É
ÄܵÄÒ»¸öMakefileµÄÎļþÊÇ£º
# ÕâÊÇÉÏÃæÄǸö³ÌÐòµÄMakefileÎļþ:
main£ºmain.o mytool1.o mytool2.o
gcc -o main main.o mytool1.o mytool2.o
main.o£ºmain.c mytool1.h mytool2.h
gcc -c main.c
mytool1.o£ºmytool1.c mytool1.h
gcc -c mytool1.c
mytool2.o£ºmytool2.c mytool2.h
gcc -c mytool2.c
ÓÐÁËÕâ¸öMakefileÎļþ£¬²»ÂÛÎÒÃÇʲôʱºòÐÞ¸ÄÁËÔ´³ÌÐòµ±ÖеÄʲôÎļþ£¬ÎÒÃÇÖ»ÒªÖ´ÐÐmakeÃüÁÎÒÃǵıà


Ïà¹ØÎĵµ£º

C/C++±ÊÊÔÌâÄ¿´óÈ«

 1.ÇóÏÂÃæº¯ÊýµÄ·µ»ØÖµ£¨Î¢Èí£©
¡¡¡¡int func(x)
¡¡¡¡{
¡¡¡¡int countx = 0;
¡¡¡¡while(x)
¡¡¡¡{
¡¡¡¡countx ++;
¡¡¡¡x = x&(x-1);
¡¡¡¡}
¡¡¡¡return countx;
¡¡¡¡}
¡¡¡¡¼Ù¶¨x = 9999¡£ ´ð°¸£º8
¡¡¡¡Ë¼Â·£º½«xת»¯Îª2½øÖÆ£¬¿´º¬ÓеÄ1µÄ¸öÊý¡£
¡¡¡¡2. ʲôÊÇ“ÒýÓÔ£¿ÉêÃ÷ºÍʹÓÓÒýÓ ......

linuxÄں˿ռäÉêÇ볬¹ý2MBÁ¬Ðø¿Õ¼äµÄʵÏÖº¯Êý¡£

 /*
kmalloc can apply 128KB memory only. This func support any continous memory allocate more than 2MB.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kallsyms.h>
#define KMEM_PAGES       &nb ......

Linux ϵͳʱ¼äÉèÖᢱà³Ì×ܽá

δÍê´ýÐø...
ÉèÖÃʱ¼ä£º
date -s "2009/11/08 11:23:00"
Ó²¼þʱÖÓÓëϵͳʱ¼äͬ²½Ò»Ï£º
hwclock --systohc
±à³Ì£º
#include <cstdlib>
time_t time(time_t *timer)
µ÷Óú󽫵±Ç°ÏµÍ³Ê±¼äÓë1900Äê1ÔÂ1ÈÕÏà²îµÄÃëÊý´æÈëµ½timerÖУ¬timer¿É¿´³ÉÊÇÒ»¸ö³¤ÕûÐÍÊý
¾ßÌåÃèÊö£º
  º¯ÊýÔ­ÐÍ£º  ......

Linux kernel development Chapter2 ½ø³Ì¹ÜÀí

1 ½ø³Ì¹ÜÀíÏà¹Ø´úÂë
  1.1 thread_info½á¹¹£¬ÔÚÎļþ<asm/thread_info.h>Öж¨Òå
      struct thread_info {
           struct task_struct *task;
           struct exec ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ