How can I manage the EXE name based on the target platform?

I would like to have two different exe files, depending on whether it is a 32-bit or 64-bit assembly, for example FooBar32.exe and FooBar64.exe. Is there a way to install this or will it be a postbuild action?

+3


source to share


4 answers


In the Project Options section of the Application tab, there is an option to change the target file extension. You can use this to change the name of your project executable for different platforms.
NOTE. This only extends the default name to be created (project name + file extension)

enter image description here

EDIT: As you can see, this approach has one drawback, which means that it always adds a period between the project name and the target file extension.

But to be honest, I rather take the approach where I configure Delphi to output 32 bit binaries to Bin32 binaries and 64 bil binaries in the Bin64 folder, instead of even renaming the main binaries. What for?



If your application uses any external dynamic link libraries (dlls), you need to make sure they are available for each supported platform (32-bit executables require a 32-bit dll, while 64-bit executables require a 64-bit dll ).

So, if you keep all of these DLLs in the same folder, you will need to make sure they are named correctly (all 32-bit dlls will be 32-prefixed, and all 64-bit dlls will be 64-prefixed). But this also means that in your code you will need certain entries to import functions from these dlls (one for the 32-bit dll and one for the 64-bit dll). And that can complicate things.

Therefore, creating separate bin files for 32-bit and 64-bit versions of applications allows you to have dlls for 32-bit and 64-bit applications with the same names, so there is no need to make any changes to the source code to be able to handle 32-bit bit and 64 bit dll

+10


source


Is there a way to install this or will it be a postbuild action?

As far as I know, you cannot use project options to change the output filename for different target architectures. So, you need to change the name of the output file post-build.



For debugging purposes, you do not need or need to rename the executable. The debugger won't like it if you do this. So the deployment time is the rename time.

+3


source


Not exactly what you want, but maybe this helps:

{$IFDEF WIN32}
{$EXTENSION 32.exe}
{$ENDIF}

{$IFDEF WIN64}
{$EXTENSION 64.exe}
{$ENDIF}

      

So, your executables will be Foobar.32.exe

and Foobar.64.exe

(with two dots).

+3


source


I do this all the time, having two projects in the project group: FooBar32.exe

and FooBar64.exe

. FooBar32.exe

installed with 32-bit options and FooBar64.exe

installed with 64-bit options. Each of the projects has the same units. The easiest way is to create FooBar32.exe

with all the necessary files, then create FooBar64.exe

, select the files FooBar32.exe

and drag and drop them onto FooBar64.exe

. Changes to either file affect both projects as they refer to the same files. Just do Build All from the design team to build both at the same time.

+1


source







All Articles