3
votes

I'm linking a dll with some dependencies on other dlls. I have a trouble with linking a 64bit version of my project. With 32bit version all is ok as far as I use mingw32. But when I switch to 64bit version of dependent dlls and mingw-w64 it tells the following:

c:/.../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible .\lib\native/libblabla.dll when searching for -llibblabla

Where 'libblabla' is a library I depend on. I'm absolutely sure it is 64bit version and should be compatible. Is it a bug in mingw?

Also, I tried to link using lib file, but provided lib is also considered as incompatible and the one generated by dlltool has no import table generated!

I'm totally stuck with this. Thank you.

1
Did you ever find a solution to your problem? I'm getting similar errors only mine are reversed... everything works for 64-bit dlls and fails with 32-bit. I get the same radix error when using nm -t. - Jason

1 Answers

2
votes

First, to get some possible misunderstanding out of the way:

  1. GCC/ld can link to (properly exporting) 32-bit DLLs and .lib/.a import and static libraries.
  2. GCC/ld should be able to link to a properly exporting 64-bit DLL or .a import or static lib, but never a 64-bit .lib file.
  3. You aren't building/linking with -m32, are you?

By "properly exporting" I mean that dumpbin /exports or nm -t reveal exported symbols when run on the DLL.

What you should try:

  1. Build the through a call to gcc, not any direct calls to binutils. The options -shared -o name.dll -Wl,--import-lib, libname.dll.a should get you started.

  2. Use MinGW-w64's gendef (it's in the mingw-w64-tools directory in their SVN/sources) to generate a .def file, which you can create an import library.

If these produce no symbols in the import library, you're not exporting any symbols. Although this would be surprising as the error message says the dll is 32-bit. What does MSYS/Cygwin's file command on the dll return?