Compiling Multiple Files in VS Code

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024
  • In this video, I will show you how to compile multiple C++ files in VS Code.
    Link to:
    Visual Studio Code: code.visualstu...
    MSYS2: www.msys2.org/
    Want to know which social media I use? Here's the link:
    odysee.com/@Ki....
    Want to know which content goes to which platforms? Here's the link:
    odysee.com/@Ki....
    Github Source Code:
    github.com/kin....
    For tutorial video requests email me at:
    kingtutlearning@protonmail.com
    #kingtut #education #vscode

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

  • @Justicewarrior795
    @Justicewarrior795 7 месяцев назад +34

    bro you gotta be prosecuted for that red theme

  • @jimozzy5245
    @jimozzy5245 8 месяцев назад +4

    A year later, and this is still helping folks out. Thank you dude. Another way to do it is to replace "${file}" in tasks.json with "${fileDirname}/*.cpp"

  • @evanlinard3191
    @evanlinard3191 2 года назад +4

    Thanks, dude! Honestly, seeing you work through the errors was useful.

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

    OMG
    I was just about to break my laptop or jump out of the window , it really helped thanks so much

  • @FourAwsomeGamerz
    @FourAwsomeGamerz 2 года назад +8

    Great vid, if you're using C not C++ this also works just need to change the .cpp to .c

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

    THANKS a lot, i've been searching a solution for this issue from 3 days and i thought it was the compilator of VScode which wasn't right installed, thx to you it's working well now

  • @thedarkestone2459
    @thedarkestone2459 22 дня назад

    Thank for this : ) I wish they could have explained this better in the documentation, I spent over 2 hours on this problem : (

  • @Sheep-s4n
    @Sheep-s4n 2 года назад +4

    Thanks for the help ! I was desperate.

  • @GrandpuhTy
    @GrandpuhTy 2 года назад +10

    Oh sweet Jesus - FINALLY! Been smashing my head against this for a couple days finding no explanation for it, so thank you for this.
    Is there no way for it to just recursively scrape the whole working directory for all subfolders and their files?

    • @kingtutlearning
      @kingtutlearning  2 года назад +1

      Thank you! It's great that you benefitted from this content.
      I am not sure how to do that. Do you mean deleting the files inside the working folder over and over again? I am still learning about some aspects of VSCode.

    • @GrandpuhTy
      @GrandpuhTy 2 года назад +3

      @@kingtutlearning I meant instead of linking every sub folder directly,
      ie ${workspaceFolder}\\cars\\*.cpp
      ${workspaceFolder}\\cars\\*.h
      Is there an option to have it go through every folder looking for those files without having to type each one out in the tasks.json? It seems a bit clunky to me to have to manually list each folder and file type per folder, so I automatically assume "There has to be a better way!" I could be wrong.
      Maybe whipping up a little script to collect all the files and their paths and append them to a g++ command in cygwin is the way to go.

    • @kingtutlearning
      @kingtutlearning  2 года назад +1

      @@GrandpuhTy That's a good question. I think you have to write script but I do not know what script I have to write for .json files.
      The only solution I can think of is to write a batch or bash (if you are on Linux) script and incorporate it into the .json files.

    • @jiadongyao8083
      @jiadongyao8083 2 года назад +3

      @@GrandpuhTy I ran into the same issue. Have you solved it?

    • @GrandpuhTy
      @GrandpuhTy 2 года назад +3

      @@jiadongyao8083 I haven't no, sorry. I just settled on adding them manually and haven't been working on anything recently to warrant writing up a script to automate it.
      There's another channel called Code, Tech and Tutorials that has a video on using multiple source files with VS Code. I think it might explain a way to do it, but its been awhile so I can't say for sure. I think that's where I got the idea of making a script to get all the paths and automatically make a command with them.

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

    Thanks, this tutorial helped me a lot. It was especially confusing for a first timer like me as the Include path in the Intellisense configuration file is not the same as the include path in the tasks.json that the compiler will search so I didn't know I had to do it in tasks.json as well.

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

    Holy shit THANK YOU!!!
    I was trying to figure out how to compile multiple files, I found something about the "Makefile Tool" or so, but it just wouldn't work, and the tutorials online to this "makefile" stuff never helped a lot. turns out all I needed were some modifications to the .json!!! Thanks!!

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

    Amazing boss! After 2 hours of trying only thisone worked

  • @yonlehman
    @yonlehman Год назад +8

    You don't need to add the .h files in the compile line. They are compiled as part of the file that includes them.

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

      I tried what you said. It doesn't work without them.

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

      @@jashangill4089 Me too I tried without .h it didn't work.

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

      Isn't because you guys didn't add the "include" flag (-I {fileDir})?

  • @omarashour02
    @omarashour02 2 года назад +9

    I've followed all the instructions In this video but still facing that error :
    (.text+0x35): undefined reference to `ClassName::memberFunction()

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

      Somebody knows how to repair it?

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

      same here. I did exactly as he explained but still not working

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

      did u fixed it bro, i met exactly your problem
      @@pinielchitare9221

  • @hassanbabaousmail194
    @hassanbabaousmail194 Год назад +6

    Thank you so much for this video.
    Is there a way to add the files automatically to tasks?

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

    Мля, этот ВСКОД вымораживает своими приколами :) СПС БРО за видос :)

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

    Thanks you so much for this video, problem solved !

  • @אורהארבל
    @אורהארבל Год назад +1

    Thanks allot for this video !! you saved me so much time

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

    Learning how to use VSCode better, dont care for the red back ground. Thanks for the video

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

    I had a problem compliing multiple files, but not for the reason in this video. My source files are all in the same folder & are being found. They will complie and run individually but won't compile together. It tells me there are multiple definitions. I spent so many hours trying to find, what I am sure is, a simple solution, I gave up and just combined the two files into one. All the problems went away.
    It would be better to have kept them separate as they are functionally almost independent, but trying to find out how to declare constants, variables and instances of library classes without getting multiple definitions was beyond my patience.
    It is a strange world where so much tech is brilliantly clever, but finding how to do something trivial & basic can be very hard and time consuming.

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

      Did you use header guards?

  • @אלעדר
    @אלעדר 9 месяцев назад +1

    But this way you have to manually type every folder you are using to the tasks.json file.
    Now what if you have a large solution with many folders and files?
    there has to be a way to do it automatically

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

    Thanks!

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

    wow, so useful for me, tks u!

  • @UtkarshKumar-l2j
    @UtkarshKumar-l2j Месяц назад

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

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

    Thaaaaaank you!

  • @wlw-fh7vo
    @wlw-fh7vo Год назад

    Thanks,really helpful

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

    Thanks that helped me out!

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

    👍

  • @睿-e6t
    @睿-e6t 5 месяцев назад

    when i cannot excute by just pushing run, but Okay at pushing debug

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

    Where .vscode folder come from??

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

      When you are selecting a folder and creating a txt file (whatever program language you made for that txt file) in that selected folder, .vscode folder is created.

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

    Go to ~4:20 for the answer. You're welcome

  • @KoolGamesHD
    @KoolGamesHD 2 года назад

    what does ur launch.json look like? mine is empty. When i run my code it says main.exe not in executable format.

    • @kingtutlearning
      @kingtutlearning  2 года назад

      This current version of vscode does not have launch.json. Just settings.json and tasks.json.
      Your task.json should have: "${fileDirname}\\${fileBasenameNoExtension}.exe" under -o in the argument bracket.

    • @KoolGamesHD
      @KoolGamesHD 2 года назад

      ​@@kingtutlearning mine already does but when i run it i get "program path is missing or invalid". and it says "open launch.json. My launch configuration has nothing in it.

    • @kingtutlearning
      @kingtutlearning  2 года назад

      @@KoolGamesHD I think this link might help you:
      stackoverflow.com/questions/71094494/trouble-debugging-vscode-configuring-json-program-path-is-missing-or-inval

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

    does this work for mac?

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

      Mac works differently. I never used VS Code on a Mac before.

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

      @@kingtutlearning I just figured it out. All you need to do is replace ${file} with ${workspaceFolder}/*.cpp and it works

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

      Awesome 👍

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

    Tried VS Code and didn't like it. Tried a few languages. Didn't work for me. Tried Python. What a mess. VS Code is totally unintuitive. The GUI is hoorrrriiible. Gave up on getting C++ working and went back to Visual Studio. Nice video though... but I doubt I'll waste any more time with VS Code.

  • @Master-bx4rd
    @Master-bx4rd 7 месяцев назад

    vsc is shit, no problems in CB