|
|
错误提示:
make -f makefile.mk
gcc -c f.c
gcc -c c.c
gcc f.o c.o -o s
c.o(.text+0x0): In function `main':
: multiple definition of `main'
f.o(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 117 in f.o to 51 in c.ocollect2: ld returned 1 exit status
make: *** 错误 1
makefile:
s:f.o c.o h.o
gcc f.o c.o -o s
f.o:f.c h.h
gcc -c f.c
c.o:c.c h.h
gcc -c c.c
c.c源文件:
#include "h.h"
main()
{
extern gnum[5];
printf("gnum=%s/n",gnum);
}
f.c源文件
#include "h.h"
#include <arpa/inet.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
char gnum[5];
main()
{
pid_t pid;
gnum[0]='a';
gnum[1]='b';
gnum[2]='c';
gnum[3]='d';
if((pid=vfork())<0)
printf("vfork success...\n");
/*child*/
if(pid==0)
{
execl("/var/tmp/c.o","c.o",(char *)0);
}
}
h.h源文件
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h> |
|