"UNIX Network Programming Volume 2" Compilation Environment Construction

1. Download the source code

    Homepage of W. Richard Stevens: http://www.kohala.com/start/
    Download unpv22e.tar.gz to /usr/local/src directory

unpv22e.tar.gz can be downloaded from the Linux Commune Resource Station:

------------------------------------------Dividing line------ ------------------------------------

The free download address is at http://linux.linuxidc.com/

Both username and password are www.linuxidc.com

The specific download directory is in /2017 data/February/9/UNIX network programming volume 2 source code environment construction/

For the download method, see http://www.linuxidc.com/Linux/2013-07/87684.htm

------------------------------------------Dividing line------ ------------------------------------

2. Unzip

    tar xvf /usr/local/src/unpv22e.tar.gz -C /root/bin

    Note: It must be in the /root/bin folder. If you do not try not to be in this folder, an error will be reported in step 4. Unable to generate /libunpipc.a file
3. Compile the library file
 
    cd /root/bin/unpv22e/ //Note: may need to be in root. Otherwise, the permissions are not enough

    ./configure

    Edit the generated config.h file, comment the following lines
 
    vi config.h 

    56 // #define uint8_t unsigned char
    57 // #define uint16_t unsigned short 
    58 // #define uint32_t unsigned int

    Add MSG_R and MSG_W definitions
    vi config.h 
    65 // add by jcq 
    66 typedef unsigned long ulong_t; //Note: Here, some have #define in front of them, I didn't add them, so they can be compiled.
    67 #define MSG_R 0400 
    68 #define MSG_W 0200
 

    Add _GNU_SOURCE definition
    vi config.h 
 
    #define _GNU_SOURCE


    Find the file wrapunix.c in the unpv22e/lib directory------------The name of this file is all wrong on the Internet

    Compile wrapunix.c, use mkstemp function to replace mktemp function
 
    cd lib 

    181 void 

    182 Mktemp(char *template) 

    183 { 

    184 if (mkstemp(template) == NULL || template[0] == 0) 

    185 err_quit("mktemp error"); 

    186 }

 

    Compile and generate libunpipc.a
    cd lib 
    make
4. Build your own directory for writing code

    mkdir -p /root/bin/unpv2 

    cd - //Note: It is better to cd unpv2 here, otherwise the next step will report an error
    cp /root/bin/unpv22e/libunpipc.a /root/bin/unpv22e/config.h /root/bin/unpv22e/Make.defines .

5. Compile each directory's own files

    Copy the *.h header files and Makfile files in each subdirectory, and then execute

    cp /root/bin/unpv22e/dir/*.h /root/bin/unpv22e/dir/Makefile /root/bin/unpv2

    make filename

    You can compile the code in each subdirectory


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325918158&siteId=291194637