C++ Compiler Installation Guide

 

This document provides a brief guide for installation of C++ compiler software on your computer.

 

Note that there is no audio in the Lesson #1 files except the “codelite_mac_install_more.mp4” file and the newer (2020 and later) files.

 

If you run into problems please check the following troubleshooting guide first:

 

Troubleshooting Guide

 

A C++ compiler translates your program from a source file (*.cpp and *.h) that a human can program and read into an executable file (*.exe) the computer can execute.  This file can be run on a computer without the compiler software.  

 

Many compiler packages have an integrated development environment (IDE) which provides a text editor for the source files and a menu which can be used to invoke the C++ compiler in addition to many other useful features.  I strongly recommend using software with an IDE since it's normally easier to use than operating the compiler from the command line.

 

It's important to install a compiler on your computer as soon as possible so you can start programming immediately.  The best way to improve as a C++ programmer is to frequently practice using a compiler on your own computer.  Furthermore, installation of a compiler can be tricky and time consuming so it's best to do it as soon as possible to avoid bottlenecks / delays.

 

 

Compiler Options

 

The following list provides some of the better C++ compiler / IDE software packages available for PCs.  Since the C++ programming language is a standard, a typical C++ program will be compatible with any of these options.  However, some C++ programs that rely on special functions such as 3D graphics and specific operating system functions will only work with some compilers.

 

Visual Studio 2022 on Windows is the recommended compiler for MECH 215 for all lecture sections. We will be using it for many of the on-line lectures and in some of the assignments.  The reason for this is because Visual Studio on Windows provides a wider range of libraries for multimedia (Windows SDK) and graphics (DirectX).  This compiler is also a more professional option than the more simple compilers such as CodeLite and Code::Blocks. Therefore, we recommend you use Visual Studio 2022 on Windows if possible for MECH 215.  If you can’t install Visual Studio, then you should use CodeLite or Code::Blocks on Windows.  If they don’t work then try one of the other options listed below.

 

If you have a Mac computer then you should install Windows 10 on it using Parallels Desktop (preferable) or Boot Camp.  This will allow you to install Visual Studio 2022 or CodeLite / Code::Blocks on Windows.

 

Using a Mac compiler (even CodeLite on Mac, etc.) is much less preferable since you won’t be able to solve some of the labs and assignments that use Windows multimedia and graphics libraries.  You will also find that many software packages used in engineering are only available on Windows, so it’s a good idea that you are able to use Windows software on your Mac.

 

I strongly recommend you install at least two options (e.g. #1 and #2) from the list below (one online and one offline compiler).

 

1. Online Compilers

 

This is the easiest option to get started since the software operates in the cloud and you don't have to install any software -- there should be no problems using these compilers on any computer / operating system you are using.

 

The main disadvantages compared to offline compilers (i.e. compilers installed on your computer) are: you can’t save your work, an executable file (*.exe) is not produced, and there might be some C++ functions that are not available (such as file I/O).  It's best to also install an offline C++ compiler (one of the options in the other sections below) since they have more features than an online compiler.

 

I've tested out the most common online compilers and these are the best options available in order of preference (1 and 2 are my top picks).  I recommend you learn how to use two of them in case one is slow or not working.  The first 5 options are interactive, so you can use keyboard input (cin, etc.) in the normal manner.  The other options you must put keyboard input into a separate “stdin” window first ahead of time before running the program.

1) http://cpp.sh

2) https://replit.com/languages/cpp

3) http://onlinegdb.com/online_c++_compiler

- select interactive console with this compiler

4) http://jdoodle.com/online-compiler-c++

- select interactive switch with this compiler

5) other good options (good but less interactive for keyboard input):

https://wandbox.org

https://coliru.stacked-crooked.com

http://www.tutorialspoint.com/compile_cpp11_online.php

 

Here is a video showing how to use each of the online compilers above:

http://users.encs.concordia.ca/~bwgordon/online_compilers_demo.mp4

 

Note in order to watch the videos on this web site you should right click (two finger click on Mac) on the link of the video and select “Save Link As …” on Google Chrome or “Download Linked File As ...” on Safari.  The file can then be opened and played with VLC.

 

 

2. Windows Compiler Software

 

