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++ > Does linking wipe what I dont need?

#13448 - MumblyJoe - Sat Dec 13, 2003 5:51 pm

Quick question for all the hardcore coders here - if I compile all my library files (for a library I am writing) into one file, then link it into my main file, will the linker include EVERYTHING in the library.o file when I link it to my main file, or will it only include the code I actually use into my final output file?
_________________
www.hungrydeveloper.com
Version 2.0 now up - guaranteed at least 100% more pleasing!

#13449 - sajiimori - Sat Dec 13, 2003 6:32 pm

.o files are imported all-or-nothing. If you want to bring in smaller portions, make an archive (.a) of a set of objects, each of which contains a subset of the library (maybe even a single function per .o). Then the linker will import individual objects from the archive as needed.

#13450 - MumblyJoe - Sat Dec 13, 2003 6:46 pm

Is there anywhere you can recommend with more info on how to do this?
_________________
www.hungrydeveloper.com
Version 2.0 now up - guaranteed at least 100% more pleasing!

#13452 - sajiimori - Sat Dec 13, 2003 7:07 pm

http://www.gnu.org/software/binutils/manual/html_mono/binutils.html#SEC1