CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Nov 2002
    Location
    Sofia, Bulgaria
    Posts
    661

    Linking with another executable

    Hello

    I am writing two executables, one being a unit test application of the other. The unit test has access to the headers of the first executable and I am looking for a way to use the functionalities.

    Is there a way to statically link to another executable... Some linker option make it look like a library, perhaps.

    I know that I can make a library from the first exectutable's code, but I'd prefer to save this step

    Thanks for any help
    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames

  2. #2
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: Linking with another executable

    Are both executables .EXE programs ?

    You can exports functions from .EXE just like the way DLL do, and your second application can use it (the exe which exported functions will be totaly used like DLL, it wont run separately.)
    Regards,
    Ramkrishna Pawar

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Linking with another executable

    Quote Originally Posted by SeventhStar
    Is there a way to statically link to another executable... Some linker option make it look like a library, perhaps.
    NOPE.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: Linking with another executable

    Statically linking to executable can be totaly equvivalent of including the source(of the exe which you want to treat like static library) in project.
    Regards,
    Ramkrishna Pawar

  5. #5
    Join Date
    Nov 2002
    Location
    Sofia, Bulgaria
    Posts
    661

    Re: Linking with another executable

    Yes, but I didn't want to lose time in linking the same files again...

    Guess I'll have to do it...

    Thanks anyway
    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: Linking with another executable

    You could use incremental linking. Linking's a fairly quick process though.

  7. #7
    Join Date
    Nov 2002
    Location
    Sofia, Bulgaria
    Posts
    661

    Re: Linking with another executable

    Quote Originally Posted by GCDEF
    Linking's a fairly quick process though.
    Well it takes about 20 seconds for the linker to make an executable and about 14 seconds for the librarian to build the library.

    I just wanted to skip these 14 seconds somehow...
    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames

  8. #8
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Linking with another executable

    Quote Originally Posted by SeventhStar
    Well it takes about 20 seconds for the linker to make an executable and about 14 seconds for the librarian to build the library.
    Buy a new computer, or at least upgrade its physical memory.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  9. #9
    Join Date
    Nov 2002
    Location
    Sofia, Bulgaria
    Posts
    661

    Re: Linking with another executable

    Well it's amd athlon 64 x2 dual core 3800+ (2 ghz), 2 gb ram, hdd hitachi sata2 7200rpm 8mb cache

    Should I really?
    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames

  10. #10
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882

    Re: Linking with another executable

    This is more than enough, I think the source code must be huge.....or you might not have Defragmented your hard disk in last 2 years.
    Regards,
    Ramkrishna Pawar

  11. #11
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Linking with another executable

    Quote Originally Posted by SeventhStar
    Well it's amd athlon 64 x2 dual core 3800+ (2 ghz), 2 gb ram, hdd hitachi sata2 7200rpm 8mb cache

    Should I really?
    Normally, not.

    Well, my computer is just a poor Pentium 4 - 2.8 GHz, 1GB RAM and never faced such type of problems.
    Who knows? Maybe exchanging them, I can help you to get rid of troubles.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  12. #12
    Join Date
    Nov 2002
    Location
    Sofia, Bulgaria
    Posts
    661

    Re: Linking with another executable

    Yep... and with libraries like Boost, LuaBind and even the standard library, the compiler expands the template code to 6-7 times it's original size
    It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames

  13. #13
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Linking with another executable

    Quote Originally Posted by Krishnaa
    or you might not have Defragmented your hard disk in last 2 years.
    AFAIK (but not quite sure) disk defragmenting for NTFS is just a funny waste of time.
    Anyhow, I don't remember last time I did it. Usually I reinstalled OS more often than once at two years. And in that case the best disk defragmenter is "format".
    Quote Originally Posted by Krishnaa
    This is more than enough, I think the source code must be huge.....
    I remember some clever guys using a cool design tool. After few months of design work, they pushed "Generate Code" then "Build". The resulted 1GB executable made them real troubles, indeed.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  14. #14
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Linking with another executable

    Quote Originally Posted by SeventhStar
    Yep...
    That's a reason for which those blamed guys from Microsoft invented DLLs for us.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  15. #15
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Linking with another executable

    Quote Originally Posted by SeventhStar
    Well it takes about 20 seconds for the linker to make an executable and about 14 seconds for the librarian to build the library.

    I just wanted to skip these 14 seconds somehow...
    Forgive me, no offence, but...

    If you want skip them then skip them. The possible ways for skipping (in order of preference):
    • Think 14 seconds about your girl/wife, look at her photo.
    • Take a couple sips of espresso/coke.
    • Look at the window/aquarium/magazine cover
    • Think about your code deciding how to improve its design and eliminate its frequent re-building


    Now, been gravely serious... Man, are you kidding? Do you really cannot stand 14 seconds of build? Or even 34? Then choose the last variant.
    Best regards,
    Igor

Page 1 of 2 12 LastLast

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

Featured