c++ - 运行 Qt hello world 时进程退出代码 0xC0000135

标签 c++ qt cmake qt5 clion

这是我的main.cpp代码:

#include <iostream>
#include <QtWidgets/QApplication>
#include <QtWidgets/QPushButton>

using namespace std;

int main(int argc, char *argv[]) {
    QApplication application(argc, argv);
    QPushButton button("Hello, world!");
    button.show();
    return application.exec();
}

在 CLion IDE(最新版本)中运行它会出现以下错误:

Process finished with exit code -1073741515 (0xC0000135)

这是我的CMakeLists.txt:

cmake_minimum_required(VERSION 3.13)
project(simple_interpreter)

set(CMAKE_CXX_STANDARD 14)

if (WIN32)
    set(CMAKE_EXE_LINKER_FLAGS "-static")
endif ()
set(ENV{PATH} "C:/Qt/5.14.2/mingw73_64/bin") # As suggested in https://stackoverflow.com/questions/44739411
set(Qt5_DIR "C:/Qt/5.14.2/mingw73_64/lib/cmake/Qt5")
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui)

add_executable(simple_interpreter main.cpp)

target_link_libraries(simple_interpreter Qt5::Core Qt5::Widgets Qt5::Gui)

最佳答案

来自 CMake documentation对于设置(ENV ...):

This command affects only the current CMake process, not the process from which CMake was called, nor the system environment at large, nor the environment of subsequent build or test processes.

因此,这不会在 CLion 环境中设置 PATH 环境变量。您应该尝试将路径 C:/Qt/5.14.2/mingw73_64/bin 附加到 Windows 计算机上系统环境变量中的 Path 变量。然后,请务必重新启动 CLion,以便应用 Path 变量更新。

关于c++ - 运行 Qt hello world 时进程退出代码 0xC0000135,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61955286/

相关文章:

macos - cmake 尝试链接资源文件

c++ - 如果 _heapchk() 返回 "okay",我可以假设堆没有损坏吗?

c++ - 处理重叠图形项的 mousePressEvent

c++ - Cin 没有操作数 >>

c++ - 从 QT lineEdit 获取 unicode 并将其写入文件

c++ - 如何在 Windows 上切换到另一个应用程序(使用 C++、Qt)?

cmake - 为什么 CMake "option"不刷新 CMakeCache 上的值?

c++ - 将 header 添加到 CMake 中的库

c++ 字符串到 boost::multiprecision::cpp_int

c++ - A*寻路慢