简体   繁体   中英

How to run C++ with QT creator

I'm trying to use cmake to run c++ using QT creator. I downloaded cmake, created a new project, clicked on the project configuration button, clicked on manage kits, click on the cmake tab, and then pressed add and added the path to my cmake.exe C:\\Program Files\\CMake\\bin\\cmake.exe . Afterwards strange things started to happen. It keeps saying configuration failed so I went back to my build settings and under the build directory, it's listing out a path that doesn't exist. Why is that happening? In the compile output, it says

Starting: "C:\Program Files\CMake\bin\cmake.exe" --build . --target all
Error while building/deploying project icg (kit: Desktop Qt 5.9.0 MinGW 32bit)
When executing step "CMake Build"

Here's the contents of my CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)
project(icg)

#--- Load the common ICG configuration
include(common/config.cmake)
include(common/Eigen.cmake)
include(common/OpenGP.cmake)

#--- OpenGL configuration
include(common/OpenGL.cmake)
include(common/GLEW.cmake)
include(common/GLFW.cmake)

#--- Subprojects
add_subdirectory(transform)
add_subdirectory(mouse)

This file is in the root of the directory. The particular project I'm trying to run is called transform which also has a CMakeLists.txt file in the transform directory.

get_filename_component(EXERCISENAME ${CMAKE_CURRENT_LIST_DIR} NAME)
file(GLOB_RECURSE SOURCES "*.cpp")
file(GLOB_RECURSE HEADERS "*.h")
file(GLOB_RECURSE SHADERS "*.glsl")
add_executable(${EXERCISENAME} ${SOURCES} ${HEADERS} ${SHADERS})
target_link_libraries(${EXERCISENAME} ${COMMON_LIBS})
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_LIST_DIR})

Qt Creator doesn't always create the build directory if it doesn't exist when you first define the project. Instead, it silently uses a temporary directory until you actually create the build directory yourself. This is not what developers normally expect and is probably a bug, but that is the behaviour you are currently observing. If you manually create the build directory and re-run CMake, Creator should then be using the correct directories and I'd expect it to build (unless your project has other errors in its CMakeLists.txt files, obviously).

To make the General Messages tab appear if it isn't showing for you at the moment, click the up-down button at the end of the list of output panes at the bottom of the window and enable it in the pop-up that appears:

输出窗格

You can also do this through the Window --> Output Panes menu.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM