From: "Carolyn Kelly-Pajot" References: <199710270603 DOT RAA16492 AT rabble DOT uow DOT edu DOT au> Subject: Re: DJGPP linker: a definitive answer wanted Date: Mon, 27 Oct 1997 09:56:52 -0500 Lines: 55 Message-ID: Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Brett Porter wrote in article <199710270603 DOT RAA16492 AT rabble DOT uow DOT edu DOT au>... >Hi > >This issue was not addressed in the FAQ, and a quick browse of the mail >archives yielded two different answers in posts of people I haven't seen on >this group since I've been here. > >So I would like a definitive answer from someone who knows 100% that it is >the truth, the whole truth and nothing but the truth (so help me God). > >Anyway, the scenario is... > >I am writing two programs simultaneously that share some classes, so I link >the files with just those classes to both. Some of the functions in these >classes are used in both programs, some only in one (ok, maybe this isn't an >example of great design, but I'm not a C++ purist, so I don't really care) > >Now, will _all_ of the functions be linked into _both_ of the programs, or >only the ones used? If they all are, is there a way of making sure only the >used ones are linked (eg conditional defines, or only good >programming design) > >I appreciate this help, and I'm _really sorry_ if the issue has already been >beaten to death (I couldn't really find it in the search with keyword >'link'), but if I at least get a definite answer here, future searchers >might have better luck. > >Thanks for your help. > >Brett > >-- >"Who here believes in telekenesis? Raise MY hand!" >-- >Brett Porter >bporter AT rabble DOT uow DOT edu DOT au > >http://www.geocities.com/CollegePark/Union/3596 > Humour, Programming, and more. > The linker links in the ENTIRE OBJECT file, even if just 1 of the objects in it are needed. If you have class functions defined in a .O file, and use that class, EVERYTHING in the object goes in. This is why each function from the C library is seperate - so no unneeded code gets linked in. The use of the word EXTERN is ok when delcaring variables (such as with allegro) but if the variable is never used again, just the definition, then it doesn't get linked. Hopefully, that answers your question.