Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!rutgers!att!mtunb!dmt From: dmt@mtunb.ATT.COM (Dave Tutelman) Newsgroups: comp.sys.ibm.pc Subject: Re: Turbo C links in everything in obj's Summary: User library of individual .OBJs Message-ID: <1450@mtunb.ATT.COM> Date: 24 Mar 89 21:01:58 GMT References: <1065@ptolemy.arc.nasa.gov> Reply-To: dmt@mtunb.UUCP (Dave Tutelman) Organization: AT&T Bell Labs - Lincroft, NJ Lines: 31 In article <1065@ptolemy.arc.nasa.gov> raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) writes: >It appears that the linker in Turbo C (2.0) links in everything you >have in your .objs independent of whether the code is actually used. > >For instance, if you have a file with the following fn's in it > main, a, b, c, d, e >and main does not call any of a, b, c, d, or e, the linker still >includes the objects for a, b, c, d, and e. > >Does the Microsoft linker handle this? Both the Microsoft and Turbo linkers do the same thing in this regard. When you think hard about the richness of the C language, you'll realize that any other decision could result in serious bugs. There is a way you can control it, however. Both Microsoft and Turbo have librarians, whose function is to turn multiple .OBJs into a single .LIB file. When an .LIB is linked, the inclusion is one .OBJ at a time, as needed. (That's precisely what you want.) What you have to do is: - Write each function as a separate C file. - Compile the files to .OBJs. - Use LIB (Microsoft) or TLIB to make a .LIB file from the .OBJs. - When you link, refer to the .LIB to be linked in. +---------------------------------------------------------------+ | Dave Tutelman | | Physical - AT&T Bell Labs - Lincroft, NJ | | Logical - ...att!mtunb!dmt | | Audible - (201) 576 2442 | +---------------------------------------------------------------+