2

I have a very simple Qt application consisting of main.cpp, mainwindow.cpp, mainwindow.h and mainwindow.ui. The contents of each are shown below:

main.cpp

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char* argv[]) {
  QApplication a(argc, argv);
  MainWindow w;
  w.show();

  return a.exec();
}

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);
}

MainWindow::~MainWindow() {
    delete ui;
}

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT

  public:
    explicit MainWindow(QWidget* parent = 0);
    ~MainWindow();

  private:
    Ui::MainWindow* ui;
};

#endif // MAINWINDOW_H

mainwindow.ui

<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow" >
  <property name="geometry" >
   <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
   </rect>
  </property>
  <property name="windowTitle" >
   <string>MainWindow</string>
  </property>
  <widget class="QMenuBar" name="menuBar" />
  <widget class="QToolBar" name="mainToolBar" />
  <widget class="QWidget" name="centralWidget" />
  <widget class="QStatusBar" name="statusBar" />
 </widget>
 <layoutDefault spacing="6" margin="11" />
 <pixmapfunction></pixmapfunction>
 <resources/>
 <connections/>
</ui>

I'm using CMake to generate a Visual Studio 14 32-bits application and my CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 2.8.11)

project(QCameraWidget)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt5Widgets REQUIRED)

include_directories(${Qt5Widgets_INCLUDES})

add_definitions(${Qt5Widgets_DEFINITIONS})

set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

set(SOURCES
main.cpp
mainwindow.cpp
)

set(HEADERS
mainwindow.h
)

set(UIS
mainwindow.ui
)

add_executable(main ${SOURCES} ${HEADERS} ${UIS})
target_link_libraries(main ${Qt5Widgets_LIBRARIES})

IF(WIN32) # Check if we are on Windows
  if(MSVC) # Check if we are using the Visual Studio compiler
    set_target_properties(main PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
  elseif(CMAKE_COMPILER_IS_GNUCXX)
    # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows") # Not tested
  else()
    message(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)")
  endif()
elseif(UNIX)
  # Nothing special required
else()
  message(SEND_ERROR "You are on an unsupported platform! (Not Win32 or Unix)")
ENDIF()

The generated Visual Studio 14 project compiles fine, but when I try to run main.exe the first thing that happens is that it complains about Qt5Widgetsd.dll missing. When I copy that from the Qt directory and try to run main.exe again, it complains about not finding vcruntime140d_app.dll. Now, I have vcruntime140d.dll in my Visual Studio installation, but I don't have vcruntime140d_app.dll anywhere on my system and after googling around I can't seem to find much about it either.

Does anyone know where this vcruntime140d_app.dll comes from, why Qt5widgetsd.dll depends on it and how I could resolve this issue?

Thanks in advance!

rindis
  • 869
  • 11
  • 25

0 Answers0