Delphi command line compiler - using same library path as the IDE

4.9k views Asked by At

Is there a way to instruct DCC32 to use the same library path that is used by the IDE (i.e. in Tools/Options/Environment Options/Delphi Options/Library - Win32)?

For obvious reasons, I do not want to maintain two lists of directories (one in a cfg file, one in the Delphi IDE).

5

There are 5 answers

1
jasonpenny On BEST ANSWER

If you are using Delphi 2006 or later, you can use MSBuild instead of dcc32, and MSBuild will use the same search path as the IDE

2
Jorge Córdoba On

You should have a cfg file in your project directory called yourprojectnamedpr.cfg which actually should contain all the directories defined in the IDE for that project.

4
Caleb Hattingh On

It is a lot of work to use DCC32 to build from the command line. MSBuild is far easier. The library path is stored in the registry, but the location depends on the Delphi version, for example (python code):

if BDSVER == '5.0':
    CompanyText = 'Borland'
else:
    CompanyText = 'CodeGear'

key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,'Software\\' + CompanyText + '\\BDS\\' + BDSVER + '\\Library')    
IncludePath = _winreg.QueryValueEx(key,'Search Path')[0]

# Then you must replace the environment vars $(BDS), $(BDSCOMMONDOR) etc
IncludePath = ReplaceEnvironVars(IncludePath)

And there is much more to do. You must also obtain the search path, and you must obtain conditional defines from the .dproj file, etc.

I wrote a complete automated build tool in python (for BDSVER >= 5), back when Delphi 2007 installed on XP x64 had a broken MSBuild. Later, it turned out that some required configuration files were not copied into the correct .NET folder by the Delphi installer. Copying these files to the correct location fixed the problem, and now I use MSBuild.

0
neves On

If you use an older Delphi (e.g. Delphi 7), you must put all your information in the "Search Path" Directory option in your IDE. It will be saved in your .dof file. The .dof file is the main reference of your project.

The IDE will also automatically update the .cfg every time you change the project configuration. The .cfg is the specifies the compilation option for the command line compiler. Both the .cfg and the .dof must be under version control.

If, instead of editing your .dof file from the IDE, you manually edit it, you can use the dof2cfg utility to generate a new .cfg from your .dof. You will have to put it in your build chain.

0
roeland On

This works for me:

call "C:\Program Files (x86)\Embarcadero\Studio\19.0\bin\rsvars.bat"
msbuild project.dproj