last day (25 days later) » 

16:39
so what to do next?
Alright I'm not sure if I can remember all the steps b/c I did that almost a year ago but let's go on.
What's the problem?
I launched ubuntu and it shows this^
Oh I think there's something you have to enable before installing WSL. Did you check that link?
It says: Open powershell and then:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Then restart your computer
it shows this error @aderchox:
@Archer Did you open PowerShell as an administrator?
16:49
@aderchox no. Then I did and restarted.
What next?
I'm not sure what you did. Did you enter the above script in PowerShell successfully and it did run without errors once?
yes
then it prompted to restart, and I restarted.
Alright, now recheck and see whether the WSL's error is gone or not
if it's ok, then run this to see the version of the gcc installed on it:
@Archer gcc --version
@aderchox it says "installing...this may take a few minutes"
16:54
@aderchox I cant understand this part^
it says there's a certain pattern that your username must obey
maybe if you de-capitalize the entered name you can get rid of this error
done
now we are here:
or if it still doesn't work, or you really want the capital A, enter Archer --force-badname
@Archer ok
Have you used a terminal like bash before?
16:58
no
idk what a terminal is :(
This black box is a terminal
This is where you can talk directly to your OS. When you click on things, a command is generated and sent to OS, but here, you take the shortcut. No GUI. It's using things with text.
okay
Now your WSL installation is done. You actually have a legit Linux system inside your Windows OS!
You can go for vscode installation
17:01
@aderchox done
Now you have to choose the terminal of vscode
how?
Wait a second
Click on this:
and then choose 3rd item
Set Default Shell
Oh and before doing this
@aderchox where is this?
CTRL + `
view (from top menu) --> Terminal
17:06
@aderchox done
then choose 3rd item
yeah done
then?
above the vscode a drop down menu is opened, right?
yes
Do you see "bash" among options ?
(That's the name of the Linux terminal you installed)
17:09
@aderchox I see WSL bash
Yeah choose it
done
WSL is just a fancy acronym for the Linux developed by Microsoft. (Windows Subsystem for Linux)
@Archer alright now run this command and tell me the result:
gcc --version
@aderchox where to run it?
open your terminal again from view->terminal
then it must be bash
then run this command
17:12
here:
gcc : The term 'gcc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ gcc --version
+ ~~~
+ CategoryInfo : ObjectNotFound: (gcc:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
can you send me a screen shot instead? I suspect this is not bash
Ok it's not bash. Look at the bottom right corner of the image. It's Powershell. Powershell is not bash. Powershell is the terminal of Windows. Open it and check if it has bash in it.
it doesnt
A reload of vscode might help and let me know in case it doesn't.
You're sure you set bash as default terminal, right?
Maybe there's an additional step that I can't remember. I'll search it now.
17:20
@aderchox ^
Cool :)
ok, then?
So gcc didn't come pre-installed on your Linux when you installed WSL. You need to @Archer install it yourself. It's as easy as typing this command inside your WSL: sudo apt get install gcc. But please notice that if you're using data of your phone, it is going to download gcc for you and might become expensive. If that's not the case, just go on and install it.
GCC is one of the most famous compilers of C++.
@aderchox I have to do C programming not C++ ...
@Archer it does both
17:26
@aderchox I enter the password of ubuntu then it says:
E: Invalid operation get
@Archer Is that the only error it gives?
yes
@Archer ok
run this first
sudo apt update
Then tell me if the error persists
@Archer Actually it does much more than both C & C++ :D Quote from GCC official website: "The GNU Compiler Collection includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D, as well as libraries for these languages (libstdc++,...)."
Cool !
Error gone.
Yeah
Nice
Now hopefully your gcc is getting installed ?
17:34
yes
Mind if I ask why you want to do C ? Nothing wrong with that. Just asking out of curiosity since I'm a student as well.
@aderchox Fresher in college
And we have a course called computer programming
The language used in that is C, that's why.
Otherwise, I know java.
@aderchox Are you from India?
@Archer Great, C rocks because sometimes you have to count bytes!, and thus will help you get an intimate feeling of how things work under the hood in your machine. But I just used it to get familiar with programming, then I left it for other "nicer" languages like C++ and Python.
@Archer No I'm from Iran.
@aderchox Cool.
Installed @aderchox. What should I do next?
Now gcc --version and let me know if it works
(Make sure you're inside bash and not Powershell)
17:46
Response:
cc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Ok, now
open your wsl and run this:
code .
(notice the dot in the end)
wait wait wait
before running that command, go to the directory where you want to keep your source codes, then hold shift and right click on somewhere (inside the window of that folder) and then choose: Open Linux Shell Here
Then run this command: code .
@Archer It must take a while and then open vscode... done?
18:02
oh sorry, had to go somewhere
back now.
@aderchox What do you mean by this? Which directory?
no worries
In BlueJ I usually created projects and saved their folders on desktop.
By directory I mean "Folder"
Go to the folder where you want to keep your source code files.
Desktop? Is that fine?
Yup
Just like me :D
18:05
:D
Ok I am on desktop
What next?
Shift+Right click somewhere
but wait...
do you main in a folder inside Desktop, or just bare Desktop ? :))
I meant to say I keep my files in a "folder" on my desktop!
@aderchox yes, okay. Created a folder XD.
Ahaha
Ok open this folder in a new window
done
then shift + right click somewhere inside that folder (inside the windows of that folder to be more precise).
then choose "open linux shell here"
then when wsl gets opened, run this: code .
18:10
@aderchox I get a windows security alert
Should I click "allow access"
Yes I suppose
ok done, ran code . , what next?
it will install something and then opens vscode for you
ya,then?
@Archer now it's hard to say in words, please send a screen shot if that's possible.
Let me explain something if this seems a bit cryptice to you. What Microsoft has done is that, by giving you the WSL, they have given you a real "linux" OS. Now just the same as any other OS, you need to have access to your files, right? For example, you need to be able to access your Windows files inside your WSL Linux. So how have they done it? They've mounted your whole Windows OS on the WSL Linux machine for you! You can think about it like this: Assume your whole files on Windows are in a
USB flash, and then you connected it to your WSL Linux!
For example, you can see all your Windows drives if you run ls /mnt
I hope I've not confused you more. But it's very easy and things will become much more clear as soon as you learn a bit about Linux and command lines and stuff like that.
18:16
OK.
Okay, do you see the bar on the left?
Under "Explorer"
yes
and more precisely, under C[wsl...
Ok?
that's your "workspace", which is a fancy word for the folders you want to have open when you're coding. Currently, you've just opened that folder you created on your desktop.
18:18
Ok.
add an arbitrary file in that folder and you should see it here I think
yeah i can
Now take your mouse pointer on the part which says "C[WSL: Ubuntu-18.04]"
and then you'll see some icons, one of them is for creating a new file.
create a new file and name it "helloworld.c"
or "archer.c" or whatever :)
then paste this inside that file:
#include <stdio.h>


int main(){
  printf("Hello World, From Archer!\n");

  return 0;
}
It says "The C/C++ extension is recommended for this type of file."
Yeah yeah yeah
Absolutely
Install that as well.
18:21
installed
ok
created the .c file as well? (I said above)
yes
Now here's two or three things you need to do just once and then you'll be fine
create another file too, name it: tasks.json
What to do about this:
Insiders version 0.26.3-insiders is available. Would you like to switch to the Insiders channel and install this update?
then put this content in it exactly and save it:
{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "shell",
      "label": "g++ build active file",
      "command": "/usr/bin/g++",
      "args": ["-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
      "options": {
        "cwd": "/usr/bin"
      },
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}
@Archer No ignore that
(insiders are the ones who get volunteer for using newer versions of softwares which are buggy to tell the developers about the bugs.)
18:26
@aderchox done
Okay, now go to your .c file
and hit these keys together:
CTRL + SHIFT + B
then tell me what you see
C/C++ gcc build active file
Send a screenshot please
yeah choose that no problem
18:32
Executing task: /usr/bin/gcc -g '/mnt/c/Users/
Congrats. You just built your C code!
Now you need to run it.
How?
you see a plus(+) sign above your terminal. Right? Click on that
done
then it should give you a new terminal instance. Then run the "ls" command in there. This command will show you the list of your files. For example, if you named your source code "foo.c" you should see two files, "1.foo 2.foo.c". Tell me if they exist.
@Archer LS
but not capital
18:36
ok
yeah it does give 3 files.
helloworld helloworld.c tasks.json
LS stands for "List". And Lists the files in directories. (Directory is the linuxy name for "folder")
Ok, the one without the .c postfix is your program!
You can run it from Linux shell using this command:
"./helloworld"
(without the double quotes around it)
it worked with the double quotes...
:)
Okay it did that for you :)
@aderchox Unlike bluej for java, this seems like a lot of work ... What all has to be done everytime I code?
No, from now on you will just:
1- create a .c file
2- CTRL+SHIFT+B
3- get a terminal
4- run your program (e.g.: ./foo)
done
18:40
get a terminal?
The plus sign step, remember that?
(+)
You don't even need to have vscode open when you want to run your program. You can just open WSL in the folder where you keep the source code and the program, and then run ./foo
the + sign step is long.
You mean it's boring?
yeah, I mean when i have too many files, all of them will show up.
No no no
you don't need to run "ls" everytime!
That was just one time
18:43
oh
I wanted to show you your files!
You can skip that step always. AND you'll usually do!
Plus
I never click on that + sign either. Because I've assigned that a shortcut key on my keyboard :))
@aderchox how to do that?
Have you done any C in your course yet?
Nope, course will start from 5th jan.
I know all the stuff that will be taught in it. But the problem is I know all that in java, not in C.
@Archer Oh trust me you'll be too prepared for that :D
Having a good environment for C matters a lot.
@Archer Just go to:
File -> Preferences -> Keyboard Shortcuts
18:47
OK
In case you don't have it already, would you please install AnyDesk (anydesk.com/en) and let me do some stuff for you on VSCode, it's waaay easier than typing all of it. :)
And please don't panic! It's completely famous and safe.
@aderchox Yeah I have used it before. And I generally use TeamViewer.
501 741 470
19:05
Look
yes?
I think I was taking the exact steps written in the manual (code.visualstudio.com/docs/cpp/config-wsl)
but for some reasons your debugger did not install
I think if you search the errors you'll get it working real quick, I just didn't want to do it on the anydesk session. You know
@aderchox which errors
19:07
Didn't you see the message that popped out when I clicked on Debug?
Give me the anydesk again please
ok
501 741 470
says "connecting"
i accepted twice
IDK what's wrong with it
Let me restart it :)
19:40
thanks man!!!! That was a lot of work!!!
No sweat buddy.
Here's also a very good course for C: cs50.tv/2014/fall
And Good bye if you don't have any other questions?
@aderchox yeah I saw :D. Are you in uni?
Yes :)
which year?
last year
Great, wish you a lot of success on your way.
19:44
Thanks and bye. Cya!
Can I ask for your help when I had Java question :) ?
Maybe an email or sth? Just in case.
@aderchox ya sure tho I am not a master at it in any way man. I did it in last 2 years of schooling as per their syllabus.
Aha.. I see.
Ok, is it night there?
Yeah. It's 1:15 am already
19:46
@aderchox Good night, and delete this one XD.
@aderchox Your email tho? I'd definitely need help in C I feel.
Me definitely a non-expert in C as well, but I'll help if I can.

  last day (25 days later) »