Results 1 to 6 of 6

Thread: To link or not to link

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271

    To link or not to link

    I got question on linking particularly in msvc6.
    Lets say I have the winmain in the main.cpp ->main.obj
    I have a foo class=>foo.obj
    and
    foobar class->foobar.obj

    In main i only have an instance of foo class.
    Basically I want to compile both classes but only link foo.obj.
    So is there a way to tell the linker "Hey if theres no instances of class foobar, dont link it in"??


    Thanks

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    No, not automatically. Why do you want to compile foobar if there are no instances?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    I would have thought it'd be optimized out anyway if there's no instances.
    an ending

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Not necessarily. It depends on the linker and its settings. And some more stuff. In general, stuff from .libs gets included only when needed, stuff from .objs always.


    Still, you could simply NOT compile the file...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    That sort of optimization can only be done by the linker. For example there could be a bar.obj that uses the foobar class, in which case it should not be discarded.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271
    Thanks for answer.

    CornedBee,
    I was just exploring a GUI designer idea.
    So ill go with libs.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width