The best compiler software options on Windows computers for this course are presented in this section.  Windows is the most popular operating system for engineering software.  Therefore, installing a Windows C++ compiler is preferable (if possible) even if you have an Apple Mac / OSX computer.  This approach for Mac users is covered in section #3.  

 

A) Visual Studio 2022 

Visual Studio is the most popular C++ compiler used in industry for Windows and it's actually a very good compiler. Make sure to use Visual Studio Community version 2022 for this course for compatibility with the lectures. Note that the Visual Studio Community compiler is free and is essentially the same as the full professional version with the advantage that it takes less disk space.  Here is a short video below that shows how to setup and use Visual Studio.

http://users.encs.concordia.ca/~bwgordon/visual_studio_2022_installation.rar

Note that in order to watch this video you need to first download the rar file.  Right click (two finger click on Mac) on the link of the file and select “Save Link As …” using Google Chrome or “Download Linked File As ...” using Safari.  Then expand the rar file (using WinRAR, etc.) and play the mp4 file using VLC player.  If you don’t follow these steps the videos may not completely work or have sound.

 

Here is the text file used in the video.  It can be opened with notepad, notepad++, a word processor, etc.

 

http://users.encs.concordia.ca/~bwgordon/VS_studio.txt

 

Here is a short follow up video showing how to use Visual Studio and change the settings so it’s easier to use for C++ programming.  The video is for Visual Studio 2019, but it will work with the 2022 version too.

 

http://users.encs.concordia.ca/~bwgordon/visual_studio_2019_settings.rar

 

B) CodeLite

 

CodeLite is a good simple C++ compiler for Windows.  Make sure to use version 14.02 for this course for compatibility with the lectures.  Here is a video below for CodeLite installation.

 

http://users.encs.concordia.ca/~bwgordon/CodeLite_14.02_installation.rar

 

Here is the text file used in the video.  It can be opened with notepad, notepad++, a word processor, etc.

 

http://users.encs.concordia.ca/~bwgordon/CodeLite.txt

 

Here is a short follow up video showing how to use CodeLite and change the settings so it’s easier to use for C++ programming.

 

http://users.encs.concordia.ca/~bwgordon/CodeLite_14.02_settings.rar

 

 

C) Code::Blocks

 

Code::Blocks is a very good alternative to CodeLite. It also may be easier to install if you have problems installing CodeLite. Make sure to use version 17.12 given below. I’ve noticed the newer version 20.03 currently has a bug. Here is the installation video below.

 

http://users.encs.concordia.ca/~bwgordon/codeblocks_17.12_install.mp4

 

http://users.encs.concordia.ca/~bwgordon/codeblocks_17.12_mingw_nosetup.rar

-- use this rar file with the above video

 

Note in order to watch the videos on this web site you should right click (two finger click on Mac) on the link of the video and select “Save Link As …” on Google Chrome or “Download Linked File As ...” on Safari.  The file can then be opened and played with VLC.

 

Note that Code::Blocks is available on the ENCS lab computers, Linux, and Mac OS so if you know how to use Code::Blocks on Windows you can easily write programs for Linux or Mac OS using Code::Blocks on those computers.

 

  

3. Installing Windows on Apple / Mac (OSX)

 

The compatibility of Visual Studio / CodeLite (and many other engineering software packages you will use in the future) is better with Windows.  Therefore, I recommend you first install Windows on your Mac if possible and then install Visual Studio / CodeLite for Windows following section #2 above (after you install Windows).

 

For this option, I strongly recommend the most recent version of Parallels Desktop since this approach is the easiest to install (much easier than alternatives such as Boot Camp).  The price is only about $50 for students.  This is a very reasonable price considering you can efficiently run 99% of Windows software (including video games).  There’s also a full featured free trial you can use to see if the software is compatible with your computer.

 

http://www.parallels.com/products/desktop/

 

https://www.parallels.com/products/desktop/trial/ -- free trial

 

https://www.parallels.com/ca/landingpage/pd/education/ -- student edition 50% off

 

Here is an alternative link for the student / educational edition

https://onthehub.com/ -- look for Concordia University, ECS option, parallels desktop

 

https://www.youtube.com/watch?v=ARQ4sCyBsmk -- good installation video

 

http://www.pcmag.com/article2/0,2817,2473278,00.asp

 

https://www.zdnet.com/article/parallels-desktop-15-for-mac-is-the-best-way-to-run-windows-linux-and-macos-on-your-mac/

 

