calling c function (libpcap) fails! lazarus / 8-Other ---------------------------------------------------------------------- kristofv · 2006-12-28 13:12 hi, i made the following c file: Code: [Select] #include #include #include  /* GIMME a libpcap plz! */ #include #include #include #include int main() { return 0; } void info() {   char *dev; /* name of the device to use */   char *net; /* dot notation of the network address */   char *mask;/* dot notation of the network mask    */   int ret;   /* return code */   char errbuf[PCAP_ERRBUF_SIZE];   bpf_u_int32 netp; /* ip          */   bpf_u_int32 maskp;/* subnet mask */   struct in_addr addr;   /* ask pcap to find a valid device for use to sniff on */   dev = pcap_lookupdev(errbuf);   /* error checking */   if(dev == NULL)   {    printf("%s\n",errbuf);    exit(1);   }   /* print out device name */   printf("DEV: %s\n",dev);   /* ask pcap for the network address and mask of the device */   ret = pcap_lookupnet(dev,&netp,&maskp,errbuf);   if(ret == -1)   {    printf("%s\n",errbuf);    exit(1);   }   /* get the network address in a human readable form */   addr.s_addr = netp;   net = inet_ntoa(addr);   if(net == NULL)/* thanks Scott :-P */   {     perror("inet_ntoa");     exit(1);   }   printf("NET: %s\n",net);   /* do the same as above for the device's mask */   addr.s_addr = maskp;   mask = inet_ntoa(addr);     if(mask == NULL)   {     perror("inet_ntoa");     exit(1);   }     printf("MASK: %s\n",mask);   return; } i compiled this c file with: Code: [Select] gcc captcha.c -libpcap this produced a binary file called a.out now i want to call the info() function from free pascal. that function uses libpcap functions to find out out the network and the subnetmask. this is the fp code that calls the c function: Code: [Select] unit Unit1; {$link ../Cfiles/capture/a.out} {$linklib c} interface uses   Classes, SysUtils, CTypes;     procedure info; cdecl; external; implementation begin   info; end. now when i try to compile the fp pogram it quits with the folowing bizarre messages: Code: [Select] unit1.pas(10,28) Hint: Unit "ctypes" not used in Unit1 ../Cfiles/capture/a.out: In function `__data_start': (.data+0x4): multiple definition of `__dso_handle' /usr/lib/gcc/i486-linux-gnu/4.1.2/crtbegin.o:(.data+0x0): first defined here ../Cfiles/capture/a.out: In function `_init': /tmp/buildd/glibc-2.3.6.ds1/build-tree/i386-libc/csu/crti.S:36: multiple definition of `_init' /usr/lib/crti.o:/tmp/buildd/glibc-2.3.6.ds1/build- tree/i386-libc/csu/crti.S:36: first defined here ../Cfiles/capture/a.out: In function `_start': ../sysdeps/i386/elf/start.S:65: multiple definition of `_start' /usr/lib/fpc/2.0.4/units/i386-linux/rtl/cprt21.o:prt1.as:(.text+0x0): first defined here ../Cfiles/capture/a.out: In function `main': (.text+0xa4): multiple definition of `main' project1.o:project1.lpr:12: first defined here /usr/bin/ld: Warning: size of symbol `main' changed from 15 in project1.o to 25 in ../Cfiles/capture/a.out ../Cfiles/capture/a.out: In function `_fini': /tmp/buildd/glibc-2.3.6.ds1/build-tree/i386-libc/csu/crti.S:52: multiple definition of `_fini' /usr/lib/crti.o:/tmp/buildd/glibc-2.3.6.ds1/build- tree/i386-libc/csu/crti.S:52: first defined here project1.lpr(13,1) Error: Error while linking what do i have to do now?? grtz[/code]