马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
vscode-QT环境设置
参考链接:
一、 配景
- 已经安装了QT软件,电脑里有了QT Creater 12.0。
- 使用QT天生并运行了一个project
- 在这个project的根本上,直接设置vscode的环境
二、环境设置
- 确认QT工程乐成运行
- 确认QT的运行设置
- 这个看起来是构建的设置
- 运行路径看起来没什么特殊的,就是实行exe文件
- 用构建下令运行一下
- 点击详情,确认一下工具的所在
如果须要的话,后续这个工具应该设置到环境变量内里。方便一点
- qmake运行pro文件
- qmake.exe …/LogTool.pro
大概是一些须要的环境设置吧,不太懂makefile
- 实行的时间把全部参数都去了,等有标题再返来研究参数吧
- 后半段有个make的运行,再试试:make qmake_all
- 用了原下令也报类似的标题。暂时忽略,直接进入第二步,恰恰也是make
- D:\Software\Qt6\Tools\mingw1120_64\bin\mingw32-make.exe -j4 in ./debug
- 模拟原下令写的,报错了
- in应该是个伪代码,重新实验一下先辈入下令,然后运行make
- 确认效果
debug目次多了一些东西
看起来标题不大,但是无法运行。。。。
- 应用无法在电脑上运行
QT环境设置的时间就踩过这个坑
之前的结论是,release的下令好使
- 使用release的下令 + mingw32-make编译到debug目次
重新天生了一下,debug目次照旧无法运行
- 用release的下令 + make试一下
可以确认应用无法运行的标题办理了
- 回首一下QT的编辑log
按照这个设置输下令,在debug目次天生了exe,直接实行也会提示版本不对,无法实行。换成之前设置过的mingw包内里的make就行了
D:\Software\Qt6\6.6.3\mingw_64\bin\qmake.exe ../LogTool.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
make -j7 release
以下是版本参考
- 设置环境变量,办理库的标题
须要将Qt的mingw放到原有的mingw上,否则会提示引用的库找不到入口点
但是如许设置的话,运行exe着实照旧依赖环境变量。不是最优解法……
- 添加依赖库
D:\BasicSetting\Qt_mingw64\bin\windeployqt.exe LogTool.exe
- 确认编译步调
- D:\Software\Qt6\6.6.3\mingw_64\bin\qmake.exe ../LogTool.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
- make -j7
- windeployqt LogTool.exe
- 安装Vscode的相干插件
- 设置ui文件
- 设置launch.json
上面装组件的方式,没有乐成运行Designer,于是放弃
launch的方式设置。每次打开ui文件,实行用Designer.exe打开ui文件的下令,到达类似的效果- {
- "version": "0.2.0",
- "configurations": [
- {
- "name": "ui Set",
- "type": "cppdbg",
- "request": "launch",
- "program": "D:\\BasicSetting\\Qt_mingw64\\bin\\designer.exe",
- "cwd": "${workspaceFolder}",
- "stopAtEntry": false,
- "externalConsole": false,
- "args": [
- "${file}"
- ],
- "setupCommands": [
- {
- "description": "Enable pretty-printing for gdb",
- "text": "-enable-pretty-printing",
- "ignoreFailures": true
- }
- ]
- }
- ]
- }
复制代码
- Qt编译环境设置
- 设置launch.json
- {
- "version": "0.2.0",
- "configurations": [
- {
- "name": "QtBuild",
- "type": "cppdbg",
- "request": "launch",
- "program": "${fileDirname}/Out/release/${relativeFileDirname}.exe",
- "args": [],
- "stopAtEntry": false,
- "cwd": "${fileDirname}",
- "environment": [],
- "externalConsole": false,
- "MIMode": "gdb",
- "preLaunchTask": "QtBuild",
- "setupCommands": [
- {
- "description": "Enable pretty-printing for gdb",
- "text": "-enable-pretty-printing",
- "ignoreFailures": true
- },
- {
- "description": "Set Disassembly Flavor to Intel",
- "text": "-gdb-set disassembly-flavor intel",
- "ignoreFailures": true
- }
- ]
- },
- {
- "name": "ui Set",
- "type": "cppdbg",
- "request": "launch",
- "program": "D:\\BasicSetting\\Qt_mingw64\\bin\\designer.exe",
- "cwd": "${workspaceFolder}",
- "stopAtEntry": false,
- "externalConsole": false,
- "args": [
- "${file}"
- ],
- "setupCommands": [
- {
- "description": "Enable pretty-printing for gdb",
- "text": "-enable-pretty-printing",
- "ignoreFailures": true
- }
- ]
- }
- ]
- }
复制代码 - 设置tasks.json
- {
- "version": "2.0.0",
- "tasks": [
- {
- "label": "createOut",
- "type": "shell",
- "group": {
- "kind":"build",
- "isDefault": true
- },
- "command": "PowerShell",
- "args": [
- "if (-not (Test-Path "Out")) { New-Item -ItemType Directory -Path "Out" }" //Power shell的命令,找out目录,如果没有就创建文件
- ],
- "options": {
- "cwd": "${fileDirname}",
- }
- },
- {
- "label": "ProBuild", //在out目录下,编译pro文件
- "type": "shell",
- "command": "D:\\BasicSetting\\Qt_mingw64\\bin\\qmake.exe",
- // "command": "ls",
- "problemMatcher": [],
- "args": [
- "${fileDirname}\\${relativeFileDirname}.pro"
- ],
- "options": {
- "cwd": "${fileDirname}\\Out\",
- "shell": {
- "executable": "PowerShell"
- }
- },
- "dependsOn":[
- ],
- },
- {
- "label": "makeFile", //在out目录下,将makefile生成为exe
- "command": "D:\\BasicSetting\\mingw64\\bin\\make.exe",
- // "command": "ls",
- "args": [
- "-j8",
- "release"
- ],
- "options": {
- "cwd": "${fileDirname}\\Out\"
- },
- "dependsOn":[
- ],
- },
- {
- "label": "deployDll", //将exe需要的部署到此目录
- "command": "D:\\BasicSetting\\Qt_mingw64\\bin\\windeployqt.exe",
- // "command": "ls",
- "args": [
- "${relativeFileDirname}.exe"
- ],
- "options": {
- "cwd": "${fileDirname}\\Out\\release",
- "shell": {
- "executable": "PowerShell"
- }
- },
- "dependsOn":[
- ],
- },
- {
- "label": "QtBuild", //launch的QtBuild的前置程序
- "dependsOrder": "sequence", //依赖task的运行顺序是顺序执行的(另外一个选项是并行)
- "dependsOn":[
- "createOut", //创建out目录
- "ProBuild", //编译Pro文件
- "makeFile", //make命令
- "deployDll" //部署依赖的库
- ],
- }
- ]
- }
复制代码
|