gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > question regarding C libriaries

#54937 - sparda - Fri Sep 23, 2005 6:57 pm

Im confused, Im learning C programming but i dont understand something. what is the difference between library and heather files?

also, What is the difference between object file libraries that end with
.o prefix and the .a prefix? Are they the same thing?

any help would be appriciated.
_________________
genius is 1% inspiration, 99% perspiration .

#54942 - paladine - Fri Sep 23, 2005 7:18 pm

A library is a compiled form of source code. It allows you to use the source code without access to the original C code. A header file is like a declaration of what is inside the library and how to use it. Some people don't like to give out their source code outright so they will often compile their source into a library for distribution as well as the header file so others can use it.

When you compile a C file you end up with a .o (object) file. Multiple .o files can be packaged into an .a file (archive). Think of it like a zip file for .o files. Your compiler knows the format of archives so it can use it when linking your program.

#54943 - sparda - Fri Sep 23, 2005 7:23 pm

Ok, i understand header and libraries now, thanks, but how do you "zip" (.o)object files into (.a)archieved file? do you need a program?
_________________
genius is 1% inspiration, 99% perspiration .

#54946 - tepples - Fri Sep 23, 2005 7:33 pm

The 'ar' program, part of GNU binutils, acts much like 'tar' or 'zip' or 'gbfs' to create a .a file from several .o files.

GNU ar manual
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#54949 - sparda - Fri Sep 23, 2005 7:47 pm

thanks alot tepples, you really cleared up alot of things for me. And thanks for the link also, i'll be sure to check it out.

Also, I CHOOSE PSP!
_________________
genius is 1% inspiration, 99% perspiration .