Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile package containing DSUtils in XE2

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.

like image 321
gabr Avatar asked Feb 10 '12 11:02

gabr


1 Answers

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

like image 75
djsoft Avatar answered Oct 30 '22 13:10

djsoft