Qt and Visual Studio: Qt5Core.dll not found error


When I move a Visual Studio project from different PCs (using same version of Visual Studio) sometime it happen to get a very strange error running the executable from Visual Studio (with Qt Plugin installed).


The error is the following:

The program can't start because Qt5Core.dll is missing from your computer. Try reinstalling the program to fix this problem.

Now the Qt libraries are on the same path so what is the problem? Currently I didn't find the cause but it seem moving a project between two or more Visual Studio installed in different computers (different OS?) make this kind of problem happen. The "error" come from the .vcxproj.user project file where some properties are in the wrong order. Making an example this is a .vcxproj.user file showing the error:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
    <QTDIR>C:\Qt\5.5\msvc2013</QTDIR>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
    <QTDIR>C:\Qt\5.5\msvc2013</QTDIR>
  </PropertyGroup>
</Project>

The critical line in this file is the Qt library path (C:\Qt\5.5\msvc2013 in this example). Currently the only way I found to fix the problem is to move up the Qt library path manually in the file as follow:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <QTDIR>C:\Qt\5.5\msvc2013</QTDIR>
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    <QTDIR>C:\Qt\5.5\msvc2013</QTDIR>
    <LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH)</LocalDebuggerEnvironment>
  </PropertyGroup>
</Project>

As you can note the red lines changed order and now the executable start correctly (you have to close the project and reopen for make the change load). This is not the best solution and I don't really like it but is the faster fix I found right now. If someone can suggest a better alternative feel free to put on the comment.

Comments

Popular posts from this blog

Access GPIO from Linux user space

Launch an app from Android shell terminal

Qt 5 and " Failed to load platform plugin 'windows' " error