Search code examples
c++visual-studio-2013midl

Midl compiler error: 2214


I've some problem with a project (an OCX): when I try to compile in release mode compilation stops with this message:

"1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(1178,5): error MSB6006: "midl.exe" exited with code 2214."

I cannot find any information useful to debug the error because is not an error code, is an exit code. What I can do? It stops right after start parsing "oaidl.acf".


Solution

  • I was getting the same error when trying to compile an OCX project that was upgraded in VS2013. I had to open the .odl file and move the #include statements inside the library block.

    Before:

    #include <olectl.h>
    #include <idispids.h>
    
    [ uuid(...), version(1.0), ... ]
    library ...
    {
        importlib(STDOLE_TLB);
        importlib(STDTYPE_TLB);
    

    After:

    [ uuid(...), version(1.0), ... ]
    library ...
    {
        #include <olectl.h>
        #include <idispids.h>
        importlib(STDOLE_TLB);
        importlib(STDTYPE_TLB);
    

    You may also be able to fix your problem by removing the /mktyplib203 switch from your MIDL settings.

    Project->Properties->Configuration Properties->MIDL->General->MkTypLib Compatible: Yes (/mktyplib203)
    

    This is very similar to this problem: FIX: Platform SDK Causes MIDL to Throw MIDL2311 Error

    MIDL2311 : statements outside library block are illegal in mktyplib compatibility mode.