Linker error “contains invalid OMF record” 2

无人久伴 提交于 2019-12-02 09:15:51

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/32695738/linker-error-contains-invalid-omf-record-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!