Unsolved External prebuilt libraries
-
Hi,
since I was solving some problems with external libraries, I realized I don't really understand how it works in QtCreator. There is a guide here and I'm following it.
But it doesn't seem to be working as described there for me. According to the guide, I should put my .dll file to 3rdparty/my_lib/bin/mylib.dll. But this doesn't work. Everything works fine if I put the .dll to 3rdparty/my_lib/lib/mylib.dll
It makes sense, because in the example the bin directory isn't mentioned anywhere in the project file:
INCLUDEPATH += 3rdparty/CatWhisperer/include LIBS += -L"3rdparty/CatWhisperer/lib" -lCatWhisperer
What am I missunderstanding here?
-
@vlada said in External prebuilt libraries:
But it doesn't seem to be working
What's not working? the compilation or the program doesn't run?
-
@VRonin Sorry for not being more specific. Compilation works fine but the program immediately crashes after start because it won't find the shared library.
-
This has nothing to do with Qt. Windows has pre-determined locations where it looks for libraries: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications
99% of the time option 1 is the way to go, 0.9999999% option it's option 6 -
@VRonin I don't think this is the case. Maybe I didn't describe it correctly. Let's say this is how my project looks like:
c:\qtapp\myapp\main.cpp
c:\qtapp\myapp\3rdparty\mylib\include\mylib.h
c:\qtapp\myapp\3rdparty\mylib\lib\mylib.dllNow I compile the app and the .exe will be created in
c:\qtapp\build-myapp-Desktop_Qt_5_13_1_MinGW_32_bit-Release\release\myapp.exeQtCreator probably adds the path of Qt libraries to the Windows search path, so these are found by the application and I assume it also adds the library path c:\qtapp\myapp\3rdparty\mylib\lib.
This works fine. But according to the guide I linked in my first post, the .dll file should be located in c:\qtapp\myapp\3rdparty\mylib\bin. But this doesn't work. So is the guide wrong?
-
That guide is about compiling a program using a 3rd party library, not deploying it. So the guide is not wrong, it's just not covering this aspect. I suspect that windeployqt will probably recognise the /bin structure and deploy the 3rd party library correctly
-
@vronin I'm not talking about deploying. I'm talking about developing my application and running it within QtCreator.
-
developing my application
The linker doesn't need the dll file so its location is irrelevant
running it within QtCreator
That's just an option inside Qt creator: https://doc.qt.io/qtcreator/creator-run-settings.html#selecting-the-run-environment
Just add the path to the bin directory to the
PATH
variable for the run environment