0

I have a C++ project using Qt and I have it working as expected. However, the problem is when I copy the executable to a standard installation of a OS (e.g. Windows or a Linux) upon execution I receive the QtWidgets or some other Qt libraries missing error.

I tried referencing the Qt Documentation but I am unable to find a solution or an example of what I am after. It has something to do with Static and Dynamic Building... but could not locate a good example or tutorial.

I looked at the tutorial http://www.qtcentre.org/wiki/index.php?title=Deploying_Qt_Applications but it is not quite the most efficient solution.

Basically I want the system to include the required Qt libraries along with the final compiled file. How can I pull it off?

epsilon
  • 2,849
  • 16
  • 23
roosevelt
  • 1,874
  • 4
  • 20
  • 27
  • 1
    just copy the required DLLs from QT-bin directory to the same directory as the executable. If compiled using mingw also provide the mingw required dlls, see http://stackoverflow.com/questions/17377706/cannot-run-my-exe-file-on-another-computer-application-requested-the-runtime-t/19136598#19136598 – Sebastian Lange Oct 15 '13 at 07:26
  • I have not tested on Windows but on Linux copying the libQtCore.so (and other libraries) to the same directory as the executable still throws an error. Is there anyway within the application I can specify a folder where the application should look for those libraries? Not sure why these features are are not simply easy as specifying a relative folder! – roosevelt Oct 15 '13 at 07:55
  • 1
    I am not sure what you want to achieve. The only things I would have recommended are already covered in the link you provided. maybe you could specify what you dislike about the solutions there. – Ingo Schalk-Schupp Oct 15 '13 at 08:02
  • There is ``void QCoreApplication::addLibraryPath ( const QString & path )``. In Linux the libraries would be placed in the system wide library folder (and headers to the system wide include folder). – Sebastian Lange Oct 15 '13 at 08:02
  • I am going to try the addLibraryPath() method and see if that makes a difference. Basically I am looking for a solution like the /bin/macdeployqt provides. It copies the Qt libraries automatically to a specific folder outside the main executable and everything is automatic. On the above URL I did not like the helper bash script. Looking for a cross platform solution really. – roosevelt Oct 15 '13 at 08:26

1 Answers1

1

What you can do is making a script which copies your DLLs (or .so* files) in the executable folder. Once you make it add an extra Makefile target in your project file :

theproject.pro:

OTHER_FILES += copy.script    # Assuming your copy script is called "copy.script" 
deploylibs.target = deploylibs
deploylibs.command = ./copy.script    # Launching the script

QMAKE_EXTRA_TARGETS += deploylibs

Now you can deploy your libraries by using the (n)make deploylibs command.

NB: there is a very useful tool called "Dependency Walker" to find the DLLs you need. It is only for Windows. As for Linux and its *.so* files you can use the ldd command :

>$: ldd theexecutable
    alib.so => /path/to/library/on/your/computer.so
...
air-dex
  • 4,130
  • 2
  • 25
  • 25