QtCreator + CMake on Windows: App crushes with "The CDB process terminated" error
-
I have a simple HelloWorld application with shared library. A library contains class Greeter which provides "Hello, World!" string. Main window takes this string from the library and places it in QLabel. Everything works fine until I place all library code in subdirectory and use "add_subdirectory" in cmake to put the library in my project. Then my app crushes without even entering main() function with "The CDB process terminated" error. Here is the code:
# CMakeLists.txt: cmake_minimum_required(VERSION 3.1.0) project(HelloWorld) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5Widgets CONFIG REQUIRED) add_subdirectory(Greeter ${CMAKE_BINARY_DIR}/Greeter/) add_executable(HelloWorld WIN32 main.cpp mainwindow.h mainwindow.cpp mainwindow.ui) target_link_libraries(HelloWorld Qt5::Widgets Greeter) add_dependencies(HelloWorld Greeter)# Greeter/CMakeLists.txt: cmake_minimum_required(VERSION 3.1.0) project(Greeter) add_library(Greeter SHARED Greeter.h Greeter.cpp) target_link_libraries(Greeter Qt5::Core)C++ code is trivial. Maybe Greeter.h is worth reciting:
#include <QString> struct __declspec(dllexport) Greeter { explicit Greeter() = default; QString Greet(); };I use MSVC compiler and debugger. I tried to update Visual Studio, delete build folder, delete .user file, and I still can't make it work.