Question

I am using Delphi XE2 and I have a program that can be compiled as Win32 EXE or ISAPI DLL. That works fine.

However my problem is how to conditionally compile.

{$include MyConditionals.Inc}

{$ifdef ISAPISERVER}
library
{$else}
program
{$endif}
  MyProgram;

That works, but the FILE extension is getting wrong. It generates an EXE extension always. I need that when selected the library condition to have the DLL extension generated.

How can easily change the condition and have the right extension?

Was it helpful?

Solution

AFAIK you can't use a conditional compilation to change the extension of the binary. The extension of the file is set in the build process depending of the value (Application, Library, Console) for the AppType entry in the .dproj file. My recommendation is create a build batch file for the dll and another for the application.

OTHER TIPS

Apparently, IDE itself is preventing you from doing that. I successfully produced both executable binary and dynamic-link library from the following source:

{$IFDEF CGI}program{$ELSE}library{$ENDIF} test;

begin
end.

using dcc32 -DCGI test.pas and dcc32 -DNSAPI test.pas commands.

Delphi IDE thinks what it "owns" the project source, so it is advised against placing conditional directives there even in newer MSBuild-based IDEs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top