antonypro / QGoodWindow

QGoodWindow - border less window for Qt 5 and Qt 6
MIT License
506 stars 87 forks source link

Process finished with exit code -1073741515 (0xC0000135) #45

Closed ameasere closed 11 months ago

ameasere commented 1 year ago

Hi,

I am probably just making a rookie mistake, but I am having an issue with getting QGoodWindow's basic example in the docs to run in CLion on Windows 11 with CMake 3.27.

Using:

I compiled QGoodWindow both into static and shared library on Windows 11, and moved the QGoodWindow parent folder containing the /include and /lib folders to the same directory as my .cpp and CMakeLists.txt file.

Here is my current CMakeLists.txt:

cmake_minimum_required(VERSION 3.25)
project(HSMC)

set(CMAKE_PREFIX_PATH C:\\Qt\\6.5.2\\mingw_64\\lib\\cmake)

find_package(Qt6 COMPONENTS Core Widgets Gui Network REQUIRED)

# Include ./QGoodWindow/include
include_directories(${CMAKE_SOURCE_DIR}/QGoodWindow/include)

# Add the QGoodWindow library
add_library(QGoodWindow STATIC IMPORTED)  # Specify as STATIC library
set_target_properties(QGoodWindow PROPERTIES
        IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/QGoodWindow/lib/libQGoodWindow.a"  # Adjust the library name accordingly
        INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/QGoodWindow/include"
)

# lib containing .a and .dll
link_directories(${CMAKE_SOURCE_DIR}/QGoodWindow/lib)

set(CMAKE_CXX_STANDARD 17)

set(SOURCES
        main.cpp
        ../UI/resources.qrc
        ../headers/resources.h
)

add_executable(HSMC WIN32 ${SOURCES} HSMC.rc)

target_link_libraries(HSMC PRIVATE
        Qt6::Core
        Qt6::Widgets
        Qt6::Gui
        Qt6::Network
        QGoodWindow
)

qt6_add_resources(QRC_RESOURCES ../UI/resources.qrc)

This loads perfectly fine, no issues. However, as soon as I try to run the EXE built from this, I get:

Process finished with exit code -1073741515 (0xC0000135)

I tried adding the DLL/static library location in PATH as well as the MinGW compiler location to no avail. Please bear in mind that I am not well versed in C++ nor CMake, I am simply wanting to use QGoodWindow for a beginner project (On Windows, potentially a silly idea) but tried my best with CMake configurations and building from source. Asking for guidance please!

Project Structure:

image (The headers directory, UI directory and associated files are all present)

antonypro commented 11 months ago

Hi, @ameasere!

This error code indicates a missing DLL(s), see here: https://stackoverflow.com/q/11432940.

To solve this problem you have a couple of options: Bundle the DLL(s) alongside with your app, or build/get a static compilation of Qt, then building a single standalone EXE.

To bundle the DLLs, the proper option on Windows is use the windeployqt tool.

The static linking option requires that you compile or get a pre-built static version of Qt. Pay attention for the Qt license that you have and your usage of Qt, opensource or commercial, BTW I'm NOT a lawyer.

That's what I'm able to say for now.

Thanks!

ameasere commented 11 months ago

Thank you so much for this @antonypro !!