2

Is there a way to compile a C program that includes math.h using the vscode code-runner extension? I know that the program can be compiled by appending -lm option at the end of the gcc command if I compile it in the terminal. The thing is I do not want to compile the program from the terminal.

As a workaround, I tried to change "code-runner.executorMapByFileExtension" as follows.

"code-runner.executorMapByFileExtension" : {
   ".c": "cd $dir && gcc $fileName -o $fileNameWithoutExt -lm && $dir$fileNameWithoutExt"
}

Note -lm option appended. But I could not get it done because the command to compile the program is not overwritten?

Any ideas to solve this problem are appreciated.

Edit: Forgot to say that I am on linux.

Sari
  • 21
  • 1
  • 4

1 Answers1

0

I haven't been able to figure out a way to load the math.h file in Visual Studio Code, either. It seems that there is no choice but to build from the terminal so that you can pass the -lm switch.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574