Following the instructions from this link on configuring c++ with vscode, I set up my tasks.json file to compile multiple files in one directory. However, I always get this error:
/usr/bin/ld: /tmp/ccXey2PG.o: in function `main':
bigone.cpp:(.text+0x9): undefined reference to `swag()'
collect2: error: ld returned 1 exit status
From what I understand, this error basically means that my function definition file swag.cpp isn't getting included in compilation. I've tried the solutiosn from this post, but nothing seems to work.
Also, if I just compile and run the files directly in the terminal through g++ swag.cpp bigone.cpp and ./a.out, everything works fine and dandy.
Any suggestions? I should probably just be using make files, but the fact that I can't figure this out is getting my knickers in a knot. Thanks for the help, as always.
Here's my code:
bigone.cpp:
#include <iostream>
#include "swag.h"
int main()
{
    swag();
    return 0;
}
swag.h:
#pragma once
void swag();
swag.cpp:
#include <iostream>
void swag()
{
    std::cout << "swag" << "\n";
}
And here's my tasks.json file:
{
    "version": "2.0.0",
    "tasks": [
      {
        "type": "shell",
        "label": "g++ build active file",
        "command": "/usr/bin/g++",
        "args": ["-g", "${fileDirname}/*.cpp", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
        "options": {
          "cwd": "/usr/bin"
        },
        "problemMatcher": ["$gcc"],
        "group": {
          "kind": "build",
          "isDefault": true
        }
      }
    ]
  }