Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

c++ - QT example executables won't run, missing QT5Cored.dll

QT5Cored.dll is on my system @: C:Qt5.4mingw491_32in folder

The Analogclock example and other projects will run in the IDE, but can Not be run from the created .exe files. When the EXE is launched the QT5Cored.dll missing error occurs. QT installed it & doesn’t know where it is? Removed & reinstalled QT with same results. enter image description here

Downloaded earler today. Version: 3.3.1, QT 5.4.1(MSCV 2010, 32 Bit), Built on Feb 20, 2015.

Any suggestions appreciated.

New error after DLL filles added to exe directory. enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To run it outside of Qt Creator, you have two choices:

  1. Copy the missing DLLs to the directory where the executable resides. For example if analogclock.exe is in c:examples, then copy C:Qt5.4mingw491_32inQt5Cored.dll and other required DLLs to c:examples. You may need to copy plugins files too.
  2. Add C:Qt5.4mingw491_32in to the PATH environment variable.

There are some ways to copy the missing DLLs:

1. Use Windows Deployment Tool (windeployqt.exe) to copy required files

  1. Open Command Prompt in one of the following way:
    1. If you use MSVC as compiler, open the correct Visual Studio Command Prompt. For example for VS2013 32-bit, click Start -> Microsoft Visual Studio 2013 -> Visual Studio Tools -> VS2013 x86 Native Tools Command Prompt. This will open a Command Prompt with the VCINSTALLDIR environment variable correctly set. windeployqt.exe requires this environment variable to copy the correct Visual C++ redistributable executable.
    2. If you use MinGW, just open a Command Prompt.
  2. Add Qt binary path and optionally g++.exe path to PATH environment variable. If your executable is 32-bit, add the 32-bit Qt binary path, eg: c:Qt5.4msvc2013in. If your executable is 64-bit, add the 64-bit Qt binary path, eg: c:Qt5.4msvc2013_64in. windeployqt.exe will copy DLLs from this directory, so it is important that you don't set 32-bit Qt binary path for a 64-bit executable, vice versa. You need to add g++.exe path too if you use MinGW, windeployqt will copy lib*.dll from there.

    ; Example path for MSVC 32-bit
    PATH=c:Qt5.4msvc2013in;%PATH%
    
    ; Example path for MinGW 32-bit, g++.exe is in C:QtToolsmingw491_32in
    PATH=C:Qt5.4mingw491_32in;C:QtToolsmingw491_32in;%PATH%  
    
  3. Run windeployqt.exe with your executable file as argument. Eg:

    windeployqt.exe C:QtExamplesQt-5.4widgets
    ichtextuild-calendar-Desktop_Qt_5_4_0_MSVC2013_32bit-Debugdebugcalendar.exe
    
  4. Check the output for error or warning. The following is an output without error and warning:

enter image description here

2. Manually copy the DLLs

You must copy the correct DLLs (32-bit or 64-bit). Use a tool like Process Explorer to find the correct DLL paths:

  1. Run the application from Qt Creator / Visual Studio.
  2. Open Process Explorer.
  3. In Process Explorer
    1. Click the executable, for example calendar.exe
    2. Press Ctrl+D to show loaded DLLs in the lower panel. The equivalent menu is View -> Lower Panel View -> DLLs
    3. In the lower panel, click the Path column to sort by path.
  4. Copy the DLLs to the directory where the executable resides. For example in the following picture. The DLLs are from C:Qt5.4msvc2013in.

Process Explorer

  1. If your executable uses something like c:Qt5.4msvc2013pluginsplatformsqwindowsd.dll. It should be copied too. But copy from the platforms directory, not plugins. Let's say calendar.exe's full path is c:examplescalendar.exe, then qwindowsd.dll should be copied to c:examplesplatformsqwindows.dll, not c:examplespluginsplatformsqwindows.dll.
  2. You need to copy C++ runtime library too. If you are using mingw, you may need to copy libgcc_s_dw2-1.dll, libstdc++-6.dll. libwinpthread-1.dll etc too. Check in Process Explorer to be sure. If you are using MSVC, you need to deploy the runtime (Eg: msvcp120.dll, msvcr120.dll). At the end, your directory structure is something like this:

    c:examplescalendar.exe
    c:examplesQt5Cored.dll
    c:examplesQt5Widgetsd.dll
    c:examplesQt5Guid.dll
    c:examplesicudt53.dll
    c:examplesicuin53.dll
    c:examplesicuuc53.dll
    c:exampleslibgcc_s_dw2-1.dll   (if using mingw)
    c:exampleslibstdc++-6.dll      (if using mingw)
    c:exampleslibwinpthread-1.dll  (if using mingw)
    c:examplesplatformsqwindowsd.dll
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...