Note you need a copy of Windows to install with Parallels Desktop.  During Parallels installation it will allow you to automatically download an unregistered version of Windows you can use for free (see the installation video above).  You should turn off Windows updates after installation to avoid problems.  I also don’t recommend using an internet browser in Windows other than to install software from well known sources.

 

Note you will need to allocate 40 - 50 GB of disk space for Windows 10 in Parallels Desktop in order to run both the operating system and Visual Studio compiler properly.

 

Note when using CodeLite with Parallels Desktop you can’t put the CodeLite workspace / project folder for C++ programs on the Mac desktop or in any Mac folders.  It has to be in a Windows folder otherwise the following error will occur “UNC paths are not supported”.  Try making the CodeLite workspace / project in a folder on the windows c:\ drive.  Use windows explorer and right click and make new folder.  Make a folder there named my_codelite.  Then run CodeLite and make a workspace / project in that folder. You might also try just copying / dragging an existing workspace folder to the c: drive in windows explorer.

 

 

4. CodeLite for Apple / Mac (OSX)

 

This section describes how to install and use CodeLite for Apple / Mac (OSX).  However, the compatibility of CodeLite (and many other engineering software packages you will use in the future) is better with Windows.  Therefore, I recommend you install Windows on your Mac if possible (see section #3 above) and use CodeLite for Windows.

 

CodeLite can be downloaded from this link (get the most recent Stable Release):

http://downloads.codelite.org/

 

I don’t recommend Xcode unless you have trouble getting CodeLite to work.  CodeLite is simpler and requires much less disk space.  Another big advantage is that it's available on Windows (including ENCS lab computers) and Linux so if you know how to use CodeLite on the Mac you can easily write programs for Windows (and in the encs labs) or Linux using CodeLite on those computers.

 

Here is video showing how to install CodeLite on the Mac:

http://users.encs.concordia.ca/~bwgordon/codelite_mac_install.mp4

 

Note when running programs with the CodeLite compiler you need to select “Rebuild Project” from the Build menu before selecting “Run”.

 

Note in order to watch the videos on this web site you should right click (two finger click on Mac) on the link of the video and select “Save Link As …” on Google Chrome or “Download Linked File As ...” on Safari.  The file can then be opened and played with VLC.

  

Normally there are no problems that occur during installation.  The most typical problem that might occur is either the OSX command line tools are not installed (CodeLite needs them) or CodeLite can’t find the OSX command line tools.  The following video shows how to solve these problems:

http://users.encs.concordia.ca/~bwgordon/codelite_mac_install_more.mp4

 

Note: the new version of CodeLite has the infamous “plus button” I’m referring to at time 5:12 in the above video.  Use that plus button to add the compiler.

 

 

5. Xcode for Apple / Mac (OSX)

 

If the suggestions above don’t work on your Mac then you can try installing Xcode which is the most well know compiler for Apple computers.

https://apps.apple.com/us/app/xcode/id497799835?mt=12

https://developer.apple.com/xcode/ -- note you use this link if the app store Xcode download doesn't support your older version of OSX.  This video shows how to select the appropriate version of Xcode (same as finding command line tools)

http://users.encs.concordia.ca/~bwgordon/codelite_mac_install_more.mp4 -- the relevant video starts at time 1:25.

 

Here is a video that shows how to make a project with Xcode:

http://users.encs.concordia.ca/~bwgordon/xcode_project.mp4 -- note: there’s no audio

 

If the installation above doesn’t work then you should use an on-line compiler for now.

 

 

6. Linux

 

CodeLite is the best option in my opinion for Linux.  It can be downloaded from this link (get the most recent Stable Release):

http://downloads.codelite.org/

 

Note when running programs with the CodeLite compiler you need to select “Rebuild Project” from the Build menu before selecting “Run”.

 

CodeLite is simpler than other options and works well.  A big advantage is that it's available on Windows (including encs lab computers) and Mac OS so if you know how to use CodeLite on Linux you can easily write programs for Windows (and in the encs labs) or Mac OS using CodeLite on those computers.

 

Note if you are using Mint Linux and some other distributions you can find CodeLite by searching in the software manager (search for codelite).  When running CodeLite the first time select the gcc compiler in the initial setup.  The g++ package should also be installed in the software manager.