我发现我的 ubuntu 12.10 amd64 带有 3.5.X 内核,无法填充一些队列,并且他们在内核 3.8.x 中修复了这个问题,我将 Ubuntu 的内核升级到 v3.10-saucy,并从主线内核安装 deb 文件档案一切进展顺利。
uname -r
3.10.0-031000-generic
还有
sudo apt-get install linux-image-3.10.0-031000-generic
说东西已经安装好了。
但是当我用 gcc 编译我的 C 代码之后,它仍然声称应该在 > 3.8.x 上运行的那段代码未声明!
问题是新安装的内核头在
/usr/src/linux-headers-3.10.0-031000-generic/include/
但/usr/include
仍然保留旧头文件。Gcc 仍然从 /usr/include 读取头文件。然后,我想到了这个:
gcc --verbose -I /usr/src/linux-headers-3.10.0-031000-generic/include/ -o test.out test.c
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:14:26: error: conflicting types for ‘fd_set’
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:220:0,
from /usr/include/net/if.h:26,
from test.c:2:
/usr/include/x86_64-linux-gnu/sys/select.h:76:5: note: previous declaration of ‘fd_set’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:15:25: error: conflicting types for ‘dev_t’
In file included from /usr/include/net/if.h:26:0,
from test.c:2:
/usr/include/x86_64-linux-gnu/sys/types.h:61:17: note: previous declaration of ‘dev_t’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:19:17: error: conflicting types for ‘nlink_t’
In file included from /usr/include/net/if.h:26:0,
from test.c:2:
/usr/include/x86_64-linux-gnu/sys/types.h:76:19: note: previous declaration of ‘nlink_t’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:25:26: error: conflicting types for ‘timer_t’
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:133:0,
from /usr/include/net/if.h:26,
from test.c:2:
/usr/include/time.h:104:19: note: previous declaration of ‘timer_t’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:45:26: error: conflicting types for ‘loff_t’
In file included from /usr/include/net/if.h:26:0,
from test.c:2:
/usr/include/x86_64-linux-gnu/sys/types.h:45:18: note: previous declaration of ‘loff_t’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:112:17: error: conflicting types for ‘u_int64_t’
In file included from /usr/include/net/if.h:26:0,
from test.c:2:
/usr/include/x86_64-linux-gnu/sys/types.h:204:1: note: previous declaration of ‘u_int64_t’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:113:17: error: conflicting types for ‘int64_t’
In file included from /usr/include/net/if.h:26:0,
from test.c:2:
/usr/include/x86_64-linux-gnu/sys/types.h:198:1: note: previous declaration of ‘int64_t’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:134:23: error: conflicting types for ‘blkcnt_t’
In file included from /usr/include/net/if.h:26:0,
from test.c:2:
/usr/include/x86_64-linux-gnu/sys/types.h:236:20: note: previous declaration of ‘blkcnt_t’ was here
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/kernel.h:6:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/skbuff.h:17,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_ether.h:23,
from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:20,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from test.c:3:
/usr/src/linux-headers-3.10.0-031000-generic/include/linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory
compilation terminated.
然后我做了:
gcc -nostdinc -I /usr/src/linux-headers-3.10.0-031000-generic/include/
不让 gcc 访问/usr/include
。但它再次声称某些包含文件<net/if.h>
未找到,并且通过删除这些头文件,它会在找到的包含文件中给出一些其他未找到的废话。
如果<net/if.h>
与 c 库相关,则可能是正确的,因为使 gcc 不读取其他包含文件夹。但它报告一些未找到的内容
<linux/if_tun.h>
In file included from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/types.h:5:0,
from /usr/src/linux-headers-3.10.0-031000-generic/include/uapi/linux/if_tun.h:19,
from /usr/src/linux-headers-3.10.0-031000-generic/include/linux/if_tun.h:18,
from penvpn-multithread-udp.c:3:
那么我该如何克服这个问题呢?