Beck Sam
Beck Sam

Reputation: 31

Fatal error LNK1179: invalid or corrupt file: duplicate COMDAT ' '

I'm building Unreal Engine 4.27.0 from source on VS2019, but shows up this:

Module.UnrealEd.15_of_23.cpp.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT ' '

Building from source takes more than 5 hours already.

Upvotes: 3

Views: 916

Answers (2)

John Perry
John Perry

Reputation: 2678

Another possible solution, inspired by the discussion of a similar problem in mingw's gcc: compile with the /GL flag, which performs whole program optimization. It worked in my case, at least!

To be honest, I'm not entirely sure I understand what the problem was in my case, so I won't try to summarize that answer. Since I encountered the exact same problem they describe there when compiling the same code with gcc in mingw, that's what made me suspect I'd need a similar approach.

Upvotes: 1

Froyo_np
Froyo_np

Reputation: 656

I just battled this duplicate or corrupt COMDAT thing for a while, I finally figured out what was causing it for me - without knowing more about your project its hard to say what it is for you, but here goes:

  1. I'm building with c++ language: C++20, VS2022 (but I encountered the same also in vs2019)

  2. I'm building with experimental standard modules enabled - for fancy stuff like this: import std.core;

  3. I have some older code that I just #include all over, and I didn't read the somewhat specific rules about how these two manners of import/including play togeather with modules enabled. I have a handful of files that look like this (but with different classes)

    // whatever.ixx
    export module whatever;
    #include "oldHeaderFullOfTemplates.hpp"
    import someNewCustomModule;
    export class stuffWhatever {
    // ...
    }

the problem here is that, by #including below the export module line, I'm forcing the compiler to include that stuff in the module... sort of... and to my limited understanding, its got to create new, ever longer mangled unique linky-names for all the things in that header * all the times you include it in any module. Anyway, by moving my
#include "oldHeaderFullOfTemplates.hpp"
above my
export module whatever;

all my stupid comdat errors go away. Also - my understanding of c++20 modules is clearly... limited, so if I've lied above, perhaps more knowledgeable folks can correct me as to wtf is going on here. One last tidbit is an old VS compiler option /H{number} which should let you pick a length of (linky-names?) for the linker to consider before it decides something is duplicate. this option is deprecated though, and it didn't help me at all, even after setting to a very high number.

Upvotes: 3

Related Questions