3

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?

Thanks, Alan

Alan Spark
  • 8,152
  • 8
  • 56
  • 91

2 Answers2

2

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.

Alan

Alan Spark
  • 8,152
  • 8
  • 56
  • 91
  • 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 Aug 29 '12 at 10:09
  • @rubenvb I think the reason the OP could link against the 32-bit `.lib` file is because it was actually an *import* 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` can resolve `.lib` import libraries - though I don't know where I'd find definitive proof... – Vladislav Martin Apr 11 '17 at 13:03
0

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 C way 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.

user827992
  • 1,743
  • 13
  • 25
  • 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 Aug 28 '12 at 09:38
  • In what language this library is written ? Maybe it's just C. – user827992 Aug 28 '12 at 09:40