Hey... If I just built a library for any open source software for C++, what file type should the library files come in? .a OR .o files? Thank you.

5 Years
Discussion Span
Last Post by christinetom

I'd say an ".a" file. An object file typically contains object code for a single source file, while an ".a" file contains multiple of them. (It is an archive of multiple .o files) So both did not involve any linking yet. Also note that this is a static library as oppposed to a shared library that are also quite common (.dll, .so). It means the machine code from the library will be copied into the final executable while with a shared library a table of stored and at startup the required functions are loaded into memory. (dynamic linking)


Thanks Gonbe.. So if I want to reference a library file in the linker section of my IDE then can I only use a .a file or can I also use .o files as long as I reference the path to tall of them in my linker paths?


You could reference all .o files as well, although I don't see the advantage of that over referring to a single .a file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.