问题
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.
- 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.
- 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. - Use
COFF2OMF
to convert the static library. And even if the file size is strange, do at least try it. - 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