Qt5 + hello World > exit code -1073741515 (0xC0000135)

Completed

Hey

 

I recently decided to start learning C++, since I love pycharm I decided to use cLion for my C adventures as well.

 

I tried today to set up QT system but so far I'm out of luck. I got to the point where it will compile but it will throw an error and I don't know what to do now. In VS it works just fine.

Here are the snippets:

 

EDIT 1: Added simpler test below.

 

Test 1:

CMake:

cmake_minimum_required(VERSION 3.8)
project(testWindowQt)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp mainWindow/mainWindow.cpp mainWindow/mainWindow.h)
add_executable(testWindowQt ${SOURCE_FILES})

if (WIN32)
# If you compile on windows replace path to your Qt folder
set(CMAKE_PREFIX_PATH "C:\\Qt\\5.9\\mingw53_32\\lib\\cmake")
endif()
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Gui REQUIRED)
qt5_use_modules(testWindowQt Core Widgets Gui)

main.cpp

#include <iostream>
#include <QtWidgets/QApplication>
#include "mainWindow/mainWindow.h"

int main(int argc, char *argv[])
{
std::cout << "Hello, World!" << std::endl;
QApplication a(argc, argv);
mainWindow w;
w.show();
return a.exec();
}

 

mainWindow.h

#include <QtWidgets/QMainWindow>

class mainWindow : public QMainWindow{
Q_OBJECT
public:
mainWindow(QWidget *parent = Q_NULLPTR);
};

 

mainWindow.cpp

#include "mainWindow.h"

mainWindow::mainWindow(QWidget *parent)
: QMainWindow(parent){
setWindowTitle("yoyoyo");
}

 

test 2 : 

CMakeList.txt

cmake_minimum_required(VERSION 3.8)
project(testWindotQt)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp )
add_executable(testWindotQt ${SOURCE_FILES})

if (WIN32)
    # If you compile on windows replace path to your Qt folder
    set(CMAKE_PREFIX_PATH "C:\\Qt\\5.9\\mingw53_32")#\\lib\\cmake")
endif()

find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Gui REQUIRED)
qt5_use_modules(testWindotQt Core Widgets Gui)
target_link_libraries(testWindotQt Qt5::Widgets Qt5::Core Qt5::Gui)

main.cpp

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

int main(int argc, char *argv[])
{
    std::cout << "Hello, World!" << std::endl;
    QApplication a(argc, argv);
    QLabel *label = new QLabel("HeyYou");
    label->show();
    return a.exec();
}

The error I get: Process finished with exit code -1073741515 (0xC0000135)

Forgot to add, Windows 10x64 system.

Any help would be amazing, 

Thanks!

 

1
5 comments
Avatar
Permanently deleted user

Have you solved the problem?

0

Yep, just had to make sure my paths/system paths were pointing to right folders of c:/qt/version etc. Restart few times and then everything worked. 

 

Ask up if you need any help.

0
Avatar
Permanently deleted user

@Dariusz Are you able to launch the Qt application from CLion? I have tried to do so and I get an error:

 

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-Gabriel'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.

 

Did you have this issue?

 

Thanks!

0

@Gcastillo, nope sorry. Mine got solved after I restarted pc few times and envi variables kicked in...

0

Just to document: we had a correspondence with @Gcastillo. He uses CLion on Windows, therefore CLion doesn't find any X display. I suggested to use MinGW or MSVC toolchain instead if Cygwin.

0

Please sign in to leave a comment.