linux 继续编译,【编译】Linux环境编译traceroute
源碼可以在 的 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 這一欄其他的工具的使用
閱讀(2149) | 評論(0) | 轉發(0) |
總結
以上是生活随笔為你收集整理的linux 继续编译,【编译】Linux环境编译traceroute的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux mysql UNSIGNED
- 下一篇: linux编译ace,Linux下编译A