12
votes

I am trying to compile a package containing DSUtils.pas (part of DSPack) and it fails because it tries to compile wrong DirectShow9.pas unit - not the one from the DSPack but the one from the Delphi XE2 (Update 3) RTL.

The problem can be repeated with a minimal package:

package Package1;

{$R *.res}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION OFF}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES ON}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DEFINE DEBUG}
{$ENDIF IMPLICITBUILDING}
{$IMPLICITBUILD ON}

requires
  rtl;

contains
  DSUtils in 'x:\common\pkg\dspack\src\DSPack\DSUtils.pas';

end.

The error occurs in DSUtils line 1058 and the error is Undeclared identifier: FrameRateCode.

Result.FrameRateCode := (x and $00000003) shr 00;

Undeclared is 'FrameRateCode' - CtrlClick on the Result brings us to Winapi.DirectShow9 (in the RTL folder) which doesn't have this field declared.

Interesting part - if I go to the DSUtils uses list, click on DirectShow9 and press Ctrl+Enter, the DSpack version of the unit will open (and this unit has FrameRateCode field defined). So Delphi knows where the unit is. It just tries to compile the package by using the wrong DirectShow9.

Interesting tidbit: If I'm compiling a normal application (non-package) that uses DSUtils, everything works fine.

What I've tried:

  1. Compiling DirectShow9 from the DSPack into its own package (actually I used DirectX9 package from DSPack which contains all files from the DirectX9 folder) and adding it to the 'requires' list. Doesn't work.

  2. Adding the folder with DirectShow9 file (from DSPack) to the beginning of the system path and rebooting. Doesn't work.

  3. Adding the folder with DirectShow9 file to the beginning of the library path. Doesn't work.

  4. Adding the DirectShow9 unit to the package with the explicit path. Doesn't work.

  5. Copying the DirectX9*.pas into the DSPack folder so that the DirectShow9 unit would be in the same folder as the DSUtils unit. Doesn't work.

I see three possible workarounds, but I'm not happy with any of them.

  1. I can comment out the problematic code. Luckily, it is only this one line, everything else compiles with Delphi's DirectShow9.

  2. I can rename DirectShow9 from DSPack but then I may have to fix the 'uses' part in different application.

  3. I can turn off automatic prefixing with 'Winapi.' but that will cause me lots of additional work editing thousands and thousands files.

What I would really like to see is getting XE2 to use the right source file.

1
have you tried adding the DirectShow9.pas unit to the package? I remember I had the same issue a while ago, but I was trying to install it in D2010, I've managed to fix it with minimal changes, but I can't remember how I did it, it's almost 2 years ):user497849
Oh, yes, tried this too. I'll update the question.gabr
damn... I'm worried that they broke something in XE2... have you tried installing it into D2010?user497849
Could it be that the previous versions did not have DirectShow9? I assume that if it is delivered with XE2, it will be in the packages your package uses, and the .dcp will select the one that is in these packages. So change the name of the unit to DSPack.DirecthShow9.pas and use that one, fully qualified. Not sure if that works right away, but it will certainly give you a hint what to do.Rudy Velthuis
one way to force the compile of the correct unit is by renaming it and adding an alias for it, eg. rename DirectShow9.pas to DirectShow9xe2.pas and then add an alias DirectShow9=DirectShow9xe2Lee_Nover

1 Answers

3
votes

I faced the same problem, and I simply commented out all the problem lines (there was 2 or 3 of them). Everything works perfectly fine.

Another option is to use the latest DSPack (which is compatible with XE2): http://code.google.com/p/dspack/

Or you can rename DSPack's DirectShow9 file, as discussed here: http://www.progdigy.com/forums/viewtopic.php?p=16971