在VSCode的CMake扩展中运行CMake Qt项目时出现的问题 这是我的第一个问题 我用VScCuad做C++,最近我在做一个基于CGEW的QT快速应用程序。 在打开和构建时,VSCodium的CMake扩展工作正常。但当按状态栏中的“Run”时,它会编译,但无法正确运行可执行文件
在终端中,它执行在VSCode的CMake扩展中运行CMake Qt项目时出现的问题 这是我的第一个问题 我用VScCuad做C++,最近我在做一个基于CGEW的QT快速应用程序。 在打开和构建时,VSCodium的CMake扩展工作正常。但当按状态栏中的“Run”时,它会编译,但无法正确运行可执行文件,c++,qt,visual-studio-code,cmake,C++,Qt,Visual Studio Code,Cmake,在终端中,它执行 user@machine:path/to/prj $ myexec 这不是有效的命令。 bash只是回复bash:myexec:command未找到 它应该运行 user@machine:path/to/prj $ ./myexec CMakeLists.txt//由Qt生成 cmake_minimum_required(VERSION 3.14) project(untitled LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR
user@machine:path/to/prj $ myexec
这不是有效的命令。
bash只是回复bash:myexec:command未找到
它应该运行
user@machine:path/to/prj $ ./myexec
CMakeLists.txt//由Qt生成
cmake_minimum_required(VERSION 3.14)
project(untitled LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.
#if(ANDROID)
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
# if (ANDROID_ABI STREQUAL "armeabi-v7a")
# set(ANDROID_EXTRA_LIBS
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
# endif()
#endif()
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
if(ANDROID)
add_library(untitled SHARED
main.cpp
qml.qrc
)
else()
add_executable(untitled
main.cpp
qml.qrc
)
endif()
target_compile_definitions(untitled
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(untitled
PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick)
我在Linux上
[
{
"directory": "/home/abbas/untitled/build",
"command": "/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_QMLMODELS_LIB -DQT_QML_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -I. -I../ -Iuntitled_autogen/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -isystem /usr/include/x86_64-linux-gnu/qt5/QtQuick -isystem /usr/include/x86_64-linux-gnu/qt5/QtQmlModels -isystem /usr/include/x86_64-linux-gnu/qt5/QtQml -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -g -fPIC -std=gnu++17 -o CMakeFiles/untitled.dir/untitled_autogen/mocs_compilation.cpp.o -c /home/abbas/untitled/build/untitled_autogen/mocs_compilation.cpp",
"file": "/home/abbas/untitled/build/untitled_autogen/mocs_compilation.cpp"
},
{
"directory": "/home/abbas/untitled/build",
"command": "/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_QMLMODELS_LIB -DQT_QML_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -I. -I../ -Iuntitled_autogen/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -isystem /usr/include/x86_64-linux-gnu/qt5/QtQuick -isystem /usr/include/x86_64-linux-gnu/qt5/QtQmlModels -isystem /usr/include/x86_64-linux-gnu/qt5/QtQml -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -g -fPIC -std=gnu++17 -o CMakeFiles/untitled.dir/main.cpp.o -c /home/abbas/untitled/main.cpp",
"file": "/home/abbas/untitled/main.cpp"
},
{
"directory": "/home/abbas/untitled/build",
"command": "/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_QMLMODELS_LIB -DQT_QML_DEBUG -DQT_QML_LIB -DQT_QUICK_LIB -I. -I../ -Iuntitled_autogen/include -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -isystem /usr/include/x86_64-linux-gnu/qt5/QtQuick -isystem /usr/include/x86_64-linux-gnu/qt5/QtQmlModels -isystem /usr/include/x86_64-linux-gnu/qt5/QtQml -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -g -fPIC -std=gnu++17 -o CMakeFiles/untitled.dir/untitled_autogen/EWIEGA46WW/qrc_qml.cpp.o -c /home/abbas/untitled/build/untitled_autogen/EWIEGA46WW/qrc_qml.cpp",
"file": "/home/abbas/untitled/build/untitled_autogen/EWIEGA46WW/qrc_qml.cpp"
}
]