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
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.)
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.
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.
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
Re: Linking with another executable
You could use incremental linking. Linking's a fairly quick process though.
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...
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.
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?
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. :D
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. :p ;)
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
Re: Linking with another executable
Quote:
Originally Posted by Krishnaa
or you might not have Defragmented your hard disk in last 2 years. :D
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". :D
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. :D
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. ;)
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.
Re: Linking with another executable
For MrBeans information... (and Sid, I guess, thanks for your care) :)
...and following to original question.
All my experiments with dynamical linking to another executable gave me negative results. I've got positive results only in case of absolutely dumb exported functions. But in case exported function calls some other function (as normal function do :)) disregarding, Win API or C-runtime, the caller process crashes.
I admit I may have no sufficient qualification in this field and would appreciate any other information on the issue.
But now I agree with Ovidiu - to make life easier the DLL would be used for sharing valuable code.
Re: Linking with another executable
About the dlls.
Unfortunately with this program, speed is of the utmost essense, and dll files give a good 2-3% overhead when being executed.
Anyway a 9mb executable file is not a very disturbing problem.
And, Igor, the whole rebuild lasts 3 minutes :)
I am talking about the linking time, after all source files are compiled.
Re: Linking with another executable
Quote:
Originally Posted by SeventhStar
About the dlls.
Unfortunately with this program, speed is of the utmost essense, and dll files give a good 2-3% overhead when being executed.
Anyway a 9mb executable file is not a very disturbing problem.
And, Igor, the whole rebuild lasts 3 minutes :)
I am talking about the linking time, after all source files are compiled.
3 min. is not a big problem, one of my projects build use to take 30 min. :D
Re: Linking with another executable
Well I am not saying that it's unbearable... but it still is irritating.
But alas I will have to live with it :)
Re: Linking with another executable
Quote:
Originally Posted by SeventhStar
About the dlls.
Unfortunately with this program, speed is of the utmost essense, and dll files give a good 2-3% overhead when being executed.
Although I don't really believe that's true (how else as long as I can bet you never really measure it) 2-3% is absolutely insignificant. Just give me an user who complained of such a percentage (or even one who realised the difference).
Quote:
Originally Posted by SeventhStar
Anyway a 9mb executable file is not a very disturbing problem.
It's a very disturbing problem. Here we can further discuss a lot.
Quote:
Originally Posted by SeventhStar
And, Igor, the whole rebuild lasts 3 minutes :)
I am talking about the linking time, after all source files are compiled.
Don't tell me you usually report one day estimated to build a project's release, and 3 minutes of build leads you in a nightmare.
Re: Linking with another executable
This particular software is an internal company tool that will operate with huge, GIGANTIC even, data and we prefer for it to work straight 10 days, rather than 11. So no users will complain about it. I will ;)
And while a whole rebuild happens rarely (no more than once a day), it's being linked too often (20-30 times a day for example) and it's just boring to wait additional 14 secons... really it is. Try waiting 14 seconds and you'll see that it's boring.
Anyway... I don't understand why you're making such a big deal out of it. I already accepted this situation :)
Re: Linking with another executable
Quote:
Originally Posted by SeventhStar
Anyway... I don't understand why you're making such a big deal out of it. I already accepted this situation :)
We are "making such a big deal out of it" because:
- you asked.
- we sincerely want to help you.
- some of us do not accept anytime such a situation.