Help with Building Multiple C++ Files in VS Code

0
8
Asked By CleverPigeon42 On

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

Answered By CrispCoder On

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.

Answered By TechieBee99 On

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.

CleverPigeon42 -

I tried removing the escape character, but I'm still getting the same error: `cc1plus.exe: fatal error: *.cpp: Invalid argument`.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.