Editing and Compiling
Situation
use lab PCs,
use your laptop offline, and
use your laptop online to edit and run codes that reside in your
C Programs
: Suppose that you want to download, edit, and run the
code
Here, 3 options are described:
functions.c
(provided in Workshop Week 2).
to as
Note
personal folder on the university’s computer system. Your
folder has the name
uni’s will be referred
, and
: This document is short. If unclear, you should seek help from
H:
or starting with in this document.
H
H:
:
your classmates and tutors.
1
COMP20007.Worshop Anh Vo 10 March 2021
Command
cd H:
Option 1: using lab
PC (in labs only!)
Suppose you already downloaded now under Download folder
from LMS, and it is
Open that
Now change
Run
functions.c
in
as required and
terminal run:
functions.c
functions.c
jEdit
and use
Save As Save
to save to
H:
MinGW
, and in the
minGW
ls
gcc –o functions functions.c
./functions.exe
Note: In this way,
uni’s
functions.c
will be kept permanently on your
COMP20007.Worshop
Anh Vo 10 March 2021
folder
H:
. If you didn’t save to
H:
, the file will be automatically
use your uni’s folder as current directory (CDIR)
display content of CDIR, you should see functions.c
compile, produce functions.exe
run functions.exe
then, back to jEdit to change/save and then compile, run again.
deletted
.
2
Notes
Aim
Option 2: using your own laptop
: be able to edit and run C programs off
– already, skip 3 pages, to page 6.
line on your own laptop/desktop. Otherwise:
If you can do that
Make sure to have an editor (such as
y ,…
jEdit
) installed. You can use
an
editor skip this step if you already use
,
For
some other similar tool such as
to also mark
such as
,
,
Windows: make sure to install
Atom
emacs
jEdit
Visual minGW
Studio
Code
(
). When
or,
Cygwin
open
minGW
,
remember
installing
for installation. Note: if you installed
msys
:
_
minGW
.
ssh
bin
minGW
open_ssh
installation
manager
and
add
msys
:
already, run
to
(see next pages
COMP20007.Worshop
Anh Vo
11 March 2021
3
bin
This will allow you to use
scp
ssh
).
Case 2a: If you use a Windows laptop
Suppose you already downloaded
it your working directory (say. C:
Open that
Run
functions.c
functions.c
\
in
terminal run:
from comp20007)
LMS, and
put
MinGW
. In this
minGW
jEdit
Command
Notes
cd C:
cd comp20007
use your C:\comp20007 as current directory (CDIR)
ls
display content of CDIR, you should see functions.c
gcc –o functions functions.c
compile, producing functions.exe
./functions.exe
run functions.exe
then, back to jEdit to change/save and then compile, run again.
Note: In this way,
wrong happens to your laptop (oh, I didn’t mean that, just if
functions.c
will be kept in your laptop. If something
) your other precious works.
lose
c
and
all of
J
you will
functions.
4
COMP20007.Worshop
Anh Vo 10 March 2021
Command
cd
mkdir comp20007
cd comp20007
ls
Case 2b: If you use a MacBook
Suppose you already downloaded
opened it in
Then open a Terminal (
from LMS, and ) and run
gcc –o functions functions.c
./functions
functions.c
jEdit
ie
. run app
Terminal
display content of CDIR, you should see functions.c
compile, producing executable file functions
run functions
then, back to jEdit to change/save and then compile, run again.
Note: In this way,
wrong happens to your laptop (oh, I didn’t mean that, just if
functions.c
will be kept on laptop. If something
)
J
you will
5
lose
functions.c
and
all of
your other precious works.
COMP20007.Worshop
Anh Vo
10 March 2021
Notes
use home directory (/Users/your_name) as current directory (CDIR)
make a new directory
change CDIR to comp20007
now, on jEdit, use Save As to save in comp20007
Common for both Case 2a and 2b:
backup
your files using your
uni’s
H:
folder
uni’s
scp on your Terminal windows
functions.c your_uni_login_name@
(
scp
You can copy your file to your that you need to run command
folder and have a good backup. For
scp
dimefox
note:
driver. You can also copy the whole directory comp20007 using: cd ..
.eng.unimelb.edu.au
:
uni’s
.eng.unimelb.edu.au
–
r comp20007
your_uni_login_name@
dimefox
H:
:
server! And of
there is a colon : at the end). The file will be copied to your
You will have a copy of your valuable works in a
uni’s
course, if you use a lab PC you can edit and run these files directly
.
Note: server nutmeg
is a university server, after
edit/compile/run and debug your codes. You can also use
.
that
dimefox
scp
, you
can
login
into
to
instead of
dimefox
COMP20007.Worshop
Anh Vo
10 March 2021
6
Option 3: use your laptop to edit and run
programs in
uni’s
H:
directly
At first, note that you can copy files from your laptop to your
uni’s
COMP20007.Worshop
Anh Vo 10 March 2021
7
folder
H:
as described in the previous page.
Tools: 3a. connect to
Aim
Your
access the folder from anywhere (with an Internet connection, of course).
dimefox
/nutmeg, why?
: use your laptop/desktop to access the CIS’s servers
(or Note:
folder
nutmeg
)
and also
dimefox H:
access your
folder
uni’s
is a good place to keep your files. You can
uni’s
H:
After accessing
submit assignments, and use various
dimefox
, you can edit and run C programs,
usefu
. Some of these might be not
such as
available in your laptop.
l
tools for this course
make
valgrind
,
,
gdb
COMP20007.Worshop
Anh Vo 10 March 2021
8
Tools: 3a. connect to
dimefox
/nutmeg, how?
if you are not on
open Terminal (such as
first
)
ssh
then, your terminal will work with
Try some
VPN
terminal, or Mac’s
dimefox
uni’s
ground, make sure to run
minGW
Terminal
on the
Terminal
run:
login_name@
.eng.unimelb.edu.au
dimefox
.
unix
(list the content of current directory), (change current directory),
commands such as:
Sample session on dimefox:
ls cd cp
mkdir
for details),
cd
ls
echo Hello Linux > hello.txt
ls
cp hello.txt hello_1.txt
more hello.txt
ls
man cp
emacs helloworld.c
(copy files, run
(make new directory).
man cp
At home
: basic Unix
(use
commands if needed .
Google
to)
learn some
COMP20007.Worshop
Anh Vo 10 March 2021
9
Tools: 3b. Remote editing programs in
Aim
H:
, be able to
/
could be mastered quickly.
: Avoid time
from your laptop to
–
files remotely from anywhere.
consuming
filecopy dimefox terminal, using
H:
edit your
uni’s
: in
vim seems inconvenient,
Tools
/
etc. While
vim nano
emacs
nano
emacs emacs
and
hello.c on
y
Ctrl
Cut/Copy/Delete a chunk of code inside the emacs window:
terminal)
quick use of emacs
relatively simple and easy: just remember
(tr
’s for “Save”,
dimefox
Ctrl
–
a few times to exit from some mode/command if having troubles
–
–
s
Ctrl
x
–
Ctrl
–
c
for “Quit”.
x
Ctrl
to
– Ctrl
mark the start, paste the chunk
to
arrows
to expand,
to copy,
to cut,
–
Esc
w
Ctrl
–
w
Space
y
Undo:
ESC
how to use
Ctrl
Ctrl
emacs
–
–
u
x
more effectively and professionally:
https://www.digitalocean.com/community/tutorials/how
emacs
to
–
editor
–
–
use
–
the
–
–
in
–
linux
COMP20007.Worshop
Anh Vo
10 March 2021
10
FAQ
command not fou
minGW
or
you
–
.
: I got “
Why?
nd
” when trying
scp
ssh
just
missed
when
installing
. Now
it
need: When the full dialog box opens with a list of software components,
Installation
You
run
minGW
minGW
Installation
Manager
down to find, then right
click
“
msys
–
openssh
bin
”
and
click “
scroll
Mark for
– ”.
Click “
), then
window, now you can use
Installation
“
”.
and
” (top left corner
until installer prompts you with a message indicating completion.
Apply Changes
”, then “
Apply
Wait
Go back to your
minGW
scp
ssh
COMP20007.Worshop
Anh Vo 11 March 2021
11