汪滔
2008-06-04 07:07:14 UTC
My code:
#include <fam.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/un.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <stdarg.h>
#include <fcntl.h>
int main(int argc,char *argv[])
{
int i,nmon,rc,fam_fd;
FAMConnection fc;
FAMRequest *frp;
struct stat status;
fd_set readfds;
char cmd[256];
frp=malloc(argc*(sizeof(*frp)));
if(!frp)
{
perror("malloc");
exit(1);
}
if((FAMOpen(&fc)) < 0)
{
perror("fam");
exit(1);
}
rc=FAMMonitorDirectory(&fc,argv[0],frp,NULL);
if(rc<0)
{
perror("FAMMonitor failed");
}
memset(cmd,0,256);
sprintf(cmd,"rsync -rlopgztC --delete -e 'rsh' %s
%s",argv[0],argv[1]);
while(1)
{
if(FAMPending(&fc)==1)
{
system("date");
system(cmd);
system("date");
}
}
}
Compile : gcc šCo mirror mirror.c
Erro:
mirror.c:(.text+0x51): undefined reference to `FAMOpen'
mirror.c:(.text+0x85): undefined reference to `FAMMonitorDirectory'
mirror.c:(.text+0xea): undefined reference to `FAMPending'
collect2: ld returned 1 exit status
#include <fam.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/un.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <stdarg.h>
#include <fcntl.h>
int main(int argc,char *argv[])
{
int i,nmon,rc,fam_fd;
FAMConnection fc;
FAMRequest *frp;
struct stat status;
fd_set readfds;
char cmd[256];
frp=malloc(argc*(sizeof(*frp)));
if(!frp)
{
perror("malloc");
exit(1);
}
if((FAMOpen(&fc)) < 0)
{
perror("fam");
exit(1);
}
rc=FAMMonitorDirectory(&fc,argv[0],frp,NULL);
if(rc<0)
{
perror("FAMMonitor failed");
}
memset(cmd,0,256);
sprintf(cmd,"rsync -rlopgztC --delete -e 'rsh' %s
%s",argv[0],argv[1]);
while(1)
{
if(FAMPending(&fc)==1)
{
system("date");
system(cmd);
system("date");
}
}
}
Compile : gcc šCo mirror mirror.c
Erro:
mirror.c:(.text+0x51): undefined reference to `FAMOpen'
mirror.c:(.text+0x85): undefined reference to `FAMMonitorDirectory'
mirror.c:(.text+0xea): undefined reference to `FAMPending'
collect2: ld returned 1 exit status