I've installed Microsoft VSCode under Linux Mint, and opened a folder named test1 containing 3 files:
test.cpp - pre-declares foo() and bar(), then calls both functions in main()
foo.cpp - defines function foo()
bar.cpp - defines function bar()
When I compile test.cpp (using F5 Start debugging in VSCode) it fails with undefined reference to foo() and undefined reference to bar(). When I compile foo.cpp and bar.cpp, they both fail with undefined reference to main.
I found VS Code will not build c++ programs with multiple .ccp source files as asked here previously, from which I discover I can type the following in the VSCode "Terminal" window...
g++ test.cpp foo.cpp bar.cpp -o a.out
./a.out
...and my program compiles and runs as expected (but I can't do any debugging, obviously).
So what I want to know in the first instance is How do I tell VSCode to compile and link in those two additional source files?
Unless it's going to be blindingly difficult, I'd also like some guidance on how to go about moving on to Phase 2 of my task - compiling foo and bar into a "library" file that I can link across to when working on a project in folder test2 (sibling to test1).
If at all possible, I'd like to achieve this entirely within the context of the VSCode environment (maybe I'll think about learning the complexities of g++ and makefiles sometime in the future).