Let’s say that there is this command:
g++ main.o somefile.o -lc -o main
What is the difference between linking object file somefile.o and linking library libc.a?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Files ending in “.a” are archive files. They essentially contain a set of “.o”s. Therefore, assuming “libc.a” contains “c1.o”, “c2.o” and “c3.o”, your command is essentially equivalent to unarchiving “libc.a”, then invoking:
Note that, the objects contained in the “.a” are only included if required, i.e., if at least one of their symbols is referenced by another “.o”.