Thanks for this, very useful. Just to add that once I got this working using your tips, I adapted this to have "-g", "${file}", "${workspaceFolder}/classes/*.cpp", and by doing this I could have several "test scripts" all using the included classes I'd made.
I did the same but I’m using clang/clang++ (so I edited this under the clang/clang++ section) and it still doesn’t work for me. It gives me a linker error and still says that the functions I’ve called are undefined
The error: "fatal error: no such directory" Occurred because the file name has seperated words by spaces. To fix it: remove spaces from the filename or replace it with an underscore"_".
you are a life saver. It would be really helpful if you make a video where you explain how to configure vscode for c++ through c_cpp_properties.json , launch.json , task.json.
Hi! I have a problem. I followed everything on this video. However, when I tried to debug, it is showing "..*.cpp: Invalid argument" g++.exe: fatal error: no input files How can I fix this? Thank you so much.
I've been trying to solve this issue for myself for the past few hours. I found that if you have any spaces in your filepath, which causes the entire path to be surrounded by quotes, including the "*.cpp" part, which is then not recognized properly. Removing spaces from the filepath, or, if you can find a way to do: "C:/whatever/your/filepath/is/"*.cpp where the quotes do not include the "*.cpp" part.
It solved my issue too with a small "\\" update, thank you very much. Incase anyone needs (you can replace c files to cpp) "command": "gcc", "args": [ "-c", "${workspaceFolder}\\*.c", "&&", "gcc", "-o", "program", "${workspaceFolder}\\*.o" ],
Thank you so much mate, I spent literally DAYS trying to find solution to this... Also, may I ask how can I modify the "${workspaceFolder}/*.cpp" so it would compile all the .cpp files in the subdirectories too? I have those files included in path from c_cpp_properties.json I suppose, but they don't get compiled.
Can you explain what to do when you have multiple folders. For example folder 1 = cordic_fucntion, folder 2 = taylor series. I want ot be able to run the two programs seperately by pressing play when on the specific file (tb_taylor, tb_cordic)
Mb u can help me. I added "&{workspaceFolder}/*. cpp" to arguments where my cpp files are, but when it started to compile, that string is inserted into the console in single quotes. It looks like "g++ -g '/my_folders/*. cpp' -o my_program_name.out" And it causes and error like 'my_folders/*. cpp' no such file or directory was found. Seems like something wrong with mask "*". If I added all the cpp pathes separately, it worked fine. Idk how to solve that problem(
Seems like I am not the only one with this issue. Me as well If I add all the cpp pathes separately, it works. If you find any solution can you mention me here? I will do that if I find a solution as well.
We need to make sure that our file path has no spaces. @addmix solved and I just updated with "\\" . Incase anyone needs (you can replace c files to cpp) @hf_boeing "command": "gcc", "args": [ "-c", "${workspaceFolder}\\*.c", "&&", "gcc", "-o", "program", "${workspaceFolder}\\*.o" ],
@@absprogThe video is to the point and solves the problem. Do you know how to compile, but now when you have folders, e.g. if you have main.cpp, and ./dir1/f1.h ./dir1/f1.cpp, etc... ?
Hello, this is probably a good video and all, because according to the VS code documentation, this is probably what you're supposed to do. But for some reason, even though I follow all the steps here, I get the exact same linking error message as before: /usr/bin/g++ -fdiagnostics-color=always -g /home/uj/Desktop/temporary/*.cpp -o /home/uj/Desktop/temporary/main /usr/bin/ld: /tmp/ccqAYtJ0.o: in function `main': /home/uj/Desktop/temporary/main.cpp:4: undefined reference to `return_one()'
I think you should compile and link c files like this, it worked for me. "command": "gcc", "args": [ "-c", "${workspaceFolder}\\*.c", "&&", "gcc", "-o", "program", "${workspaceFolder}\\*.o" ],
You have no idea how difficult it is to find this kind of answer! I am glad I ran into your video! It was EXACTLY what I was looking for! I almost gave up and cheat by using: include “FILE_NAME.cpp”
You have no idea how long I've been racking my brain trying to figure this out! Thank You!
I'm glad to hear that the tutorial was helpful to you David 👍
ME TOO
after seeing 40 videos and 30 articles finally found your video helpful thanks a lot
Thank you for your feedback! I'm glad it turned out well 👍
Thank you from all my heart , i've been stuck in this for a day and half until i found your video and fixed my problem
I'm glad to hear that it worked well for you Mario
I sure love you. I may have been 10 hours trying to compile my damn code, but in the end you saved me. It was a damn torture but it is compiled!
I'm glad it turned out well👍
Hey man , can you make a tutorial explaining about the c_cpp_properties.json , launch.json , task.json and its components . That would be helpful.
This was so useful, it need to be the top result when you search for how to compile c++.
Thanks for your kind words! 👍
Just started using VS Code, and your tutorial has been exceptionally helpful.
That's great to hear👍
This was SUPER HELPFUL. Thank you!
Glad it was helpful!
Hallelujah !!!! Finally someone got it straight to the point.
Thanks for the feedback Alex!
Thanks for this, very useful. Just to add that once I got this working using your tips, I adapted this to have "-g", "${file}", "${workspaceFolder}/classes/*.cpp", and by doing this I could have several "test scripts" all using the included classes I'd made.
Thanks for the tip!
Thanks, this was exactly what I was looking for. I've been trying to get more experience with C++.
Glad it was helpful!👍
In my windows vs code with mingw, it didn't work initially .
Finally it worked, nice tutorial
👍
I am glad you found this helpful👍
I have a problem, why when I try to use another file it gives me an output error -1?
I did the same but I’m using clang/clang++ (so I edited this under the clang/clang++ section) and it still doesn’t work for me. It gives me a linker error and still says that the functions I’ve called are undefined
I have no suggestions within the json file
But now when i run another c++ file it gives an error. How do i fix it
You just saved my life! Thank you!
Happy to help!🤗
The error: "fatal error: no such directory"
Occurred because the file name has seperated words by spaces.
To fix it: remove spaces from the filename or replace it with an underscore"_".
you are a life saver. It would be really helpful if you make a video where you explain how to configure vscode for c++ through c_cpp_properties.json , launch.json , task.json.
Thank you so much for your kind words! I'll do my best to prioritize it
cant thank you enough for this!
You're most welcome👍
you save my brain to overthink to link every source file
Thanks for your support👍
Thank you so much for saving my time
Hi!
I have a problem. I followed everything on this video. However, when I tried to debug, it is showing "..*.cpp: Invalid argument"
g++.exe: fatal error: no input files
How can I fix this? Thank you so much.
I've been trying to solve this issue for myself for the past few hours. I found that if you have any spaces in your filepath, which causes the entire path to be surrounded by quotes, including the "*.cpp" part, which is then not recognized properly. Removing spaces from the filepath, or, if you can find a way to do:
"C:/whatever/your/filepath/is/"*.cpp
where the quotes do not include the "*.cpp" part.
It is working now you are 100% correct. Thank you and I hope you have a good day!
It solved my issue too with a small "\\" update, thank you very much. Incase anyone needs (you can replace c files to cpp)
"command": "gcc",
"args": [
"-c",
"${workspaceFolder}\\*.c",
"&&",
"gcc",
"-o",
"program",
"${workspaceFolder}\\*.o"
],
New problem, now a project with two .h files also does not compile, something needs to be configured.
Thank you very much! This video is really helpful!!!!
Thanks for the feedback!
Thank you so much mate, I spent literally DAYS trying to find solution to this...
Also, may I ask how can I modify the "${workspaceFolder}/*.cpp" so it would compile all the .cpp files in the subdirectories too? I have those files included in path from c_cpp_properties.json I suppose, but they don't get compiled.
Thank you very much!
You're most welcome!
you should also include fixing undefined reference error to the title. it will be easier to search.
I appreciate your contribution. Thanks
Great it worked finally! Thanks! Do you know how to get the same result with the Code Runner extension?
This doesn't work for me. I'm still having the same error after following your instructions
I don’t know why it’s still not working for me 😭
x2
Can you explain what to do when you have multiple folders. For example folder 1 = cordic_fucntion, folder 2 = taylor series. I want ot be able to run the two programs seperately by pressing play when on the specific file (tb_taylor, tb_cordic)
Great tip, thank you! Is there a way to add a "Build" icon on the status bar?
Man this is a great tutorial, thanks! What is a hotkey analogue of ctrl+space for macos?
I am glad you found this helpful. For macOS it is Cmd+Space
would you recommend to always use this? Like can I just change my task.json as shown and I wont have to rap my head around compiling?
Yeah, you can just leave it this way
Mb u can help me. I added "&{workspaceFolder}/*. cpp" to arguments where my cpp files are, but when it started to compile, that string is inserted into the console in single quotes. It looks like "g++ -g '/my_folders/*. cpp' -o my_program_name.out" And it causes and error like 'my_folders/*. cpp' no such file or directory was found. Seems like something wrong with mask "*". If I added all the cpp pathes separately, it worked fine. Idk how to solve that problem(
Seems like I am not the only one with this issue. Me as well If I add all the cpp pathes separately, it works. If you find any solution can you mention me here? I will do that if I find a solution as well.
We need to make sure that our file path has no spaces. @addmix solved and I just updated with "\\" . Incase anyone needs (you can replace c files to cpp) @hf_boeing
"command": "gcc",
"args": [
"-c",
"${workspaceFolder}\\*.c",
"&&",
"gcc",
"-o",
"program",
"${workspaceFolder}\\*.o"
],
@@mfbayramfenac
Thanks for the answer! But it didn't help me. When I added "\\", the same problem was caused
@@hf_boeing Did you make sure that your projects file path directory has no space inside? This is really important to check.
@@mfbayramfenac wow, c++ is a bit a shit. starting with this shit problem....
bro thank you so much!
You're most welcome👍
Great video thanks!!
Thank you very much!👍
@@absprogThe video is to the point and solves the problem.
Do you know how to compile, but now when you have folders, e.g.
if you have main.cpp, and ./dir1/f1.h ./dir1/f1.cpp, etc...
?
Not working in Ubuntu
Hello, this is probably a good video and all, because according to the VS code documentation, this is probably what you're supposed to do.
But for some reason, even though I follow all the steps here, I get the exact same linking error message as before:
/usr/bin/g++ -fdiagnostics-color=always -g /home/uj/Desktop/temporary/*.cpp -o /home/uj/Desktop/temporary/main
/usr/bin/ld: /tmp/ccqAYtJ0.o: in function `main':
/home/uj/Desktop/temporary/main.cpp:4: undefined reference to `return_one()'
How do i do it using windows?
Cam we do the same with multiple c and cpp files in the same directory
I think you should compile and link c files like this, it worked for me.
"command":
"gcc",
"args": [
"-c",
"${workspaceFolder}\\*.c",
"&&",
"gcc",
"-o",
"program",
"${workspaceFolder}\\*.o"
],
God bless you
Thanks 🙏
how convert .cpp .h file to exe in visual studio code
Thank you!!
You're most welcome! 🤗
thank you soooo much
Thank you for taking the time to watch my video and for leaving a comment Johannes
Cool
Thank you for watching! I appreciate your support Ahmed!
Thank You
You're welcome 👍
i do not have a tasks.json file in my .vscode folder, can you help with that?
me too i need some help please
same here
Try to hit the debug button and is should appear.
@@krzysztofturchan5355 thanks it worked !
@@krzysztofturchan5355 i love you bro
i dont have a .vscode file...
Go to settings and search executor map, when you open it I think it should make the .vscode file appear
thanks a lot
You're welcome Ahmet! 👍
Bro you are saviour
Thanks for your support and kind words! 😊
You have no idea how difficult it is to find this kind of answer! I am glad I ran into your video! It was EXACTLY what I was looking for! I almost gave up and cheat by using: include “FILE_NAME.cpp”