小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

UNIX網(wǎng)絡(luò)編程 源代碼 使用方法

 just_person 2012-02-14
1.編譯《UNP》

http://www./unpv13e.tar.gz
我們首先產(chǎn)生一個目錄,以后自己的代碼就敲在這個目錄里。
mkdir /home/hehe/study/unp

仍然是下載到/home/hehe/download/,解壓縮,進入目錄
cd /home/hehe/download/unpv13e/
README 文件中說的很詳細:
========================================
Execute the following from the src/ directory:

    ./configure    # try to figure out all implementation differences

    cd lib         # build the basic library that all programs need
    make           # use "gmake" everywhere on BSD/OS systems

    cd ../libfree  # continue building the basic library
    make

    cd ../libroute # only if your system supports 4.4BSD style routing sockets
    make           # only if your system supports 4.4BSD style routing sockets

    cd ../libxti   # only if your system supports XTI 
    make           # only if your system supports XTI 

    cd ../intro    # build and test a basic client program
    make daytimetcpcli
========================================
這里只編譯lib下的文件,這樣可以產(chǎn)生libunp.a,復(fù)制這個靜態(tài)庫到/usr/lib/和/usr/lib64/
如果提示:
unp.h:139: error: conflicting types for ‘socklen_t’
/usr/include/bits/socket.h:35: error: previous declaration of ‘socklen_t’ was here
需要注釋掉當(dāng)前目錄中unp.h的第139行。
復(fù)制libunp.a到系統(tǒng)目錄:
root@dan-laptop:/home/hehe/download/unpv13e/lib# cp ../libunp.a /usr/lib
root@dan-laptop:/home/hehe/download/unpv13e/lib# cp ../libunp.a /usr/lib64/

2.使用unp.h和libunp.a
如果直接復(fù)制unpv13e/lib/unp.h和config.h到/usr/include,那么在別的目錄編譯書上代碼時,很可會得到類似下面的錯誤:
In file included from daytimetcpsrv1.c:1:
/usr/include/unp.h:227: error: redefinition of ‘struct sockaddr_storage’
In file included from daytimetcpsrv1.c:1:
/usr/include/unp.h:249:30: error: ../lib/addrinfo.h: No such file or directory
/usr/include/unp.h:263: error: redefinition of ‘struct timespec’
/usr/include/unp.h:363: error: conflicting types for ‘gai_strerror’
/usr/include/netdb.h:647: error: previous declaration of ‘gai_strerror’ was here
/usr/include/unp.h:367: error: conflicting types for ‘getnameinfo’
/usr/include/netdb.h:653: error: previous declaration of ‘getnameinfo’ was here
/usr/include/unp.h:371: error: conflicting types for ‘gethostname’
/usr/include/unistd.h:857: error: previous declaration of ‘gethostname’ was here
/usr/include/unp.h:387: error: conflicting types for ‘inet_ntop’
/usr/include/arpa/inet.h:65: error: previous declaration of ‘inet_ntop’ was here
/usr/include/unp.h:395: error: conflicting types for ‘pselect’
/usr/include/sys/select.h:121: error: previous declaration of ‘pselect’ was here
daytimetcpsrv1.c: In function ‘main’:
daytimetcpsrv1.c:9: error: ‘MAX_LINE’ undeclared (first use in this function)
daytimetcpsrv1.c:9: error: (Each undeclared identifier is reported only once
daytimetcpsrv1.c:9: error: for each function it appears in.)
dan@dan-laptop:~/study/unp/4$ rm -f /usr/include/unp.h

這是因為unp.h包含config.h使用的是#include "../config.h",而此時unp.h和config.h的位置關(guān)系發(fā)生了變化,只需改為#include "./config.h"即可

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多