c++ - 运行 Qt hello world 时进程退出代码 0xC0000135
问题描述
这是我的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(最新版本)中运行它会给我以下错误:
进程以退出代码 -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文档:set(ENV ...)
该命令只影响当前的 CMake 进程,不影响调用 CMake 的进程,也不影响整个系统环境,也不影响后续构建或测试进程的环境。
因此,这不会在您的 CLion 环境中设置PATH
环境变量。您应该尝试将路径附加C:/Qt/5.14.2/mingw73_64/bin
到Path
Windows 机器上的系统环境变量中的变量。然后,请务必重新启动 CLion,以便Path
应用变量更新。
推荐阅读
- spring - 如何在 Spring IOC 中使用 @Autowired 将值注入 Null 对象?
- apache-nifi - 使用 JavaScript 在 NiFi 中转换时区
- javascript - 引导下拉菜单卡在展开位置,不响应按钮
- javascript - 是否可以在 json 中进行表达式/计算?
- java - 如何在 EJB-JPA tx 中停止自动提交
- reporting-services - SSRS 2016 - 加入收藏
- pandas - 使用 Seaborn 绘制箱线图后如何删除异常值?
- tabulator - 有没有办法像 jQuery 一样通过选择器获取 Tabulator 对象?
- javascript - babel 7 忽略当前目录之外的文件
- .net - Visual Studio 2012 离线安装 nuget