在.vscode文件夹下新建c_cpp_properties.json,(可以用在工程目录下直接新建.vscode文件夹,注意vscode前带一个点,再新建一个c_cpp_properties.json文件)
$ mkdir .vscode
$ cd .vscode
$ gedit c_cpp_properties.json
c_cpp_properties.json 代码如下,使用gedit编辑完,Ctrl+s保存,当然你也可以使用vim编辑,不一定用gedit编辑,其中/opt/Qt5.9.9/5.9.9为安装目录,需要更换为你自己的安装目录:
{
"version": 4,
"configurations": [
{
"name": "gcc_64",
"intelliSenseMode": "gcc-x64",
"includePath": [
"/opt/Qt5.9.9/5.9.9/gcc_64/include",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtCore",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtGui",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWidgets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DAnimation",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DCore",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DExtras",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DInput",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DLogic",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuick",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickAnimation",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickExtras",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickInput",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickRender",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickScene2D",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DRender",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtAccessibilitySupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtBluetooth",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtConcurrent",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDBus",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDesigner",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDesignerComponents",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDeviceDiscoverySupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtEglFSDeviceIntegration",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtEglSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtEventDispatcherSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtFbSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtFontDatabaseSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtGamepad",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtGlxSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtHelp",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtInputSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtKmsSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtLinuxAccessibilitySupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtLocation",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtMultimedia",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtMultimediaQuick_p",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtMultimediaWidgets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtNetwork",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtNfc",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtOpenGL",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtOpenGLExtensions",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPacketProtocol",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPlatformCompositorSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPlatformHeaders",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPositioning",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPrintSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQml",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQmlDebug",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuick",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickControls2",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickParticles",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickTemplates2",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickTest",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickWidgets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtScxml",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSensors",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSerialBus",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSerialPort",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtServiceSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSql",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSvg",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtTest",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtThemeSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtUiPlugin",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtUiTools",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWebChannel",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWebSockets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWebView",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtX11Extras",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtXml",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtXmlPatterns",
"${workspaceRoot}"
],
"browse": {
"path": [
"/opt/Qt5.9.9/5.9.9/gcc_64/include",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtCore",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtGui",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWidgets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DAnimation",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DCore",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DExtras",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DInput",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DLogic",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuick",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickAnimation",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickExtras",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickInput",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickRender",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DQuickScene2D",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/Qt3DRender",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtAccessibilitySupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtBluetooth",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtConcurrent",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDBus",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDesigner",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDesignerComponents",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtDeviceDiscoverySupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtEglFSDeviceIntegration",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtEglSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtEventDispatcherSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtFbSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtFontDatabaseSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtGamepad",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtGlxSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtHelp",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtInputSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtKmsSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtLinuxAccessibilitySupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtLocation",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtMultimedia",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtMultimediaQuick_p",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtMultimediaWidgets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtNetwork",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtNfc",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtOpenGL",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtOpenGLExtensions",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPacketProtocol",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPlatformCompositorSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPlatformHeaders",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPositioning",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtPrintSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQml",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQmlDebug",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuick",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickControls2",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickParticles",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickTemplates2",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickTest",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtQuickWidgets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtScxml",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSensors",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSerialBus",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSerialPort",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtServiceSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSql",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtSvg",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtTest",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtThemeSupport",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtUiPlugin",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtUiTools",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWebChannel",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWebSockets",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtWebView",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtX11Extras",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtXml",
"/opt/Qt5.9.9/5.9.9/gcc_64/include/QtXmlPatterns",
"${workspaceRoot}"
]
},
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17"
}
]
}
"includePath"和"path"标定了查找的headers的位置, "compilerPath"标定了分析用的编译器的路径, 这里我使用的gcc编译器, 需要提前安装,当然而已可以去除这几行。
其中这里有个技巧就是你到安装目录下使用命令:ls -al 然后使用列编辑,把目录都填到上面的c_cpp_properties.json文件中。
Ubuntu@Ubuntu-vm:/opt/Qt5.9.9/5.9.9/gcc_64/include$ ls -al
total 356
drwxr-xr-x 73 root root 4096 .
drwxrwxr-x 11 root root 4096 ..
drwxr-xr-x 3 root root 4096 Qt3DAnimation
drwxr-xr-x 3 root root 4096 Qt3DCore
drwxr-xr-x 3 root root 4096 Qt3DExtras
drwxr-xr-x 3 root root 4096 Qt3DInput
drwxr-xr-x 3 root root 4096 Qt3DLogic
drwxr-xr-x 3 root root 4096 Qt3DQuick
drwxr-xr-x 3 root root 4096 Qt3DQuickAnimation
drwxr-xr-x 3 root root 4096 Qt3DQuickExtras
drwxr-xr-x 3 root root 4096 Qt3DQuickInput
drwxr-xr-x 3 root root 4096 Qt3DQuickRender
drwxr-xr-x 3 root root 4096 Qt3DQuickScene2D
drwxr-xr-x 3 root root 12288 Qt3DRender
drwxr-xr-x 3 root root 4096 QtAccessibilitySupport
drwxr-xr-x 3 root root 4096 QtBluetooth
drwxr-xr-x 2 root root 4096 QtConcurrent
drwxr-xr-x 3 root root 20480 QtCore
drwxr-xr-x 3 root root 4096 QtDBus
drwxr-xr-x 3 root root 4096 QtDesigner
drwxr-xr-x 3 root root 4096 QtDesignerComponents
drwxr-xr-x 3 root root 4096 QtDeviceDiscoverySupport
drwxr-xr-x 3 root root 4096 QtEglFSDeviceIntegration
drwxr-xr-x 3 root root 4096 QtEglSupport
drwxr-xr-x 3 root root 4096 QtEventDispatcherSupport
drwxr-xr-x 3 root root 4096 QtFbSupport
drwxr-xr-x 3 root root 4096 QtFontDatabaseSupport
drwxr-xr-x 3 root root 4096 QtGamepad
drwxr-xr-x 3 root root 4096 QtGlxSupport
drwxr-xr-x 3 root root 20480 QtGui
drwxr-xr-x 3 root root 4096 QtHelp
drwxr-xr-x 3 root root 4096 QtInputSupport
drwxr-xr-x 3 root root 4096 QtKmsSupport
drwxr-xr-x 3 root root 4096 QtLinuxAccessibilitySupport
drwxr-xr-x 3 root root 4096 QtLocation
drwxr-xr-x 3 root root 12288 QtMultimedia
drwxr-xr-x 3 root root 4096 QtMultimediaQuick_p
drwxr-xr-x 3 root root 4096 QtMultimediaWidgets
drwxr-xr-x 3 root root 4096 QtNetwork
drwxr-xr-x 3 root root 4096 QtNfc
drwxr-xr-x 3 root root 4096 QtOpenGL
drwxr-xr-x 2 root root 4096 QtOpenGLExtensions
drwxr-xr-x 3 root root 4096 QtPacketProtocol
drwxr-xr-x 3 root root 4096 QtPlatformCompositorSupport
drwxr-xr-x 2 root root 4096 QtPlatformHeaders
drwxr-xr-x 3 root root 4096 QtPositioning
drwxr-xr-x 3 root root 4096 QtPrintSupport
drwxr-xr-x 3 root root 4096 QtQml
drwxr-xr-x 3 root root 4096 QtQmlDebug
drwxr-xr-x 3 root root 4096 QtQuick
drwxr-xr-x 3 root root 4096 QtQuickControls2
drwxr-xr-x 3 root root 4096 QtQuickParticles
drwxr-xr-x 3 root root 4096 QtQuickTemplates2
drwxr-xr-x 3 root root 4096 QtQuickTest
drwxr-xr-x 3 root root 4096 QtQuickWidgets
drwxr-xr-x 3 root root 4096 QtScxml
drwxr-xr-x 3 root root 4096 QtSensors
drwxr-xr-x 3 root root 4096 QtSerialBus
drwxr-xr-x 3 root root 4096 QtSerialPort
drwxr-xr-x 3 root root 4096 QtServiceSupport
drwxr-xr-x 3 root root 4096 QtSql
drwxr-xr-x 3 root root 4096 QtSvg
drwxr-xr-x 3 root root 4096 QtTest
drwxr-xr-x 3 root root 4096 QtThemeSupport
drwxr-xr-x 2 root root 4096 QtUiPlugin
drwxr-xr-x 3 root root 4096 QtUiTools
drwxr-xr-x 3 root root 4096 QtWebChannel
drwxr-xr-x 3 root root 4096 QtWebSockets
drwxr-xr-x 3 root root 4096 QtWebView
drwxr-xr-x 3 root root 20480 QtWidgets
drwxr-xr-x 2 root root 4096 QtX11Extras
drwxr-xr-x 3 root root 4096 QtXml
drwxr-xr-x 3 root root 4096 QtXmlPatterns
感觉不错的话点个赞在走吧,你们的支持是我继续写博客的动力!
参考自以下链接:
https://blog.csdn.net/caoshiying/article/details/78281996