"In-depth understanding of computer systems" on Csapp.h and CSAPP.C compilation issues

Source: Internet
Author: User

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 :

< csapp.c >

In fact, it is not necessary to write Csapp.c file, directly copy the contents of the Csapp.c file to csapp.h the last line of the #end if before. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.