# Fail to compile this tiny C code on FreeBSD...



## YZMSQ (Mar 30, 2012)

Hi, all:
I'm just busy working around my graduation thesis about data mining on Internet application identifier, and need to process some traces. I download the NetFlow data here with its recommended program source code (simply a C source code file) to process the data. What confounded me is that, I failed to compile this C code file on FreeBSD while succeeded on Linux, using identical command line:

```
gcc -lpcap -o flow flow-extract.c `pkg-config --cflags --libs glib-2.0`
```
with some annoying errors:

```
flow-extract.c: In function 'pkt_callback':
flow-extract.c:329: error: dereferencing pointer to incomplete type
flow-extract.c:329: error: dereferencing pointer to incomplete type
flow-extract.c:333: error: dereferencing pointer to incomplete type
flow-extract.c:367: error: dereferencing pointer to incomplete type
flow-extract.c:370: error: dereferencing pointer to incomplete type
flow-extract.c:373: error: 'struct tcphdr' has no member named 'source'
flow-extract.c:373: error: 'struct tcphdr' has no member named 'source'
flow-extract.c:373: error: 'struct tcphdr' has no member named 'source'
flow-extract.c:373: error: 'struct tcphdr' has no member named 'source'
flow-extract.c:374: error: 'struct tcphdr' has no member named 'dest'
flow-extract.c:374: error: 'struct tcphdr' has no member named 'dest'
flow-extract.c:374: error: 'struct tcphdr' has no member named 'dest'
flow-extract.c:374: error: 'struct tcphdr' has no member named 'dest'
flow-extract.c:378: error: 'struct udphdr' has no member named 'source'
flow-extract.c:378: error: 'struct udphdr' has no member named 'source'
flow-extract.c:378: error: 'struct udphdr' has no member named 'source'
flow-extract.c:378: error: 'struct udphdr' has no member named 'source'
flow-extract.c:379: error: 'struct udphdr' has no member named 'dest'
flow-extract.c:379: error: 'struct udphdr' has no member named 'dest'
flow-extract.c:379: error: 'struct udphdr' has no member named 'dest'
flow-extract.c:379: error: 'struct udphdr' has no member named 'dest'
flow-extract.c:387: error: dereferencing pointer to incomplete type
flow-extract.c:387: error: dereferencing pointer to incomplete type
flow-extract.c:387: error: dereferencing pointer to incomplete type
flow-extract.c:387: error: dereferencing pointer to incomplete type
flow-extract.c:387: error: dereferencing pointer to incomplete type
flow-extract.c:387: error: dereferencing pointer to incomplete type
flow-extract.c:388: error: dereferencing pointer to incomplete type
flow-extract.c:388: error: dereferencing pointer to incomplete type
flow-extract.c:388: error: dereferencing pointer to incomplete type
flow-extract.c:388: error: dereferencing pointer to incomplete type
flow-extract.c:388: error: dereferencing pointer to incomplete type
flow-extract.c:388: error: dereferencing pointer to incomplete type
flow-extract.c:388: error: dereferencing pointer to incomplete type
flow-extract.c:398: error: dereferencing pointer to incomplete type
flow-extract.c:398: error: dereferencing pointer to incomplete type
flow-extract.c:398: error: dereferencing pointer to incomplete type
flow-extract.c:398: error: dereferencing pointer to incomplete type
flow-extract.c:398: error: dereferencing pointer to incomplete type
flow-extract.c:398: error: dereferencing pointer to incomplete type
flow-extract.c:399: error: dereferencing pointer to incomplete type
flow-extract.c:399: error: dereferencing pointer to incomplete type
flow-extract.c:399: error: dereferencing pointer to incomplete type
flow-extract.c:399: error: dereferencing pointer to incomplete type
flow-extract.c:399: error: dereferencing pointer to incomplete type
flow-extract.c:399: error: dereferencing pointer to incomplete type
flow-extract.c:399: error: dereferencing pointer to incomplete type
```

After google it, I added a line of 
	
	



```
#define __FAVOR_BSD
```
 ahead of this file, but still no go. So, any help is appreciated. Thanks in advance.


----------



## SirDice (Mar 30, 2012)

I'm not sure but I think it's caused by the pcap library from FreeBSD. It's slightly different from the Linux version.

There are a few tools regarding NetFlow already in the ports. You might want to have a look at those.

This one seems like a nice start: net-mgmt/flow-tools.


----------



## YZMSQ (Mar 31, 2012)

SirDice said:
			
		

> I'm not sure but I think it's caused by the pcap library from FreeBSD. It's slightly different from the Linux version.
> 
> There are a few tools regarding NetFlow already in the ports. You might want to have a look at those.
> 
> This one seems like a nice start: net-mgmt/flow-tools.


Thank you, but the problem for me is that how to process this downloaded dump file. I need to extract flow information there quickly:e


----------



## YZMSQ (Mar 31, 2012)

And I just installed the net/libpcap but nothing improved, though.


----------

