0

How can I setup Delphi library folders so I can have both Debug and Release versions of my units library when I work on a project ? Until now I compiled my library in Release mode once is finished. But I encountered situations when I work on a project and I need to follow the debugging steps even in the compiled units. But if they are compiled as Release, it won't let me. And if I compile them as Debug, it puts the debuging code in the Release version of the project, which is not normal. I would like that when I switch between Debug and Release in my project, the units also switch. Can it be done ? If I put both Debug and Releas folders in Delphi library path, it will know when to choose te right one ?

Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55
  • Why do you need to debug the release version? Also, this question is off-topic for Stack Overflow - you would be better off asking in [Delphi Praxis](https://en.delphipraxis.net). – Dave Nottage Dec 08 '22 at 21:39
  • The question is unclear. Are the libraries part of the project or are they separate? Please consider giving a more detailed example. – Uwe Raabe Dec 08 '22 at 21:47
  • @UweRaabe It is about a general library (made by me). It is not part of the project. – Marus Gradinaru Dec 08 '22 at 23:01
  • You probably want the "Debug DCU Path" in Options -> Language -> Delphi -> Library, The convention is to put the pre-compiled debug DCUs in a subfolder named "debug" – Gerry Coll Dec 08 '22 at 23:47
  • So, in "Debug DCU Path" I put units compiled with Debug mode and in "Library Path" the Release version ? – Marus Gradinaru Dec 08 '22 at 23:51
  • 3
    Delphi IDE can use Debug Win32 version of DCU, DCL and BPL, it's not problem. To make a building of your application corectly you can do next steps: set `Output directory` of your library something like `$(MyLibraryPath)\Bin\$(Platform)\$(Config)`, than add into `Search path` of your application same value. After that Delphi compiler will take correct version of library in all cases. It will replace `$(Platform)` into `Win32` or `Win64` and `$(Config)` into `Release` or `Debug` depense of current buiding params. `$(MyLibraryPath)`can be some absolute path or add such enviroment variable. – Oleksandr Morozevych Dec 09 '22 at 08:13

1 Answers1

0

I finally managed to understand how it works: the key is $(Platform) and $(Config).

I made a test unit with a function that tells me what configuration I'm using:

unit Test;

interface

function GetConfig: String;

implementation

function GetConfig: String;
begin
 {$IFDEF RELEASE} Result:= 'Release'; {$ENDIF}
 {$IFDEF DEBUG} Result:= 'Debug'; {$ENDIF}
end;

end.

I compiled it in Debug and Release mode and saved .dcu files in D:\Delphi\MyLIB\Win32 \Release and \Debug. And the .pas in the D:\Delphi\MySRC. Then I go to Tools > Options > Language > Delphi > Library and I added D:\Delphi\MyLIB\$(Platform)\$(Config) to Library Path section and 'D:\Delphy\MySRC' to Browsing Path.

Now, if I make a new project and use that unit, the correct version is selected according to Buid Configuration. And if I switch to Debug and do a Trace Into (F7) over that function, I can debug inside it.

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Test;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 Caption:= GetConfig;
end;

end.

Thanks to Oleksandr Morozevych comment !

Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55