The compile steps are as follows:
1. My current working directory is/home/sxh2/clinux, the directory has 3 files inet_aton.c csapp.h csapp.c.
2. Compile the csapp.c file, the command is Gcc-c csapp.c, generate the target file CSAPP.O.
3. Compile the inet_aton.c file, the command is Gcc-c INET_ATON.C, generate the target file INET_ATON.O.
4. Link the target file csapp.o, INET_ATON.O (due to the csapp.c file in the part of the thread, GCC compile must take-lpthread, otherwise error), command for Gcc-o main CSAPP.O INET_ATON.O- Lpthread, generate the executable file main, run it.
Before solving this problem, I tried to try the online approach, not very good, and still have errors. Here, I should be able to run successfully, but it is not recommended.
The steps are as follows:
1. Put the csapp.h csapp.c file in/usr/include (the way you look at others is put under/usr/lib, try not to)
2. In Csapp.h, add the last line #end if before:
# include <csapp.c>
In fact, there is no need to write Csapp.c file, directly copy the contents of the Csapp.c file to csapp.h the last line of #end If. However, this does not comply with the principle of interface and implementation separation.
The 3.csapp.c file has a section on the thread, GCC compilation must take-lpthread, otherwise it will be wrong.
4. Add # include <csapp.h> to the header of the file to be compiled
5 Specific instructions are as follows: GCC Inet_aton.c-lpthread.
"In-depth understanding of computer systems" on Csapp.h and Csapp.c compilation issues (RPM)