Cannot find my dll
-
I am trying to use my library from a console or widget application. I've tried this reference https://wiki.qt.io/How_to_link_to_a_dll but it didn't work. And it's producing error like:
error: file not recognized: File format not recognized collect2.exe:-1: error: error: ld returned 1 exit status
I am using qt 5.9 msvc 2015 and 2017. I also tried this:
LIBS += -L"D:\Project\build-MyLibrary-Desktop_Qt_5_9_6_MSVC2015_64bit-Debug\debug" -lDLL
but it produce error like:error: cannot find -lDLL collect2.exe:-1: error: error: ld returned 1 exit status
What seemes to be wrong here? Can u help fix.
-
Is this library compiled using MSVC ? file format wrong indicates that it is not valid image.
-
Is this library compiled using MSVC ? file format wrong indicates that it is not valid image.
@dheerendra said in Cannot find my dll:
Is this library compiled using MSVC ? file format wrong indicates that it is not valid image.
yes it is compiled using msvc. how can I fix it then?
-
I am trying to use my library from a console or widget application. I've tried this reference https://wiki.qt.io/How_to_link_to_a_dll but it didn't work. And it's producing error like:
error: file not recognized: File format not recognized collect2.exe:-1: error: error: ld returned 1 exit status
I am using qt 5.9 msvc 2015 and 2017. I also tried this:
LIBS += -L"D:\Project\build-MyLibrary-Desktop_Qt_5_9_6_MSVC2015_64bit-Debug\debug" -lDLL
but it produce error like:error: cannot find -lDLL collect2.exe:-1: error: error: ld returned 1 exit status
What seemes to be wrong here? Can u help fix.
@LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
Also, in the link you posted they do it like this:LIBS += "$$PWD/myLibrary/mylibrary.dll"
Did you try?
-
@LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
Also, in the link you posted they do it like this:LIBS += "$$PWD/myLibrary/mylibrary.dll"
Did you try?
@jsulm said in Cannot find my dll:
@LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
Also, in the link you posted they do it like this:LIBS += "$$PWD/myLibrary/mylibrary.dll"
Did you try?
yes and I receive error like
error: file not recognized: File format not recognized collect2.exe:-1: error: error: ld returned 1 exit status
im not sure if it is has anything with the msvc version or kit version? is it? cause i only get the error if only choose kit version of msvc 2017 and 2015 for both library and console application.
-
@jsulm said in Cannot find my dll:
@LovelyGrace What is the file name of your DLL? DLL as file name for a lib is strange.
Also, in the link you posted they do it like this:LIBS += "$$PWD/myLibrary/mylibrary.dll"
Did you try?
yes and I receive error like
error: file not recognized: File format not recognized collect2.exe:-1: error: error: ld returned 1 exit status
im not sure if it is has anything with the msvc version or kit version? is it? cause i only get the error if only choose kit version of msvc 2017 and 2015 for both library and console application.
@LovelyGrace said in Cannot find my dll:
error: file not recognized: File format not recognized
Then your DLL has different ABI (means is incompatible with your current compiler). Is your lib 32bit or 64bit. And what about your app (32bit/64bit)?
-
@jsulm said in Cannot find my dll:
@LovelyGrace said in Cannot find my dll:
error: file not recognized: File format not recognized
Then your DLL has different ABI (means is incompatible with your current compiler). Is your lib 32bit or 64bit. And what about your app (32bit/64bit)?
64 bit. How do I fix this then?
Should both library and application has the same kit version? So that the application can use the library?
-
@jsulm said in Cannot find my dll:
@LovelyGrace said in Cannot find my dll:
error: file not recognized: File format not recognized
Then your DLL has different ABI (means is incompatible with your current compiler). Is your lib 32bit or 64bit. And what about your app (32bit/64bit)?
64 bit. How do I fix this then?
Should both library and application has the same kit version? So that the application can use the library?
@LovelyGrace You cannot mix 32bit and 64bit binaries. You need to build both as 32bit or 64bit. So, yes same Kit.
-
From this statement:
copy .lib to project directory in the directory with myProgram.pro, create the folder myLibrary. Enter this directory, and then copy the following files to it: mylibrary.dll, mylibrary.h and mylibrary_global.h
which .dll should I get, from the debug or from the release? I am not sure to this though
-
Now I'm getting this error: LNK1107: invalid or corrupt file: cannot read at 0x330. Same kit version for library and application
-
Now I'm getting this error: LNK1107: invalid or corrupt file: cannot read at 0x330. Same kit version for library and application
@LovelyGrace I'm not a Windows expert, but as far as I know you need *.lib file for linking and *.dll for executing your app. So, in my opinion the description in the link you posted is wrong - you should add the lib file to your pro file, not dll. But I may be wrong here.
"which .dll should I get, from the debug or from the release?" - depending on whether you're building your app in debug or release mode (same story: don't mix debug and release binaries).