Bird
0
0

You want to compile multiple C files (a.c, b.c, c.c) into a single executable named 'app'. Which sequence correctly uses the compilation process?

hard📝 Application Q8 of 15
C - Basics and Execution Environment
You want to compile multiple C files (a.c, b.c, c.c) into a single executable named 'app'. Which sequence correctly uses the compilation process?
Agcc -c a.c b.c c.c -o app
Bgcc -c a.c gcc -c b.c gcc -c c.c gcc a.o b.o c.o -o app
Cgcc -E a.c b.c c.c gcc -S a.i b.i c.i gcc -c a.s b.s c.s gcc a.o b.o c.o -o app
Dgcc -c a.c b.c c.c -o app gcc a.o b.o c.o -o app
Step-by-Step Solution
Solution:
  1. Step 1: Understand compiling multiple files

    Each source file must be compiled separately with '-c' to produce object files.
  2. Step 2: Linking object files

    Link all object files together to create the executable.
  3. Final Answer:

    Compile each file separately, then link all object files -> Option B
  4. Quick Check:

    Separate compile, then link = correct multi-file build [OK]
Quick Trick: Compile each file separately, then link all [OK]
Common Mistakes:
  • Compiling all files at once with -c
  • Skipping linking step
  • Overcomplicating with preprocessing and assembly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes