I'm a beginner in C++, and I'm trying to compile multiple files using the Code Runner extension in VS Code. I've modified the setting to:
`"cpp": "cd $dir && g++ *.cpp -o $fileNameWithoutExt && $dir$fileNameWithoutExt"`
However, I keep getting a fatal error stating that '*.cpp' is an invalid argument. I've seen posts suggesting that using '*.cpp' should work in PowerShell, but it's not working for me. What could be the issue, and how can I resolve it?
2 Answers
It looks like the issue might be that you have quoted '*.cpp'. In PowerShell, if you include quotes around it, it won't expand the wildcard correctly. Try running it without quotes like this: `g++ *.cpp` and see if that solves the problem.
It sounds like you might be using the escape character '' incorrectly. The code is trying to find a file named '*.cpp' instead of recognizing it as a wildcard. Just make sure that your command looks like `g++ *.cpp` without any escape characters. That should allow the shell to interpret it properly.
I tried removing the escape character, but I'm still getting the same error: `cc1plus.exe: fatal error: *.cpp: Invalid argument`.