Compiling multiple C++ files in Visual Studio Code (Ubuntu 22.04)

Поделиться
HTML-код
  • Опубликовано: 22 авг 2024

Комментарии • 104

  • @davidnewman1605
    @davidnewman1605 Год назад +23

    You have no idea how long I've been racking my brain trying to figure this out! Thank You!

    • @absprog
      @absprog  Год назад

      I'm glad to hear that the tutorial was helpful to you David 👍

    • @brianli3493
      @brianli3493 2 месяца назад

      ME TOO

  • @vrajsavani241
    @vrajsavani241 10 месяцев назад +4

    after seeing 40 videos and 30 articles finally found your video helpful thanks a lot

    • @absprog
      @absprog  10 месяцев назад

      Thank you for your feedback! I'm glad it turned out well 👍

  • @Mario-xc5dz
    @Mario-xc5dz Год назад +2

    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

    • @absprog
      @absprog  Год назад +2

      I'm glad to hear that it worked well for you Mario

  • @ismaelfernandezmendez1664
    @ismaelfernandezmendez1664 5 месяцев назад

    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!

    • @absprog
      @absprog  5 месяцев назад

      I'm glad it turned out well👍

  • @user-ue8gm6xe1k
    @user-ue8gm6xe1k 10 месяцев назад +11

    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.

  • @user-rl1ds8li2x
    @user-rl1ds8li2x 11 месяцев назад +1

    This was so useful, it need to be the top result when you search for how to compile c++.

    • @absprog
      @absprog  11 месяцев назад

      Thanks for your kind words! 👍

  • @williamkiarie9669
    @williamkiarie9669 9 месяцев назад +1

    Just started using VS Code, and your tutorial has been exceptionally helpful.

    • @absprog
      @absprog  9 месяцев назад

      That's great to hear👍

  • @dabunnisher29
    @dabunnisher29 8 дней назад

    This was SUPER HELPFUL. Thank you!

    • @absprog
      @absprog  7 дней назад

      Glad it was helpful!

  • @AlexRoman-dv7uo
    @AlexRoman-dv7uo 2 месяца назад

    Hallelujah !!!! Finally someone got it straight to the point.

    • @absprog
      @absprog  2 месяца назад

      Thanks for the feedback Alex!

  • @peterwake2
    @peterwake2 Год назад +1

    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.

    • @absprog
      @absprog  Год назад

      Thanks for the tip!

  • @ryanantony6191
    @ryanantony6191 4 месяца назад

    Thanks, this was exactly what I was looking for. I've been trying to get more experience with C++.

    • @absprog
      @absprog  4 месяца назад +1

      Glad it was helpful!👍

  • @pankaj_yadav99
    @pankaj_yadav99 7 месяцев назад

    In my windows vs code with mingw, it didn't work initially .
    Finally it worked, nice tutorial
    👍

    • @absprog
      @absprog  7 месяцев назад

      I am glad you found this helpful👍

  • @hugogarcia3375
    @hugogarcia3375 4 месяца назад +2

    I have a problem, why when I try to use another file it gives me an output error -1?

  • @Rapidspiders
    @Rapidspiders 8 месяцев назад +2

    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

  • @AD-ly5zk
    @AD-ly5zk 3 месяца назад +2

    I have no suggestions within the json file

  • @user-ju3cx1dh4z
    @user-ju3cx1dh4z 7 дней назад +1

    But now when i run another c++ file it gives an error. How do i fix it

  • @fischeye82
    @fischeye82 5 месяцев назад

    You just saved my life! Thank you!

    • @absprog
      @absprog  5 месяцев назад +1

      Happy to help!🤗

  • @paulkariuki4392
    @paulkariuki4392 Год назад +1

    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"_".

  • @PaulDirac_
    @PaulDirac_ 7 месяцев назад

    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.

    • @absprog
      @absprog  7 месяцев назад

      Thank you so much for your kind words! I'll do my best to prioritize it

  • @Miller-bp3ww
    @Miller-bp3ww 6 месяцев назад

    cant thank you enough for this!

    • @absprog
      @absprog  6 месяцев назад

      You're most welcome👍

  • @tasinkhan-sp6ov
    @tasinkhan-sp6ov 8 месяцев назад

    you save my brain to overthink to link every source file

    • @absprog
      @absprog  8 месяцев назад

      Thanks for your support👍

  • @VantomChannel
    @VantomChannel 9 месяцев назад

    Thank you so much for saving my time

  • @ComputerScience-pd7nd
    @ComputerScience-pd7nd Год назад +3

    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.

    • @addmix
      @addmix Год назад +3

      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.

    • @ComputerScience-pd7nd
      @ComputerScience-pd7nd 11 месяцев назад +1

      It is working now you are 100% correct. Thank you and I hope you have a good day!

    • @mfbayramfenac
      @mfbayramfenac 6 месяцев назад

      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"
      ],

  • @o01122
    @o01122 2 месяца назад

    New problem, now a project with two .h files also does not compile, something needs to be configured.

  • @user-vg3qj1cv8h
    @user-vg3qj1cv8h Год назад

    Thank you very much! This video is really helpful!!!!

    • @absprog
      @absprog  Год назад

      Thanks for the feedback!

  • @JK-dd7vn
    @JK-dd7vn 7 месяцев назад

    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.

  • @o01122
    @o01122 2 месяца назад

    Thank you very much!

    • @absprog
      @absprog  2 месяца назад

      You're most welcome!

  • @syenah7059
    @syenah7059 3 месяца назад

    you should also include fixing undefined reference error to the title. it will be easier to search.

    • @absprog
      @absprog  3 месяца назад

      I appreciate your contribution. Thanks

  • @Rodrigoooo
    @Rodrigoooo 9 месяцев назад

    Great it worked finally! Thanks! Do you know how to get the same result with the Code Runner extension?

  • @pinielchitare9221
    @pinielchitare9221 Год назад

    This doesn't work for me. I'm still having the same error after following your instructions

  • @destineecassie7143
    @destineecassie7143 4 месяца назад +1

    I don’t know why it’s still not working for me 😭

  • @wesleytaylor-rendal5648
    @wesleytaylor-rendal5648 9 месяцев назад

    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)

  • @Bamber11999
    @Bamber11999 11 месяцев назад

    Great tip, thank you! Is there a way to add a "Build" icon on the status bar?

  • @baksblr11
    @baksblr11 10 месяцев назад

    Man this is a great tutorial, thanks! What is a hotkey analogue of ctrl+space for macos?

    • @absprog
      @absprog  9 месяцев назад

      I am glad you found this helpful. For macOS it is Cmd+Space

  • @dajoelnino8317
    @dajoelnino8317 2 месяца назад

    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?

    • @absprog
      @absprog  2 месяца назад

      Yeah, you can just leave it this way

  • @hf_boeing
    @hf_boeing 6 месяцев назад +1

    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(

    • @mfbayramfenac
      @mfbayramfenac 6 месяцев назад

      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.

    • @mfbayramfenac
      @mfbayramfenac 6 месяцев назад

      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"
      ],

    • @hf_boeing
      @hf_boeing 6 месяцев назад

      @@mfbayramfenac
      Thanks for the answer! But it didn't help me. When I added "\\", the same problem was caused

    • @mfbayramfenac
      @mfbayramfenac 6 месяцев назад

      @@hf_boeing Did you make sure that your projects file path directory has no space inside? This is really important to check.

    • @ryomaizen
      @ryomaizen 4 месяца назад

      @@mfbayramfenac wow, c++ is a bit a shit. starting with this shit problem....

  • @_tesseract7029
    @_tesseract7029 8 месяцев назад

    bro thank you so much!

    • @absprog
      @absprog  8 месяцев назад

      You're most welcome👍

  • @user-ck6yl6qb2g
    @user-ck6yl6qb2g 7 месяцев назад

    Great video thanks!!

    • @absprog
      @absprog  7 месяцев назад +1

      Thank you very much!👍

    • @user-ck6yl6qb2g
      @user-ck6yl6qb2g 7 месяцев назад

      @@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...
      ?

  • @alexeystepanenko8965
    @alexeystepanenko8965 5 месяцев назад

    Not working in Ubuntu

  • @ubuntujackson9133
    @ubuntujackson9133 Год назад +2

    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()'

  • @PolloGamer3424
    @PolloGamer3424 2 месяца назад

    How do i do it using windows?

  • @huzaifaat5265
    @huzaifaat5265 8 месяцев назад

    Cam we do the same with multiple c and cpp files in the same directory

    • @mfbayramfenac
      @mfbayramfenac 6 месяцев назад

      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"
      ],

  • @WaarDoz57
    @WaarDoz57 7 месяцев назад

    God bless you

    • @absprog
      @absprog  7 месяцев назад

      Thanks 🙏

  • @mm-wm6uh
    @mm-wm6uh 10 месяцев назад

    how convert .cpp .h file to exe in visual studio code

  • @JimenaGarciaC
    @JimenaGarciaC Год назад

    Thank you!!

    • @absprog
      @absprog  Год назад +1

      You're most welcome! 🤗

  • @onlzy
    @onlzy Год назад

    thank you soooo much

    • @absprog
      @absprog  Год назад +1

      Thank you for taking the time to watch my video and for leaving a comment Johannes

  • @azylumZ
    @azylumZ Год назад

    Cool

    • @absprog
      @absprog  Год назад +1

      Thank you for watching! I appreciate your support Ahmed!

  • @HyphenFrox
    @HyphenFrox 11 месяцев назад

    Thank You

    • @absprog
      @absprog  11 месяцев назад

      You're welcome 👍

  • @ItsBrocraftHd
    @ItsBrocraftHd Год назад

    i do not have a tasks.json file in my .vscode folder, can you help with that?

    • @othniell_l__l
      @othniell_l__l Год назад

      me too i need some help please

    • @whoskwabi
      @whoskwabi Год назад

      same here

    • @krzysztofturchan5355
      @krzysztofturchan5355 Год назад +1

      Try to hit the debug button and is should appear.

    • @ipsita1227
      @ipsita1227 2 месяца назад

      @@krzysztofturchan5355 thanks it worked !

    • @1harw
      @1harw 6 дней назад

      @@krzysztofturchan5355 i love you bro

  • @Sakapaka
    @Sakapaka 10 месяцев назад

    i dont have a .vscode file...

    • @Rapidspiders
      @Rapidspiders 8 месяцев назад

      Go to settings and search executor map, when you open it I think it should make the .vscode file appear

  • @ahmetsar165
    @ahmetsar165 Год назад

    thanks a lot

    • @absprog
      @absprog  Год назад

      You're welcome Ahmet! 👍

  • @Snapper_Raj
    @Snapper_Raj 10 месяцев назад

    Bro you are saviour

    • @absprog
      @absprog  10 месяцев назад

      Thanks for your support and kind words! 😊

  • @lamalamalex
    @lamalamalex Год назад

    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”