Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Storing libraries in a particular folder



  • I am making a Qt Gui C++ application using shared libraries for windows...
    my question is when I am including dlls in my application, I want to store the dlls in a particular folder(bin folder) and the executable is out of that folder.
    is this possible??
    and if possible what changes I should make in the .pro file, so that when executing the executable it can find the respective dlls.
    please reply..

    Thanks in advance,
    Ketan Shah.



  • I didn't do this before but I think you should be able to load libraries at runtime using "QLibrary":http://doc.qt.nokia.com/latest/qlibrary.html

    Also try :
    @
    QStringList path = QCoreApplication::libraryPaths();
    path.append(qApp->applicationDirPath()+"\bin");
    QCoreApplication::setLibraryPaths(path);
    @

    Where bin folder is where you put dlls (inside application install directory).



  • Why not put the exe in the bin dir along with the dll's? That way no changes are needed to environment.



  • but if possible i dont want to keep the dlls and exe together...
    is there any proper way to do that...



  • In that case you need to tell the system where to find your dll's. That is you need to somehow alter the %PATH% environment variable. You could do this in a simple wrapper script that launches the real application or a compiled stub application. You may even be able to do it in a windows shortcut (I can't recall off the top of my head).


Log in to reply