Lab 0 - (Part 2) Lab Environment Setup
Lab 0 - (Part 2) Lab Environment Setup
Lab 0 - Part 2
Installing Necessary Tools
In this part, you will be installing IDEs and work with Git on top of your previous setup in Part 1 of this lab.
Simple editors
vim is a classic, highly configurable editor that comes with many Linux distributions. It’s a multi-
mode editor, meaning that you have to switch between modes (e.g., input, select, edit). It runs in the
terminal, all functions are controlled by keystrokes and internal commands, and vim can be customized
with plugins.
Sublime Text is a modern, lightweight, cross-platform editor highly customizable via plugins and with a
strong fulltext search.
IDEs
(Recommended) VSCode is a free IDE built by Microsoft, and has support for all major languages
(including C and C++). It also comes with built-in Git integration. Runs on macOS, Linux, and Windows,
as well as connection options to the lab Docker container.
CLion is a cross-platform IDE built by JetBrains specifically for C and C++ development. It helps you
with code navigation, generation, and refactoring. Students qualify for free licenses. Runs on macOS,
Linux, and Windows.
CLion works with CMake (an open-source system for managing the build process, comparable
to make ) to analyze and understand project context.
If you choose this option, you should import your project into CLion, so that it automatically
generates necessary CMake files for you. Please look this up for more details.
XCode is Apple’s official free IDE for Mac and iOS app development, and supports C and C++ (in
addition to various other languages). Runs on macOS.
Task
After installing, try it out! you can type fortune into your terminal to see a prediction for your semester, and
can use cowsay by typing cowsay "<some string>" .
cs300-user:~$ fortune
You will gain money by an illegal action.
cs300-user:~$ cowsay "What a strange fortune... At least I get some money!"
______________________________________
/ What a strange fortune... At least I \
\ get some money! /
--------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Of course, apt can also be used to install more serious programs, like vim or emacs .
fortune generates text, and cowsay can display text in a fun way. Is there any way to combine the two? Yes!
You’ll learn about how this works under the hood later, but data can be moved from one process to another
using something called a pipe. By putting the | pipe character between two commands, the output of the first
will become the input of the second.
Try it out by running:
If you cannot run fortune or cowsay after installing them, you may need to tell the terminal where to find
these programs by adding their location to the “PATH”. You can do this by running the following command:
$ export PATH=$PATH:/usr/games
Running ./cs300-run-docker --clean will remove any custom packages that you have installed. This is
because --clean removes any existing lab containers on your system.
Fortunately, you should be able to re-install your packages with apt using your new-found package
installation skills!
If you have custom configurations for your packages, (e.g., a .vimrc file for vim ), the configurations are
persisted even if you have used --clean . This is because user-specific configurations are stored in ~ (or its
sub-directories), which are just a mount of your [DEV-ENVIRONMENT]/home directory on your machine.
Git
Git is an awesome version control tool for your code. In essence, it allows you to continuously save your
project as a sequence of small changes instead of one final thing. Some of the cool things this grants you are:
There are a ton of resources out there to learn about Git, so we won’t try to recreate them. Instead, we’ll link
you to a few tutorials, and encourage you to find more on your own!
Before you start running Git commands, you’ll need to configure your name and email in Git.
Task
Within your container, set your name and email in Git.
If you are not already signed up to GitHub with your iut-dhaka.edu email address, add it to your profile so
that GitHub knows to correctly attribute commits to your username.
Optional: you can cache your GitHub credentials to avoid entering them in each time.
Task
Accept the GitHub Classroom assignment for the labs, then clone the repo into your container.
Labs: Set up CS300 Labs 2023
2. Clone the repo. Do this by going to the GitHub Repo link created by classrooms, and clicking Clone or
download. Copy the url in the box, and use it to clone like so:
… where YOURUSERNAME is your GitHub username. The above commands assume that you have registered an
SSH public key with GitHub; if you haven’t, try using https://github.com/cs300... instead of
the [email protected]:cs300-... URL.
Once you cloned the repository, you should see the lab directories in the labs repo.
Excercise
At this point, you have your version control set up. Let’s do a quick exercise to practice your newfound Git
skills. The results of this part of the lab are used for evaluation.
Inside the lab0 you should see a file hello_world.c . This is a Hello World program, and is the one you’ll
make changes to. To run the program you need to compile it first (we will cover compilation in detail in a later
lab). For now, just use the following commands:
Task
1. Modify the program so it prints the following tounge twister:
Oh, Shelley? She sells seashells by the shilling. Silly, selling Shelley.
2. Then, commit and push your changes.
You have now committed your changes to Git and they are stored in the version history ( git log should
show your new commit!). You’ve also pushed the new commit to GitHub’s servers.
So now you're all done and set for the exciting journey that awaits you in rest of the labs! Good luck!