2

Here is my main.cpp code:

#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();
}

Running it in CLion IDE (latest version) gives me the following error:

Process finished with exit code -1073741515 (0xC0000135)

Here is my 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)
Kevin
  • 16,549
  • 8
  • 60
  • 74
Youssef13
  • 3,836
  • 3
  • 24
  • 41
  • 1
    `set(ENV{PATH} "C:/Qt/5.14.2/mingw73_64/bin")` I am not sure that this works. You may just want to try setting the PATH environment variable in windows and rebooting or logout / login. It may just set the environment variable for the configure / generate stage but not change it for the IDE which is the parent process. – drescherjm May 22 '20 at 12:44
  • do an "Exec" instead of a "show" – ΦXocę 웃 Пepeúpa ツ May 22 '20 at 12:45
  • Thanks! Adding it to the PATH directly from OS instead of CMakeLists.txt, then closing and re-opening the IDE fixed it. – Youssef13 May 22 '20 at 12:54

1 Answers1

2

From the CMake documentation for set(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.

So, this does not set the PATH environment variable within your CLion environment. You should instead try appending the path C:/Qt/5.14.2/mingw73_64/bin to the Path variable in your System Environment Variables on your Windows machine. Then, be sure to restart CLion, so the Path variable update is applied.

Kevin
  • 16,549
  • 8
  • 60
  • 74