New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C/C++: Can't compile or run when source file path has space(s) #248
Comments
Same problem. "code-runner.executorMap": { I can run the first two command successfully, but it won't work for the last command ($dir$fileNameWithoutExt). |
@Michany Try changing |
@hanghang0702 sorry I'm late, @Michany you forgot the escape characters, @formulahendry it isn't the problem on *nix based system the executable file runs with ./"dir"filename ,
I'm not a windows user & I'm not sure if it's going to work on windows (you'll probably need to adjust/change some escape characters or something similar). |
Same issue here. When I run C code in bash terminal. I get this: |
Hello! I have a same problem in Mac OS X. Some solution to this bug? Thank you! |
If you are using Windows, try configuring settings like this: "code-runner.executorMap": {
"cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt.exe\" && & \"$dir$fileNameWithoutExt.exe\""
} Pay attention to the extra If you are using Unix based system, try this (I haven't tested, but I think this would work): "code-runner.executorMap": {
"cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" && \"$dir$fileNameWithoutExt\""
} |
Hello, I have the same problem. I'm using Windows, I'm trying to run a simple C++ program, I don't have spaces anywhere in the path or file name.
If I copy the command as is, and paste it in a cmd.exe then it works without problem :/ I made changes as suggested by others but nothing worked. EDIT: Solved! Here is how, maybe it will help others :
|
hello there... |
Yes in settings.json. I finally used this command instead:
Here is extract of my settings.json :
|
I believe I am also having this issue. Are there any plans on resolving it? Here are my results: |
Hello, after trying a lot of time I found the solution, hope this will help others "cpp": "cd $dir && g++ "$fileName" -o "$fileNameWithoutExt" && .\"$fileNameWithoutExt"", |
Where to add this?? IN settings.json file in .vscode?? or somewhere else? |
![image](https://user-images.githubusercontent.com/61356854/80334858-161fd900-8818-11ea-92eb-ad8e37982bc7.png)
…-->Yeah you need to copy that on your settings.json (exactly in your executor map) on vscode, i’m going to attach a photo
|
Windows Guys!
|
this worked for me. I Am now able to compile and run c cpp and java files('&' is not needed in java though if anyone is wondering) |
This solution works!! Finally my c program could be compiled and run. Thanks! |
It really helped, Thank You! |
PLEASE HELP!!!😭 I'm getting the same error.
This and still I'm getting the same error. And my environment variables : And just in case if anyone has doubts about my files and such... |
@tripathi-abhishek use this In case you run into issues with a bash error like "bash: cd: too many arguments" Fixed by:- Screenshot:- |
@VipulKhandelwal1999 thanks this worked! |
@ushakhanal read my comments. I have already explained what to do in case of "too many arguments" error. |
For windows in settings .json change cpp to the following: "code-runner.executorMap": { |
this works for me |
Thank you very much, I was using the same .json as you suggested. |
Simple open the code runner configuration by search in settings code runner and under extensions selecting it then scroll and click on edit setting.json |
Thank you. Your executorMap worked for my cpp files in code runner but I copied the same executorMap for c programs and it isnt working.
I am getting this error
EDIT I managed to do it for C with this
|
It works for me!
|
I created a file
D:\Program\USACO\[C2, S3.2] Magic Square.cpp
But when I compile,
some errors occurred:
OS: Win7 SP1
VSCode: 1.19.3
Runner: 0.8.7 5beeedf
The text was updated successfully, but these errors were encountered: