C/C++: Can't compile or run when source file path has space(s)
See original GitHub issueI created a file
D:\Program\USACO\[C2, S3.2] Magic Square.cpp
But when I compile, some errors occurred:
[Running] cd "d:\Program\USACO\" && g++ [C2, S3.2] Magic Square.cpp -o [C2, S3.2] Magic Square && "d:\Program\USACO\"[C2, S3.2] Magic Square
g++: error: [C2,: No such file or directory
g++: error: S3.2]: No such file or directory
g++: error: Magic: No such file or directory
g++: error: Square.cpp: No such file or directory
g++: error: S3.2]: No such file or directory
g++: error: Magic: No such file or directory
g++: error: Square: No such file or directory
g++: fatal error: no input files
compilation terminated.
OS: Win7 SP1 VSCode: 1.19.3 Runner: 0.8.7 5beeedfa674b330537448162dfe9c2330c7eda50
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:29 (1 by maintainers)
Top Results From Across the Web
C++ file name with space causes error in Visual Studio Code
If you are using Windows, try configuring settings like this in your Setting.JSON "code-runner.executorMap": { "cpp": "cd $dir && g++ ...
Read more >g++ compiler : unable to compile - c++ - Super User
and I'm trying to run a very simple program to display "hello", to see wether it would work. The problem is that whatever...
Read more >How To Compiling C Program And Creating Executable File ...
Next, open your terminal(ctrl+t) and type cd location and press enter.Now compile your c file using this command line gcc filename.c .Now a.out ......
Read more >Getting Started with the LLVM System
Local LLVM Configuration; Compiling the LLVM Suite Source Code; Cross-Compiling LLVM; The Location of LLVM Object Files; Optional Configuration Items.
Read more >Using make to Compile Programs
Most C programs, however, are compiled from several source files. ... Each executable is to be built from a source file that has...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you are using Windows, try configuring settings like this:
Pay attention to the extra
'&'
character.If you are using Unix based system, try this (I haven’t tested, but I think this would work):
@tripathi-abhishek use this
In case you run into issues with a bash error like “bash: cd: too many arguments”
Fixed by:- Go to visual studio code settings for code runner and replace cpp key value pair in code-runner.executorMap with the following :- “code-runner.executorMap”: { “cpp”: “g++ $fileName -o $fileNameWithoutExt.exe && ‘./$fileNameWithoutExt.exe’” }
Screenshot:- replace your cpp key value pair with the below mentioned code in “code-runner.executorMap” like:-