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.

Recommended Answers

All 4 Replies

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.

Thanks Gonbe.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.