C++ Update – Gautier Rss, Shared and Static Build Makefiles

A few updates on the 2016 version of the GautierRss program which is also an example of a C++14 GUI from scratch. The previous articles were based on a single makefile that used static libraries. Those libraries were manually built into a specific directory visible to that single makefile. The capability to do a static link is maintained, but I decided to set up a second makefile that uses shared versions of the libraries available from the public repository for the Fedora Linux distribution (and presumably repositories for Ubuntu, SUSE and others). Using shared libraries has several advantages as does static libraries. With two build scripts to support either scenario, I gain a bit of flexibility depending on how the solution is deployed. With shared libraries, the program can receive updates to those libraries automatically (this is not always the case, but on principle can be a good idea). At the same time, two build scripts provide an opportunity to avoid a type of tunnel vision. Two scripts allow you to verify in reality that a code base can be built for different runtime scenarios and allows you to test those scenarios.

The screenshot below shows the output when using the makefile that links shared libraries to the executable. The item in green is the executable. The size of the program is shown to be 165KB. The items with the file extension ending in .o are the object files that are linked together to form the executable. You’ll notice something interesting about their sizes later on.

gautiercpp-20170111-buildflexibility-sharedlibrariesinput

The second screenshot shows the same executable built with the makefile that uses static versions of the library. This executable is largely self-contained and it shows somewhat in the size of the executable. It currently stands at 12.6MB. That’s not that large a file in a desktop program scenario. Notice that the object files are unchanged in size. That is because static builds are a function of linking rather than compiling.

gautiercpp-20170111-buildflexibility-staticlibrariesinput

An updated version of the code base has been published. One of the great things about GitHub is how it enhances the use of git source control. The following screenshot is taken from the current build shown in this article. I added operator overloading to the InteractionState class in order to simplify some of the code in the PrimaryDisplaySurfaceWindow class with a corresponding uptick in efficiency. The rest of the changes can be seen through the GitHub visualizer for this commit.

gautiercpp-20170111-buildflexibility-githubvisualizer

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s