3

I'm trying to automate building of my project, using DCC32 to compile it.

The same project compiled in the IDE will compile OK, but when i call DCC32, i get the error below :

c:\myproject>dcc32 myproject.dpr
Embarcadero Delphi for Win32 compiler version 33.0
Copyright (c) 1983,2018 Embarcadero Technologies, Inc.
myproject.dpr(56) Fatal: F2613 Unit 'Forms' not found.

What should i do to DCC32 works exactly as the IDE compiler ?

delphirules
  • 6,443
  • 17
  • 59
  • 108
  • 1
    It depends on what libraries you are using and in which version the units were created and what version your are compiling your project. But as dcc32 will only use the .dpr file for compiling (and the unit it references) all other compiler options, which are set in the .dproj file, need to be supplied as commandline parameters of dcc32. Regariding your error: you need to specify unit prefixes like ‘vcl’. – R. Hoek Nov 16 '20 at 17:56
  • Ok, i could fix this specific issue by adding 'Vcl.' before the 'Forms'. But there are a lot of other problems like this one. Is there a way to dcc32 compile exact like the IDE compiles, with no further configuration needed ? Maybe i'm missing some DCC32 swithches – delphirules Nov 16 '20 at 17:59
  • Sorry for the misunderstanding, but I ment ‘specify unit aliasses’ as command line parameters (ex. -A Forms=Vcl.Forms). This way you do not need to modify your code. But you will need to specify much more. See list of command line options http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devwin32/dcc32_xml.html. But you alsoneed to supply search oaths for libraries and so on... – R. Hoek Nov 16 '20 at 18:04
  • I just want DCC32 compiles like the IDE does... this should be easy, as the IDE compiles ok without any errors – delphirules Nov 16 '20 at 18:05
  • It seems DCC32 is ignoring the Library path specified on Delphi Library option under Tools, so DCC32 is not find my units – delphirules Nov 16 '20 at 18:07
  • 1
    Don't call dcc32 directly, use `msbuild`. Then all these troubles will vanish. – David Heffernan Nov 16 '20 at 19:16
  • `dcc32 /?` gives you a list of the command-line parameters it accepts, including the one to specify the library path. The settings in the Delphi Library option under Tools is used by the IDE, not the command-line compiler; for it, you need to specify the library path at the command line. – Ken White Nov 17 '20 at 01:19

1 Answers1

3

I think you need to run rsvars.bat before your run dcc.

You can find it in $(BDSCOMMONDIR), which for me is C:\Program Files x86\Embarcadero\Studio\17.0\bin\rsvars.bat

This sets the relevant environment variables so that dcc can pick up the references it requires.

0909EM
  • 4,761
  • 3
  • 29
  • 40
  • This worked for Delphi units, like Forms, System etc. But now it's returning errors for my own units that are already on the Library path. It's like DCC32 is not searching the Library Path, like the IDE does – delphirules Nov 16 '20 at 18:18
  • In Delphi (IDE) they're on the Library path, I think you're probably now looking for the `-u` options on the command line, see command line reference [here](http://docwiki.embarcadero.com/RADStudio/Sydney/en/Delphi_Compiler). Hope that helps! – 0909EM Nov 16 '20 at 18:25
  • 3
    Note you can also compile from the command line using dcc, by using MSBuild. In that case you run rsvars.bat, then you invoke MSBuild as follows: `msbuild project.dproj /t:Rebuild /p:config=Release` – 0909EM Nov 16 '20 at 18:27
  • Thanks, the -u switch worked ! But i still have the problem having to manually edit 'Forms' by 'Vcl.Forms' and so on... Running rsvars.bat did not fix this. Any other thing i could try ? – delphirules Nov 16 '20 at 18:36
  • 2
    I'd personally build it via `msbuild` as noted above - your dproj should contain all the info that `msbuild` and `dcc` require to build the project (just run rsvars.bat first). I'm not sure what you mean about having to manually edit Forms by Vcl.Forms, if it all builds in the IDE as is, then you're missing something with dcc (at a guess, you need the `-U` option to specify your library paths).... but as I say, `msbuild` should just invoke `dcc` and pass all the data it requires – 0909EM Nov 16 '20 at 18:49
  • I never used MSBuild. Is this part of Delphi ? – delphirules Nov 16 '20 at 18:51
  • 1
    You might already have it installed, see [details here](https://learn.microsoft.com/en-gb/visualstudio/msbuild/msbuild?view=vs-2019) – 0909EM Nov 16 '20 at 19:01
  • 2
    @delphirules "*Is [MSBuild] part of Delphi ?*" - yes, and has been since Delphi 2007. See [Delphi's MSBuild documentation](http://docwiki.embarcadero.com/RADStudio/Rio/en/MSBuild) for details. There is no need to invoke `dcc32` directly when compiling whole projects. – Remy Lebeau Nov 16 '20 at 19:08
  • Thank you guys, using MSBuild makes me achieve what i needed ! RIP DCC32 :-D – delphirules Nov 16 '20 at 19:16