¿Por qué no puedo vincular un archivo .lib de 64 bits en MinGW?

I need to use a third party .lib / .dll file (probably compiled in Visual Studio) with my project in Eclipse CDT using MinGW.

I can dynamically link with the 32-bit version (using 32-bit MinGW) successfully but not with the 64-bit version (using 64-bit MinGW). When I run the 64-bit version, it crashes when invoking the third party function.

Is there something different that I need to do to get 64-bit working?

Gracias, alan

preguntado el 28 de agosto de 12 a las 09:08

2 Respuestas

The solution for me was to link against the 32-bit .lib file for 32-bit builds and the 64-bit . Dll file for 64-bit builds.

I'm still not sure where the inconsistency comes from, so any comments are welcome.


Respondido 29 ago 12, 10:08

The 64-bit .lib file format is just not the same as the 64-bit .a library archive format used by GCC/binutils. In short: 32-bit works, 64-bit doesn't. The reason is the same as any other: "why does this not work?"-question: it wasn't made to work. - rubenvb

@rubenvb I think the reason the OP could link against the 32-bit .lib file is because it was actually an importar library, not a static library. Would you agree? On Windows, a .lib is sometimes nothing more than a library generated from a .dll for symbol resolution during compilation (it's essentially a stub). I believe that MinGW's port of the GCC binutils' ld puede resolver .lib import libraries - though I don't know where I'd find definitive proof... - Vladislav Martín

Microsoft Visual Studio uses a different set of ABI if compared to GCC ( MinGW ).

It's not easy to make this work, many projects and libraries offers 2 versions of their library for Windows just to solve this issue, one for MSVS and one for MinGW.

The C++ ABI are different but there is a common ABI set with the C language, a trick consist in using the extern C keyword and try to use C++ code in a Camino C and link it as C code.

The answer to your question is no, you can try some trick but there is no standard ABI for this and no guarantee to make this work.

Either way you need to access the source code of your library to at least try something or recompile the library with MinGW, you can also try to send an email to the developer that probably doesn't know about this issue under Windows and ask for a different version of this library. What you have right now is useless without Visual Studio.

Respondido 28 ago 12, 10:08

I have emailed the developer but I did manage to get it working when I took the .lib file out of the equation for 64-bit builds... linking against the .dll works for me. Is this normal? - Alan Spark

In what language this library is written ? Maybe it's just C. - user827992

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.