1

I have a cpp project with multiple classes and headers. I was trying to make it compile and run using tasks and lunch.json but I gave up. I realized that a while ago I had a problem with Python interperter and went to code-runner configuration to change the default interperter when working with Python. But there has to be a way to make code-runner work even in cpp when having multiple classes and header. This is what I found in the configuration:

"code-runner.executorMap": {
    "cpp": "cd $dir && g++ -std=c++14 $fileName  -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},

I see that only one file gets compiled. What should I add to the code above to make vscode compile all classes?

Payam30
  • 560
  • 1
  • 4
  • 17
  • for multiple files you probably better have make or CMakeLists.txt with cmake-tools ext for vscode – vsh Dec 25 '19 at 01:49
  • Does it mean alot of tweeking? – Payam30 Dec 25 '19 at 19:10
  • Depends on the side of a project, but in case of increasing the amount of files someday you will need to find build system for your project – vsh Dec 26 '19 at 08:28

1 Answers1

7

I change that line to

"code-runner.executorMap": {
    "cpp": "cd $dir && g++ -std=c++14 *.cpp  -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},

Now it works like a charm.

Payam30
  • 560
  • 1
  • 4
  • 17