microsoft / vscode-makefile-tools

MAKE integration in Visual Studio Code
Other
194 stars 58 forks source link

Where can I set the path to the compiler? #503

Closed huangda1982 closed 12 months ago

huangda1982 commented 1 year ago

Windows 10 My compiler's path is not in the PATH variable. When "Makefile: Build the current target", I got "'ccrx' is not recognized as an internal or external command, operable program or batch file'". "ccrx" is the name of the compiler.

And, how can I comile one .c file with makefile tool?

gcampbell-msft commented 1 year ago

@huangda1982 It sounds like the fix for you would be to add your compilers path to the PATH variable and then close and re-open VS Code.

As for compiling a single file with the makefile tool, the most useful resource is likely any documentation on make.exe that is online. A good starting point might be here: https://www.gnu.org/software/make/

huangda1982 commented 1 year ago

Thank you for your reply. But the problem is I don't want to add compilers path to the system PATH. Is there a method to add the compilers path to the makefile-tool making environment.?

gcampbell-msft commented 1 year ago

Something like this: https://stackoverflow.com/questions/6258851/specifying-path-in-makefile-gnu-make-on-windows, might work? I haven't gotten a chance to test that it would work for you, but this might help.

Please let me know if this helps you at all, or if there is anything further that we can do to assist.

huangda1982 commented 12 months ago

Thank you very much. I will close this issue.

andreeis commented 12 months ago

@huangda1982, you can also add the compiler path to the path via the preConfigure script which would not require a close/reopen of VSCode and neither an alteration of your PATH variable on the system. It will only inject the new paths into the path of the current process. Write a script and point the extension to it via "makefile.preConfigureScript", then run the "Pre-configure" command from the palette before configuring and building. Does this work?

andreeis commented 12 months ago

Regarding compiling one .c file, maybe you are familiar with the equivalent in the CppTools or CMake Tools extensions. We don't have that here implemented on purpose but you can achieve it depending on how your makefile is written. You could chose a build target as the obj of the file (left side UI panel of Makefile Tools) then run build. But I admit this is too complicated. We also generate a compile_commands.json (there is a command in the Makefile Tools palette) and you can hook that file into CppTools to get "Compile single file" functionality. I also opened work item https://github.com/microsoft/vscode-makefile-tools/issues/507 to track this on our side. It wouldn't hurt we implement this at some point.