[good]vscode中qt环境配置包括qt和cmake安装

具体参考这篇帖子VsCode+QT5.14.2安装部署详细教程_vscode配置qt-CSDN博客

 

以下是自己按照这贴的安装步骤及细节,qt和cmake的具体安装过程见文末,后面有问题再修改,但基本上问题不大

安装完qt之后需要配置三个环境变量,和关于cmake的环境变量,注意是系统变量中的Path变量

我的安装目录是D:\Qt5.14.2\,但其实安装的时候可以指定为D:\Qt即可,因为里面还有个5.14.2的目录,这样会导致路径有点长

 

然后打开powershell,本来路径显示的是strawberry,是因为环境变量里面有那几个变量,删了之后就变成如下图了,因为我已经安装了msys64,但这个不打紧,后面可以修改

 接下来是安装vscode插件,也见文末

之后是cmake tool的配置

 以及QT configure的配置

 

 

 

 新建一个空目录,用vscode打开

 

 

 

 

 

则在左侧会多出一些文件

 

 

 ctrl+shift+p输入cmake之后,选择cmake configure则会自动扫描

 

扫描完成之后会跳出下面的下拉框

 

 

具体是这样的,但是好像不修改也没事,后面也能够编译和运行,估计和cmake configure的时候选择编译器有关

[
  {
    "name": "GCC 13.2.0 x86_64-w64-mingw32 (ucrt64)",
    "compilers": {
      "C": "d:\\msys64\\ucrt64\\bin\\gcc.exe",
      "CXX": "d:\\msys64\\ucrt64\\bin\\g++.exe"
    },
    "isTrusted": true,
    "environmentVariables": {
      "CMT_MINGW_PATH": "d:\\msys64\\ucrt64\\bin"
    },
    "preferredGenerator": {
      "name": "MinGW Makefiles"
    }
  },
  {
    "name": "Visual Studio Professional 2022 Release - amd64",
    "visualStudio": "92d78322",
    "visualStudioArchitecture": "x64",
    "isTrusted": true,
    "preferredGenerator": {
      "name": "Visual Studio 17 2022",
      "platform": "x64",
      "toolset": "host=x64"
    }
  },
  {
    "name": "Visual Studio Professional 2022 Release - amd64_x86",
    "visualStudio": "92d78322",
    "visualStudioArchitecture": "x64",
    "isTrusted": true,
    "preferredGenerator": {
      "name": "Visual Studio 17 2022",
      "platform": "win32",
      "toolset": "host=x64"
    }
  },
  {
    "name": "Visual Studio Professional 2022 Release - x86",
    "visualStudio": "92d78322",
    "visualStudioArchitecture": "x86",
    "isTrusted": true,
    "preferredGenerator": {
      "name": "Visual Studio 17 2022",
      "platform": "win32",
      "toolset": "host=x86"
    }
  },
  {
    "name": "Visual Studio Professional 2022 Release - x86_amd64",
    "visualStudio": "92d78322",
    "visualStudioArchitecture": "x86",
    "isTrusted": true,
    "preferredGenerator": {
      "name": "Visual Studio 17 2022",
      "platform": "x64",
      "toolset": "host=x86"
    }
  }
]

 

这个时候会发现qt的编译器路径不在这个文件内,然后cmake scan一下试试

 直接按那个build

 

 也没什么问题,唯一的问题是框跳不出来

这个时候把build目录下的hello.exe拖到D:\Qt5.14.2\5.14.2\mingw73_64\bin\下的windeployqt.exe文件上,则build目录下则会多出一些dll文件

因为已经编译过了,所以现在是按那个三角形运行

 

 

 

 

 

1/qt

Index of /archive/qt

 

 

 

 

 

 

 

 

 

 

 

 

2、cmake

Download CMake

 安装比较简单

 记得选择add path,这样就不用手动添加环境变量了

 

 

 

 

3、vscode插件

c/c++

 

cmake

 

cmake tools

 

qt configure

 

qt tools

 

posted on 2023-12-11 15:07  风中狂笑  阅读(620)  评论(0编辑  收藏  举报

导航