Why are my units “compiled with a different version” of my own files?

前端 未结 14 1913
误落风尘
误落风尘 2020-12-16 16:22

I\'m building a program that uses plugins. Unfortunately, the plugin framework\'s dynamic linking forces the RTL and VCL out of my project EXE and into the BPL versions, an

相关标签:
14条回答
  • 2020-12-16 17:05

    I just had the same error message in Delphi XE. Mine was solved after closing Delphi, opening it again and recompiling my project.

    0 讨论(0)
  • 2020-12-16 17:08

    In my case, I added the locations of the "problem" units to my project's search path. As long as it could find it, it compiled. Of course, if you have several versions of the file in question, it could complicate matters...

    0 讨论(0)
  • 2020-12-16 17:10

    How I solved the 'path madness' in Delphi XE7:

      Rule1: Always separate the DCU from the PAS files
    
      Tools -> Option -> Library path: 
                     Path to global (3rd party) libraries (DCU folder) that never change.
    
                        c:\Delphi\Tools\FastMM\
                        c:\MyProjects\Packages\Third party packages\$(Platform)
                        c:\MyProjects\Packages\DragDrop\$(Platform)
                        c:\MyProjects\Packages\Graphics32\$(Platform)
    
      Project -> Options -> Search path: 
                     Path to personal libraries, that changes often. 
                     Enter the path to the DCU folder first, then path to PAS file. 
                     This way, the compiler will use the DCU files first, instead of recomilin every time from PAS files. 
                     It will recompile anyway if you do a Build.
    
                        c:\MyProjects\Packages\cCommonControls\$(Platform)_$(Config)
                        c:\MyProjects\Packages\cCommonControls\
    
      Project -> Options -> Output directory: 
                     Leave it empty so the exe file is generated in project's folder 
    
      Project -> Options -> DCU output directory: 
                     Use .\$(Platform)_$(Config) in order to enforce Rule1
    
    0 讨论(0)
  • 2020-12-16 17:12

    The error "unit is compiled with a different version of..." is an annoying one. It occurs in a situation like below:

         +--------+
         | unit A |
         +--------+
          |      |
          |      |
          V      |
      +--------+ |
      | unit B | |
      +--------+ |
          |      |
          |      |
          V      V
         +--------+
         | unit C |
         +--------+
    

    Both unit A and B use unit C and unit B uses C. Unit B and C are compiled and for some reason the source of unit B is not available. Now Unit C is changed (any change will do and is recompiled) And the dcu of unit C differs from the unit C used by unit B, so unit B needs to be recompiled too. But unfortunately, the source is not available so the compiler gives up.

    It is not entirely clear what's wrong with your situation.

    You have a test framework that links to the plugins. So where do unit X and Y fit in and do you recognize the pattern shown above?

    But the fact that a complete build solves the problem is hint in this direction. And this is not the first time I saw problems with partial recompiles. So I always use the complete version.

    0 讨论(0)
  • 2020-12-16 17:12

    Are you using a modified VCL? The units you reference in your interface section also determine your interface. I would suggest making sure you do not have two different versions of any of your units with the same name (including VCL/RTL) that may be referenced from your project. Maybe it is something a silly as the background compilation is using a different version of the units then the disk compilation. So editing it triggers the background compiler, which then messes up the synchronization.

    0 讨论(0)
  • 2020-12-16 17:15

    For me the problem was that I installed Delphi with minimum required components. And when I opened a project that was compiled with full Delphi installation it happened to me. Coping the files in the "Source" folder in Delphi installation folder from another machine with full Delphi installation solved my problem.

    0 讨论(0)
提交回复
热议问题