views:

2321

answers:

6

Say I've got a generic vertical market application and I want to package it as two separate programs aaa.exe and bbb.exe. Is there any way to use the Delphi linker to create an EXE/DLL file that doesn't have the same name as the DPR?

I can't just rename the file because I get this error

    bbb.exe - Unable to to locate component
      This application has failed to start because aaa.exe was not found. 
      Re-installing the application may fix this problem.
 

Now in general, I can rename an executable, but not this one. Thanks for the comments to point out my boneheadedness in this regard. There is a problem, just obviously not a normal one, maybe not even necessarily Delphi related.

I'm using Delphi 7 (if it is possible in 2007/2009 that would be awesome because I need more fodder for upgrade)

+14  A: 

Delphi 2007 and Delphi 2009 both use MSbuild. You can use post-build events in MSbuild to do almost anything you want. You could, for example, use the Copy task to copy the EXE into a new filename.

Craig Stuntz
+4  A: 

In addition to Craig's excellent answer (up-voted) if you are unfortunately stuck in D7, what Craig says can still apply, you would just need to do the heavy lifting yourself, i.e. create yourself a build script for building your apps rather than just compiling from the IDE, use a dos script or (even better) powershell, its a bit of work up front, but gives you more flexibility in the long run.

Tim Jarvis
+1 . I have done this with D7 and FinalBuilder.
Jamie
+4  A: 

You could use a build manager like FinalBuilder or even MSBuild on your own. I'd still recommend upgrading to Delphi 2009 though. There are so many other fabulous additions to 2009.

Jim McKeeth
A: 

Or you could have the program examine it's own exe name when you run it. If it is not aaa.exe or bbb.exe then have it copy itself into those two names and terminate (or launch them!)

Jim McKeeth
Only half kidding.
Jim McKeeth
+2  A: 

No, you cannot make the compiler create a file with a name different from the project name.

You can put your project in a "project group." Append to the group a batch project, and in that batch project, put a command to rename or copy the file. When you choose "Compile All" or "Build All," your main project will be processed, and if it compiles successfully, the next project will be processed as well, running the batch file.

Or, since you only said you want to package it as two programs, simply configure your installer to write two copies during installation, using different names, rather than producing both copies in your build environment and then distributing two copies of the file.

I don't understand your comment about being unable rename the file after you compile it. Renaming an EXE file is completely allowed, as long as it's not in use at the time.

Rob Kennedy
+3  A: 

Why can't you rename the file after compilation? I don't get the whole unix reference. I can rename every executable file I find on my machine, well... almost everyone, as long as they're not currently executing that is.

Why can't you? What is it that you're not telling us?

Simple right-click the file in explorer, select Rename, and give it a new name. Does that not work for you? If not, please do tell us why, because there is something you're not telling us about your situation.

Lasse V. Karlsen
Here's my error.bbb.exe - Unable to Locate ComponentThis application failed to start becasue bbb.exe was not found. Re-installing the application may fix this problem.In any event, renaming the program after compilation doesn't seems like a very elegant solution.
Peter Turner
If bbb.exe really does exist on disk, then the problem is not with the renaming, it is with the code that mistakenly cannot find the file.
Lasse V. Karlsen
I agree, and there is no problem with renaming. The problem is with running the renamed executable.
Peter Turner
Perhaps you should try to find out what in the program knows the name from the build step? I'd imagine that code could easily be changed to accommodate whatever filename the program has at any time
Lasse V. Karlsen