VS Code will not build c++ programs with multiple .ccp source files

前端 未结 7 1919
后悔当初
后悔当初 2020-11-29 07:58

Note that I\'m using VS Code on Ubuntu 17.10 and using the GCC Compiler.

I\'m having trouble building a simple program which makes use of additional .ccp files. I\'m

7条回答
  •  自闭症患者
    2020-11-29 08:21

    For Mac you can use

    {
        "version": "2.0.0",
        "tasks": [
            {
                "type": "shell",
                "label": "shell: g++ build active file",
                "command": "/usr/bin/g++",
                "args": [
                    "-g",
                    "-Wall",
                    "-Wextra",
                    "-Wpedantic",
                    "${workspaceFolder}/*/*.cpp",
                    "${fileDirname}/*.cpp",
                    "-o",
                    "${fileDirname}/${fileBasenameNoExtension}"
                ],
                "options": {
                    "cwd": "/usr/bin"
                },
                "problemMatcher": [
                    "$gcc"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
    

    This will compile all the cpp file with all the directories which contain .cpp files.

提交回复
热议问题