c++c++buildercoffomf

Linker error “contains invalid OMF record” 2


I'm working with Embarcadero XE8 C++ builder 32 bit.

I was adding a library to my program for solving the Unresolved external error.

When I added the library I got the error as in the title. So I searched the web and found this topic on stackoverflow: Linker error "contains invalid OMF record"

As it says the COFF2OMF tool, CAN work. Sadly it didn't work for me, I give a 7mb library file, when I convert it with the tool it's only 41kb... so I guess the convertion failed. When I add the converted files to my program it just ignores it and still says the unresolved external error.

So how can I get my library working with my C++ builder?


Solution

  • A little background:

    Libraries need to be compiled with the same kind of tool as the application you are trying to make, because every compiler does things a wee bit differently. Most libraries for Windows are compiled with the MVSC (Microsoft Visual Studio Compiler).

    You're using the Embarcardero Compiler, which means that the MVSC libraries are incompatible (you may have noticed that ;)).

    You have multiple options.

    1. If you can, get the source of the library and compile it with your own compiler. That way the chance to succeed is the highest.
    2. I may be mistaken since it's been a while, however I believe there's a tool called implib which takes the shared library (.dll) and generates an Embarcardero-style .lib from that for use in your project.
    3. Use COFF2OMF to convert the static library. And even if the file size is strange, do at least try it.
    4. Try the LoadLibrary function call. This one requires you to map the functions you need manually, however you get around using the .lib.

    Good luck.