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.

4

0 回答 0