Chinaunix首页 | 论坛 | 博客
  • 博客访问: 49906
  • 博文数量: 68
  • 博客积分: 71
  • 博客等级: 民兵
  • 技术积分: 700
  • 用 户 组: 普通用户
  • 注册时间: 2011-10-18 12:13
文章分类

全部博文(68)

文章存档

2015年(68)

我的朋友

分类: LINUX

2015-06-05 16:36:46



源码可以在 的 Network tools include 这一栏找到
下载解压

三部曲,直接执行

:~/Downloads/traceroute-1.4a12$ ./configure
creating cache ./config.cache
checking host system type... Invalid configuration `x86_64-pc-linux-gnu': machine `x86_64-pc' not recognized

checking target system type... Invalid configuration `x86_64-pc-linux-gnu': machine `x86_64-pc' not recognized

checking build system type... Invalid configuration `x86_64-pc-linux-gnu': machine `x86_64-pc' not recognized

checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking for malloc.h... yes
checking for sys/select.h... yes
checking for sys/sockio.h... no
checking for net/route.h... yes
checking for net/if_dl.h... no
checking for inet/mib2.h... no
checking for strerror... yes
checking for usleep... yes
checking for setlinebuf... yes
checking for gethostbyname... yes
checking for socket... yes
checking for putmsg in -lstr... no
checking routing table type... linux
checking for int32_t using gcc... yes
checking for u_int32_t using gcc... yes
checking if sockaddr struct has sa_len member... no
checking if struct icmp has icmp_nextmtu... yes
checking for a BSD compatible install... /usr/bin/install -c
updating cache ./config.cache
creating ./config.status
creating Makefile
:~/Downloads/traceroute-1.4a12$ make
gcc -O -DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_NET_ROUTE_H=1 -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 -DHAVE_SETLINEBUF=1 -DHAVE_ICMP_NEXTMTU=1  -I.  -c ./traceroute.c
./traceroute.c:213:28: fatal error: netinet/ip_var.h: No such file or directory

缺失这个头文件,在系统上查找,但是也没有找到

也尝试了注掉这些头文件,但是代码用到了,是不能注掉的。

后来发现其实源码包中包含了这些,位置是 源码包的 linux-include 目录下

traceroute-1.4a12$ ls linux-include/netinet/
in_systm.h  ip.h  ip_icmp.h  ip_var.h  udp.h  udp_var.h

都有了。

所以直接修改 生成的make文件,

有这一行:
INCLS = -I.

直接修改成:
INCLS = -I. -I./linux-include

加入这个自带的头文件路径。这样编译时,可以在 ./linux-include下找到缺失的头文件。

继续


traceroute-1.4a12$ make
gcc -O -DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_NET_ROUTE_H=1 -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 -DHAVE_SETLINEBUF=1 -DHAVE_ICMP_NEXTMTU=1  -I. -I./linux-include  -c ./traceroute.c
./traceroute.c: In function ‘main’:
./traceroute.c:471:9: warning: function with qualified void return type called [enabled by default]
./traceroute.c:515:8: warning: function with qualified void return type called [enabled by default]
./traceroute.c: At top level:
./traceroute.c:1378:1: warning: function definition has qualified void return type [enabled by default]
gcc -O -DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_NET_ROUTE_H=1 -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 -DHAVE_SETLINEBUF=1 -DHAVE_ICMP_NEXTMTU=1  -I. -I./linux-include  -c ./ifaddrlist.c
./ifaddrlist.c: In function ‘ifaddrlist’:
./ifaddrlist.c:103:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat]
./ifaddrlist.c:166:8: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat]
gcc -O -DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_NET_ROUTE_H=1 -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 -DHAVE_SETLINEBUF=1 -DHAVE_ICMP_NEXTMTU=1  -I. -I./linux-include  -c ./findsaddr-linux.c
sed -e 's/.*/char version[] = "&";/' ./VERSION > version.c
gcc -O -DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_NET_ROUTE_H=1 -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 -DHAVE_SETLINEBUF=1 -DHAVE_ICMP_NEXTMTU=1  -I. -I./linux-include  -c ./version.c
gcc -O -DHAVE_MALLOC_H=1 -DHAVE_SYS_SELECT_H=1 -DHAVE_NET_ROUTE_H=1 -DHAVE_STRERROR=1 -DHAVE_USLEEP=1 -DHAVE_SETLINEBUF=1 -DHAVE_ICMP_NEXTMTU=1  -I. -I./linux-include  -o traceroute traceroute.o ifaddrlist.o findsaddr-linux.o version.o
traceroute-1.4a12$ make install
/usr/bin/install -c -m 4555 -o root -g bin traceroute /usr/local/sbin
/usr/bin/install: cannot create regular file `/usr/local/sbin/traceroute': Permission denied
make: *** [install] Error 1
traceroute-1.4a12$ sudo make install
/usr/bin/install -c -m 4555 -o root -g bin traceroute /usr/local/sbin
xu1984.zhou@ontv:~/Downloads/traceroute-1.4a12$ ll /usr/local/sbin
total 32
-r-sr-xr-x 1 root bin 29648 Jun  6 00:17 traceroute*
xu1984.zhou@ontv:~/Downloads/traceroute-1.4a12$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/xu1984.zhou/p4v-2014.1.888424/bin

可以看到生成的 二进制可执行程序traceroute放在了 /usr/local/sbin,而且已经添加到环境变量中,所以可以直接使用了。

完毕~~

任务延伸
1. 后边需要深入研究linux环境下编译源码涉及的知识,尤其是 pkg-config 和 .pc 文件的使用
比如 http://blog.chinaunix.net/uid-20595934-id-1918368.html

2. traceroute 的使用

3. 的 Network tools include 这一栏其他的工具的使用



阅读(3048) | 评论(0) | 转发(0) |
0

上一篇:【初始化】【低端】bootmem阶段

下一篇:没有了

给主人留下些什么吧!~~