0

I'm trying to compile my app using vs code and g++ on windows 11 without having to type all the files manually in the task.json file, but everytime I try to compile I get a fatal error :

cc1plus.exe: fatal error c:\..\src\*.cpp invalid argument

I tried replacing /src/*.cpp for \\src\cpp or /src/**.cpp and pretty much all the possible variants.
I have also tried to change the type from cppbuild to shell.

None of this worked.

Note that if I type all the files manually vs code is able to compile the app.

Here's the arguments I'm using.

"args": [
    "-fdiagnostics-color=always",
    "-g",
    "${workspaceFolder}/src/*.cpp",
    "-o", 
    "${workspaceFolder}/bin/app.exe"
  ],
8
  • I dont think in WIndows, the wildcards expand in g++. Try using **/*.cpp Commented Nov 10 at 8:33
  • Note, the question proposed as a duplicate is totally different from this one. Commented Nov 10 at 10:04
  • 3
    Please post a complete, unedited error message, formatted as a code block Commented Nov 10 at 10:07
  • In my opinion, the correct solution is to "not use Visual Studio Code". Commented Nov 10 at 15:01
  • 1
    The official VSCode instructions say this won't work: https://code.visualstudio.com/docs/cpp/config-mingw#_modifying-tasksjson "Starting November 3, 2024, MSYS2 has disabled wildcard support for mingw-w64 by default. This change impacts how wildcards like "*.cpp" are processed in build commands. To build multiple C++ files in your tasks.json, you must explicitly list the files, use a build system like make or cmake or implement the following workarounds: msys2.org/docs/c/#expanding-wildcard-arguments." Commented Nov 11 at 13:47

1 Answer 1

1

The official VSCode MinGW instructions say this won't work anymore: https://code.visualstudio.com/docs/cpp/config-mingw#\_modifying-tasksjson

Starting November 3, 2024, MSYS2 has disabled wildcard support for mingw-w64 by default. This change impacts how wildcards like "*.cpp" are processed in build commands. To build multiple C++ files in your tasks.json, you must explicitly list the files, use a build system like make or cmake or implement the following workarounds: msys2.org/docs/c/#expanding-wildcard-arguments.

In addition to the make or CMake suggestion from the above quote you can also just switch to use bash as your shell and have the shell expand the wildcard for you. You do this by editing your settings.json

"terminal.integrated.profiles.windows": {
  "MSYS2 Bash": {
    "path": "C:\\msys64\\usr\\bin\\bash.exe"
  }
},
"terminal.integrated.defaultProfile.windows": "MSYS2 Bash"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.