【问题标题】:Process exit code 0xC0000135 while running Qt hello world运行 Qt hello world 时进程退出代码 0xC0000135
【发布时间】:2020-05-22 12:40:21
【问题描述】:

这是我的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)

【问题讨论】:

  • set(ENV{PATH} "C:/Qt/5.14.2/mingw73_64/bin") 我不确定这是否有效。您可能只想尝试在 Windows 中设置 PATH 环境变量并重新启动或注销/登录。它可能只是为配置/生成阶段设置环境变量,但不会为作为父进程的 IDE 更改它。
  • 执行“执行”而不是“表演”
  • 谢谢!直接从操作系统而不是 CMakeLists.txt 将其添加到 PATH,然后关闭并重新打开 IDE 修复它。

标签: c++ qt cmake qt5 clion


【解决方案1】:

来自 CMake documentationset(ENV ...)

此命令只影响当前的 CMake 进程,不影响调用 CMake 的进程,也不影响整个系统环境,也不影响后续构建或测试进程的环境。

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

【讨论】:

    猜你喜欢
    • 2021-04-04
    • 2016-02-08
    • 2017-10-07
    • 2020-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多