Weird linker error linking to opencv... "LNK1107: invalid or corrupt file: cannot read at 0x2E8"

18,984

If I would have to guess (partially based on the documentation of that error), I'd say you're trying to link directly against the DLL.

You probably want to link against its corresponding .lib file.

Share:
18,984
Jim
Author by

Jim

Updated on June 12, 2022

Comments

  • Jim
    Jim about 2 years

    This OpenCV build was working for me a few nights ago. I am trying to run the example grabcut.cpp file given with the OpenCV examples and so I set up a quick project and brough the cpp file in. Then, I set up all of the standard configurations and got this error on building.

    error LNK1107: invalid or corrupt file: cannot read at 0x2E8   
    opencv_calib3d231.dll
    

    What does this mean?

  • Jim
    Jim over 12 years
    I feel like I always linked against DLLs before... That's not normal?
  • user1071136
    user1071136 over 12 years
    Depends on the compiler; MinGW, for example, seems to be able to directly link against DLLs.
  • Bart
    Bart over 12 years
    Hmm, I don't know about MinGW. Perhaps you're right. It might do something similar as one could do with Visual Studio's tools to generate a .def and thereby a .lib from a DLL. However (unless anyone can tell me otherwise) I don't think Visual Studio allows for direct linking against a DLL. You either have to use a .lib or dynamically load the DLL in your code.
  • Elshan
    Elshan about 8 years
    make sure you are linking .lib file instead .dll
  • Benjamin Crawford Ctrl-Alt-Tut
    Benjamin Crawford Ctrl-Alt-Tut almost 4 years
    Another common case of this exact error is when accidentally missing the -o flag, thus mistakenly specifying a binary as a source file.