Home > Back-end >  CLion configuration Qt CreateProcess error=193, % 1 is not a valid Win32 application.
CLion configuration Qt CreateProcess error=193, % 1 is not a valid Win32 application.

Time:09-21

# cmake_minimum_required (VERSION & lt; Specify CMake version here>)
Project (StudentManager)

Set (CMAKE_CXX_STANDARD 17)
Set (CMAKE_INCLUDE_CURRENT_DIR ON) # include the build directory where the qt generated header exists

# set Qt5 cmake module directory, if you don't set will use the system to provide the version
# QT_DIR and QT_VERSION is to specify the qt installation directory and version of the environment variable
Cmake # if you use the system, so will be preferred to use the system to provide the module, because cmake will first search CMAKE_SYSTEM_PREFIX_PATH
# if you don't want cmake first search system directory (leads to compile using the system to install qt rather than our configuration), need prompt find_package command

Set (CMAKE_PREFIX_PATH D:/Qt/Tools/mingw730_64)

# to find corresponding qt module, in the name of qmake qt +=& lt; Name> After the name of the first letters capitalized plus prefix Qt5
# the core for the QtCore, for example, you can also go to ${CMAKE_PREFIX_PATH} directory to find the right module name
# if you don't want to use the system qt, writes (note NO_DEFAULT_PATH parameters, it can let find_package skip system directory lookup) :
# tell cmake where your qt5 library lies
Set (Qt5_DIR D:/Qt/5.14.2/mingw73_64/lib/cmake/Qt5)
Find_package (Qt5 REQUIRED COMPONENTS Widgets Core Gui)

# if you want to use the system's own qt, write like this:
# find_package (Qt5Widgets REQUIRED)

Cmake_minimum_required (VERSION 3.16)

Set (project_ui_files MainWindow. UI)
Set (project_src_files Main. CPP MainWindow. CPP)
Set (project_header_files MainWindow. H)

Set (CMAKE_AUTOMOC ON)
SET (CMAKE_AUTOUIC ON)
Set (CMAKE_AUTORCC ON)

# the UI files are converted to the header files at build time like XML in WPF
Qt5_wrap_ui (project_headers_wrapped ${project_ui_files})
# because the header files are the where Q_Object is defined
Qt5_wrap_cpp (project_src_moc ${project_header_files})

Add_executable (${PROJECT_NAME} # UI files are not necessary here
The ${project_src_files}
The ${project_header_files}
The ${project_headers_wrapped}
The ${project_src_moc}
)


Target_link_libraries (${PROJECT_NAME} # PROJECT_NAME is case - sensitive
PUBLIC
Qt5: : Widgets
Qt5: : Core
Qt5: : Gui
)

CodePudding user response:

Online tutorial as a several times, don't know where the problem is, seems to be the tool didn't didn't know that, as a result of not using the right way to compile, know not QT repository Win32 function

And I don't feel solves this problem should be finished
  • Related