Thread: Info regarding multiply linking single static lib

  1. #1

    Info regarding multiply linking single static lib

    So I haven't done any programming in a while, and to ease my way back into a rather massive project I decided to lump one aspect of the menial functions (which includes about 10 different classes and data etc) into a static-link lib. But a thought just occured to me I can't find a quick answer to, and I figured someone here would probably know.

    My app already uses a SLL called Common.LIB full of extremely low level tools (data, error, memory handling etc). Many of those tools use templates, and what I'm wondering is, if foo.LIB links Common.LIB and Project bar links both fu AND Common; Will MSVC 6.0 be smart enough to use code already generated from the templated Common classes which will be found in foo.LIB or will it generate a whole second set of identical code, thus bloating the app?

    To further illustrate my point (as that may have been a little confusing):
    //Project Foo uses a templated Common.LIB class thus
    CommonData<int> SomeStuff;
    CommonData<char *> SomeOtherStuff;
    //and so now Foo.LIB will contain code for an int and a char * version of the CommonData class...
    //Project Bar links to Foo.LIB and Common.LIB, then desires this:
    CommonData<int> DataForBar;
    So, will the final compiled executable contain 2 identical code segments for an int verson of CommonData? What will actually happen?
    "There's always another way"
    -lightatdawn (

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    No. If it does, the compiler is plain stupid!

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. Linking error with static template class members
    By cunnus88 in forum C++ Programming
    Replies: 6
    Last Post: 04-02-2009, 12:31 PM
  3. Problem with Free.
    By chakra in forum C Programming
    Replies: 9
    Last Post: 12-15-2008, 11:20 AM
  4. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  5. Help doing an e-mail program in c...
    By Tyler_Durden in forum C Programming
    Replies: 88
    Last Post: 01-02-2005, 03:12 PM