0% found this document useful (0 votes)
26 views10 pages

Guide

Uploaded by

duyhung160605
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views10 pages

Guide

Uploaded by

duyhung160605
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

EEET2601 – Engineering Computing 01

HOW TO INSTALL SOFTWARE DEVELOPMENT TOOLS


FOR C/C++ PROGRAMMING
Written by Linh Tran (2023)
Please follow one of the below installation instructions depending on the operating system
(Windows/MacOS) that you use.

WINDOWS
1. Install GCC toolchain
a. Go to this link: MinGW-W64-builds. Download x86_64 release-posix-seh-ucrt-rt with
latest version.

o After you download the file, right click on it and select “Extract Here” with WinRAR or
7-Zip tool to extract it. You will get the extracted folder mingw64 as below:

o Now, copy that folder to your C drive as below.


b. Go into the bin folder, duplicate the file mingw32-make.exe (by copying it then pasting
in the same place), then rename it becomes make.exe as below. It would allow to run the
make tool by the short name “make” later.

c. Copy the path of the bin folder. With the instructions above, the path will be
“C:\mingw64\bin” (it is fine if you copy it in another place with a different path but must
have no space characters in the path).

d. Add the above path to the Windows PATH environment variable so that gcc tool can
run without the full path in Windows Terminal (PowerShell and Command Prompt):
o In the search bar, search for “variables” and select “Edit the system environment
variables”.
o Select “Environment Variables”

o Under System variables area, select Path > Edit. In the Edit environment variable
window, press New and input path to the bin directory of our installed GCC tool. After
that, press OK in all windows to complete PATH setting.

e. Test the gcc tool to make sure that it is installed properly:


o Type powershell in Search bar to open PowerShell.
Note: close and reopen powershell if you are opening it while or before doing PATH
setting step above (so that it can be updated with the PATH setting).
o Type “gcc --version”. If it is installed correctly, you should see the result as below:

o Similarly, type “make --version”. You should also see it as below


2. Install VS Code and extensions
a. Download the VS Code installer for Windows. Double-click on the downloaded file to run
the installer.
b. Click on File > Auto Save to turn on Auto Save feature for all files (very helpful feature !).
c. Install C/C++ extension.
o Open VS Code. Click at the Extensions icon in the Activity Bar on the left side of VS
Code and search for "C/C++" in the Search box.
o Click on the Install button of the extension to install it

d. Install and use Code Runner extension for “click to compile and run” feature.
o Search for "Code Runner" in the extension search box and install it.

• Click on File > Preferences > Setting. Search for Code Runner. Scroll down to find and tick on
option “Code-runner: Run In Terminal” (will make the program to run in terminal when we
hit Run button to compile the code).

• Now, you will see a RUN button which can be used to compile and run your program.
3. Get familiar with VS Code
a. Close and re-open VS Code if it is opening while or before doing the PATH setting above.
b. Click on File > Add Folder to Workspace. Browse to/ create a folder where you want to save all of
your programs (e.g. D:\MyCodingSpace), and select it.
c. Create a new file namelly hello.c with example program as below

d. Copy the following code and paste it into your hello.c file:
#include <stdio.h>
int main()
{
int num;
printf("Enter an integer: ");
scanf("%d", &num);
printf("Got number = %d", num);
return 0;
}
e. Compile and run it in the terminal
o Click on Teminal > New Terminal to open Windows’ Powershell terminal.
o In the terminal window, type “gcc hello.c” to compile the hello.c file. By default it will
generate a.exe in Windows as a result (can type “ls” to see all files). Then, type
“./a.exe” to run the program. It should work properly as below:

f. Alternatively, you can hit the RUN button of Code Runner to compile and run your program
MAC OS
1. Install VS Code and extensions
a. Go to https://code.visualstudio.com/download to download the suitable installer for your
Mac computer. Click on the downloaded file to install it.
b. Click on File > Auto Save to turn on Auto Save feature for all files (very helpful feature !).
c. Install C/C++ extension.
o Open VS Code. Click at the Extensions icon in the Activity Bar on the left side of VS
Code and search for "C/C++" in the Search box.
o Click on the Install button of the extension to install it

d. Install and use Code Runner extension for “click to compile and run” feature.
o Search for "Code Runner" in the extension search box and install it.

• Click on File > Preferences > Setting. Search for Code Runner. Scroll down to find and tick on
option “Code-runner: Run In Terminal” (will make the program to run in terminal when we
hit Run button to compile the code).

• Now, you will see a RUN button which can be used to compile and run your program.
2. Install GCC toolchain
a. Install homebrew
o Go to https://brew.sh/ and copy the installation script

o Open the terminal, paste the script and run it

b. Install GCC toolchain from homebrew:


o Run command “brew install gcc”

o Check install success by “brew info gcc”

If the installation FAIL, type following commands:


rm -rf /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
brew tap homebrew/core

o As shown above, the gcc version 11 has been installed. Check again by command
“gcc-11 –version”
Note: You may get another version depending on the current time of installation. For
example, if you got version 12, type gcc-12 --version.
c. Create a symbolic link (shortcut) file for gcc.
On Mac OS, the default compiler is clang. Thus, to use gcc, we need to create a symbolic
link namely gcc which links to our actual gcc-11 file (so that we can just type gcc to use
our actual gcc version 11 tool)
o Check where the gcc-11 is installed
which gcc-11

Note: You may get /usr/local/bin/gcc-11 as the result, then it is in /usr/local/bin/


(some people may get another location, e.g. /opt/local/bin/gcc-11).
o cd to the location that you get above and list out content by flowing commands. You
should see gcc-11 file there:
cd /usr/local/bin
ls
Note: in “ls” and “ln” commands, l is L letter in lower-case (not i letter).

o Create a symbolic link file namely gcc g++ which links to our actual gcc-11
and g++-11 files as below
ln -s gcc-11 gcc
ln -s g++-11 g++
o Check again with “ls” command. You should see both files gcc, g++ (symbolic link)
and actual gcc-11, g++-11 file.
ls
d. Now, close and reopen the terminal, type “gcc --version” to check whether we have
successfully have configured it correctly or not. You should see it as Homebrew GCC (not
clang) as below:

e. Install Xcode Command Line Tools by running following command


xcode-select --install

f. Install make tool


o Check that you already have the make tool or not
make --version

o If you do not have it, install it through command


brew install make

3. Get familiar with VS Code


a. Create a new folder to store your codes, e.g. MyCodingSpace on your Desktop.
b. Open VS Code. Click on File > Add Folder to Workspace. Browse to that folder and select it.
c. Create a new file namelly hello.c with example program as below

Copy the following code and paste it into your hello.c file:
#include <stdio.h>
int main()
{
int num;
printf("Enter an integer: ");
scanf("%d", &num);
printf("Got number = %d", num);
return 0;
}
d. Click on Teminal > New Terminal to open Terminal.
e. In the terminal window, type “gcc hello.c” to compile the hello.c file. By default it will generate
a.out file as a result (can type “ls” to see all files). Then, type “./a.out” to run the program.
f. Alternatively, you can hit the RUN button of Code Runner to compile and run your program

You might also like