C-language Multi-file compilation under Linux

Source: Internet
Author: User
If you have more than one source file, there are basically two ways to compile it:
[Suppose there are two source files for TEST.c and TESTFUN.C]

1. Multiple files compile
usage: #gcc testfun.c test.c-o Test
Role: TESTFUN.C and TEST.c are compiled and linked to the test executable file respectively.

2. Compile each source file separately, and then link to the target file after the compiled output.
usage:
#gcc-C testfun.c//TESTFUN.C compiled into TESTFUN.O
#gcc-C test.c//test.c compiled to TEST.O
#gcc-o TESTFUN.O Test.o-o test//TESTFUN.O and TEST.O link to test the

above two methods compare, the first method compiles all the files need to recompile, and the second method can only recompile modified files, unmodified files do not have to recompile.

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.