Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Advanced C++

You're reading from  Advanced C++

Product type Book
Published in Oct 2019
Publisher
ISBN-13 9781838821135
Pages 762 pages
Edition 1st Edition
Languages
Authors (5):
Gazihan Alankus Gazihan Alankus
Profile icon Gazihan Alankus
Olena Lizina Olena Lizina
Profile icon Olena Lizina
Rakesh Mane Rakesh Mane
Profile icon Rakesh Mane
Vivek Nagarajan Vivek Nagarajan
Profile icon Vivek Nagarajan
Brian Price Brian Price
Profile icon Brian Price
View More author details

Table of Contents (11) Chapters

About the Book 1. Anatomy of Portable C++ Software 2A. No Ducks Allowed – Types and Deduction 2B. No Ducks Allowed – Templates and Deduction 3. No Leaks Allowed - Exceptions and Resources 4. Separation of Concerns - Software Architecture, Functions, and Variadic Templates 5. The Philosophers' Dinner – Threads and Concurrency 6. Streams and I/O 7. Everybody Falls, It's How You Get Back Up – Testing and Debugging 8. Need for Speed – Performance and Optimization 1. Appendix

About the Book

About the Authors

Gazihan Alankus holds a PhD in computer science from Washington University in St. Louis. Currently, he is an assistant professor at the Izmir University of Economics in Turkey. He teaches and conducts research on game development, mobile application development, and human-computer interaction. He is a Google developer expert in Dart and develops Flutter applications with his students in his company Gbot, which he founded in 2019.

Olena Lizina is a software developer with 5 years experience in C++. She has practical knowledge of developing systems for monitoring and managing remote computers with a lot of users for an international product company. For the last 4 years, she has been working for international outsourcing companies on automotive projects for well-known automotive concerns. She has been participating in the development of complex and highly performant applications on different projects, such as HMI (Human Machine Interface), navigation, and applications for work with sensors.

Rakesh Mane has over 18 years experience in the software industry. He has worked with proficient programmers from a variety of regions: India, the US, and Singapore. He has mostly worked in C++, Python, shell scripting, and database. In his spare time, he likes to listen to music and travel. Also, he likes to play with, experiment with, and break things using software tools and code.

Vivek Nagarajan is a self-taught programmer who started out in the 1980s on 8-bit systems. He has worked on a large number of software projects and has 14 years of professional experience with C++. Aside from this, he has worked on a wide variety of languages and frameworks across the years. He is an amateur powerlifter, DIY enthusiast, and motorcycle racer. He currently works as an independent software consultant.

Brian Price has over 30 years experience working in a variety of languages, projects, and industries, including over 20 years experience in C++. He was worked on power station simulators, SCADA systems, and medical devices. He is currently crafting software in C++, CMake, and Python for a next-generation medical device. He enjoys solving puzzles and the Euler project in a variety of languages.

Installation and Setup

Before you embark on this book, you will need to install the following libraries used in this book. You will find the steps to install these here.

Installing CMake

We will use CMake version 3.12.1 or later. We have two options for installation.

Option 1:

If you are using Ubuntu 18.10, you can install CMake globally using the following command:

sudo apt install cmake

When you run the following command:

cmake –version

You should see the following output:

cmake version 3.12.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

If the version you see here is lower than 3.12.1 (for example, 3.10), you should install CMake locally using the following instructions.

Option 2:

If you are using an older Linux version, you may get a CMake version that is lower than 3.12.1. Then, you need to install it locally. Use the following commands:

wget \

https://github.com/Kitware/CMake/releases/download/v3.15.1/cmake-3.15.1-Linux-x86_64.sh

sh cmake-3.15.1-Linux-x86_64.sh

When you see the software license, type y and press Enter. When asked about the installation location, type y and press Enter again. This should install it to a new folder in your system.

Now, we will add that folder to our path. Type the following. Note that the first line is a bit too long and the line breaks in this document. You should write it as a single line, as follows:

echo "export PATH=\"$HOME/cmake-3.15.1-Linux-x86_64/bin:$PATH\"" >> .bash_profile

source .profile

Now, when you type the following:

cmake –version

You should see the following output:

cmake version 3.15.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

3.15.1 is the current latest release at the time of writing this document. Since it is newer than 3.12.1, this will suffice for our purposes.

Installing Git

Test the current installation by typing the following:

git --version

You should see a line such as the following:

git version 2.17.1

If you see the following line instead, you need to install git:

command 'git' not found

Here is how you can install git in Ubuntu:

sudo apt install git

Installing g++

Test the current installation by typing the following:

g++ --version

You should see an output such as the following:

g++ (Ubuntu 7.4.0-1ubuntu1~18.04) 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.

If it is not installed, type the following code to install it:

sudo apt install g++

Installing Ninja

Test the current installation by typing the following:

ninja --version

You should see an output such as the following:

1.8.2

If it is not installed, type the following code to install it:

sudo apt install ninja-build

Installing Eclipse CDT and cmake4eclipse

There are multiple ways of installing Eclipse CDT. To get the latest stable version, we will use the official installer. Go to this website and download the Linux installer: https://www.eclipse.org/downloads/packages/installer.

Follow the instructions there and install Eclipse IDE for C/C++ Developers. Once you have installed it, run the Eclipse executable. If you did not change the default configuration, typing the following command in the terminal will run it:

~/eclipse/cpp-2019-03/eclipse/eclipse

You will choose a workspace folder and then you will be greeted with a Welcome tab in the main Eclipse window.

Now, we will install cmake4eclipse. An easy way to do this is to go to this website and drag the Install icon to the Eclipse window: https://github.com/15knots/cmake4eclipse#installation. It will ask you to restart Eclipse, after which you are ready to modify the CMake project to work with Eclipse.

Installing GoogleTest

We will install GoogleTest in our system, which will also install other packages that are dependent on it. Write the following command:

sudo apt install libgtest-dev google-mock

This command installs the include files and source files for GoogleTest. Now, we need to build the source files that we installed to create the GoogleTest library. Run the following commands to do this:

cd /usr/src/gtest

sudo cmake CMakeLists.txt

sudo make

sudo cp *.a /usr/lib

lock icon The rest of the chapter is locked
Next Chapter arrow right
You have been reading a chapter from
Advanced C++
Published in: Oct 2019 Publisher: ISBN-13: 9781838821135
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}