r/code • u/Whole_Database_8706 • Dec 19 '21
New to coding , been trying to make a executable file but keep getting this error , lotta sources only describe the problem but not how to fix it , help
4
u/PixlDemon Dec 21 '21
people are correctly saying that wrapping the path in quotes may fix the problem, but I'd say you should never ever have spaces in source file names in the first place. because it complicates things in the command line and also because in some languages, you may have to refer to source files by name in your code (without quotes around them) which will not work if they contain whitespace. get used to using underscores, dashes or CamelCase instead of spaces. it will make your life easier. this goes for directory names aswell.
1
4
u/Whole_Database_8706 Dec 19 '21
man I need help not upvotes :/
5
u/RagingBox08 Dec 19 '21
Use double quotes for filename
4
u/Whole_Database_8706 Dec 19 '21
Ayo , double quotes? file name as in the folder or actual .cpp file
5
u/RagingBox08 Dec 19 '21
What ur command
5
u/RagingBox08 Dec 19 '21
What do u type in terminal to create an .exe file
4
4
u/Whole_Database_8706 Dec 19 '21
What should I type in terminal to make a .exe file ?
4
3
3
u/_Azurius Dec 19 '21
The whitespace in your filename is the culprit. Rename your file to not contain any whitespace. Hello World.cpp - > HelloWorld.cpp
3
u/Whole_Database_8706 Dec 19 '21
did it befor , not working
4
u/_Azurius Dec 19 '21
Use your terminal then. Copy the command it executed but put every path in double quotes, eg "C:/marks pc/..." and run it this way. Your ide is looking for a file called "World.cpp", which doesn't exist.
2
u/Whole_Database_8706 Dec 19 '21
sorry I don’t understand what ur saying here , can you give me a actual example of what I should type I the terminal ?
3
u/_Azurius Dec 19 '21
See the two lines between "Starting build..." and "cc1plus.exe..."? Copy this, but put every path in double quotes "C:/Users/.../your file.cpp", paste it into the terminal (where it shows the error) and hit enter.
2
1
Dec 19 '21
Did you copied the directory name as well from the file explorer address bar! Cause there should be %20 instead of space in the user's folder name!!
1
u/bottlez14 Dec 19 '21 edited Dec 19 '21
Try reading about this is vscode docs Using GCC with MinGW.
In your example it says error: world.cpp: No such file or directory That's because your file paths are not "surrounded in quotes". On windows if you have any space, you need quotes for file path.
I was able to get the build task to work. Notice "C:\Users\auste\Downloads\c++\Hello world.cpp" is in quotes.
> Executing task: C/C++: g++.exe build active file <
Starting build...
C:/msys64/mingw64/bin/g++.exe -g "C:\Users\auste\Downloads\c++\Hello world.cpp" -o "C:\Users\auste\Downloads\c++\Hello world.exe"
The system cannot find the path specified.
Build finished with warning(s).
Terminal will be reused by tasks, press any key to close it.Tell us how you are actually building. Are you using the build task in vscode CTRL+SHIFT+B? Sharing the file .vscode\tasks.json will help us help you.
If you are brand new and actually want to learn C++ I suggest using Visual Studio not VSCode. There is alot less to setup in a full fledged IDE.
1
0
Dec 19 '21
[deleted]
4
u/Whole_Database_8706 Dec 19 '21
guys , thank you all for replying and taking the time to respond , my issue has been resolved , again thank you all
5
u/[deleted] Dec 19 '21
Either don't use spaces on your file names, or use double quotes when u execute the program