藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年6月6日 10:18


在Kdevelop中編譯libnet.

在Kdevelop中編譯libnet.
我現在Kdevelop中編譯libnet.

http://www.packetfactory.net/libnet/

在gcc中編譯需要設置如下:

gcc -Wall `libnet-config --defines` foo.c -o foo `libnet-config --libs`

可是我因該在Kdevelop中如何設置 `libnet-config --defines`
應該把它加入何處呢?





There has been some confusion on how to correctly implement the libnet-configure shell script. Since 0.99e, it has become mandatory to use this script. The library will not compile code without it. This is to avoid potential problems when user code is compiled with improper or missing CPP macros. The script also has provisions for specifying libraries and cflags. The library switch is useful on architectures that require additional libraries to compile network code (such as Solaris). The script is very simple to use. The following examples should dispell any confusion:
At the command line you can run the script to see what defines are used for that system:
shattered:~>; libnet-config --defines
-D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H
-DLIBNET_LIL_ENDIAN

At the command line to compile a simple program:

shattered:~>; gcc -Wall `libnet-config --defines` foo.c -o foo `libnet-config --libs`


In a Makefile:
DEFINES = `libnet-config --defines`

In a Makefile.in (also employing autoheader):
DEFINES = `libnet-config --defines` @DEFS@

在Kdevelop中編譯libnet.

將download下來的libnet-1.1.0.tar.gz一次展開,到unix下面
在當前目錄下,運行configure。然後make

由於裡面的代碼是支持IPV6的,所以如果你的系統中沒有IPv6的庫,將會出錯。對於這種錯誤,可以通過定義宏或者對如下的結構體做處理。

struct sockaddr_in6 sin;/*系統的*/
struct libnet_ipv6_hdr *ip_hdr;/*在這個包中的一個頭文件中定義*/

在Kdevelop中編譯libnet.

我編譯是出現的問題:
gcc -Wall `libnet-config --defines` s.c -o s `libnet-config --libs`
s.c: In function `main':
s.c:27: warning: implicit declaration of function `libnet_name_resolve'
s.c:29: warning: implicit declaration of function `libnet_error'
s.c:19: warning: unused variable `ipUc'
/tmp/ccfT1P6V.o(.text+0x6e): In function `main':
: undefined reference to `libnet_name_resolve'
/tmp/ccfT1P6V.o(.text+0x93): In function `main':
: undefined reference to `libnet_error'
collect2: ld returned 1 exit status

是不是安裝有問題?



Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com