Can't manage to link compiler to files from other folders

Viewed 19

I'm working in VSCode with C++. I want to use and compile files from different folders, I made an example of what I want to do https://github.com/ChrisvdHoorn/Cplusplus_project (renamed .vscode to vscode so that I could upload to github, is actually called .vscode (!))

Cplusplus_project
└───.vscode
│   │ c_cpp_properties.json
│   │ launch.json
│   │ settings.json
|   | tasks.json  
│   
└───include
|   │ TestLib.h
|
└───src
    | main.cpp
    | TestLib.cpp

main.cpp uses TestLib.h and Testlib.cpp. This compiles fine when main.cpp, TestLib.h and Testlib.cpp are placed directly in the worspace, but not in the file structure above.

I came across similar questions on the internet, and the general answer was that you need to add something like "-I${workspaceFolder}/include", the the args section of the compiler. I tried this, but no luck.

Any help is very welcome :)

Sub question: I use the playbutton to compile and run the code. Is this actually running the task from tasks.json? I couldn't really find a definitive answer on it online.

0 Answers
Related