Linux, C++, and Libraries like myHTML

Whenever you write c++ code for a project, have you ever wondered where the actual implementations for iostream’s << and >> operators are?  What about the implementations for all of the algorithms that are in the algorithm header? Whenever you’re building a project and linking in things from external libraries, where’s the compiled version of those functions?  The secret is in libraries of code external to your project.

Often times when coding, you may want to use libraries from third party sources other than the Standard lib.  One example is the MyHTML parsing library available on GitHub.  It isn’t just a header file that you include in your project and that gets built when you build your project.  It is meant to be built as an external library and used with static or dynamic linking.

Building MyHTML Library

Here’s an example walk-through of incorporating MyHTML parser into a project in the CSE 2341 Virtual Machine (tested with the Fall 2018 VM only).  All of the steps below are to be done inside the VM.

  1. Go to the MyHTML github repo and either clone the repository in your vm (git clone) or choose the download zip option. DO NOT clone it or download it to your repo for the class. If you download the zip file, unzip it.  For the purposes of the walk-through, I’ll assume you downloaded it to /home/student/Downloads.
  2. open a Terminal and navigate to the root folder of the myhtml library, probably something like cd /home/student/Downloads/MyHTML. The name of the MyHTML folder may be different… it could be something like myhtml-master.
  3. Type make and press enter.  This will build the library.  It built without incident on the standard VM for Fall 2018 CSE 2341.  If you’re using a different platform or have made significant changes to the VM, your mileage may vary. During the build process, you shouldn’t see anything that looks like an error.

Note that there is normally another command you’d use to “install” the library into the system include paths, but we aren’t going to do that right now.  The command is sudo make install.  However, we’re just going to use the lib from the MyHtml folder where you built it.

Incorporating MyHTML into your Project

When you build your project, you’ll need to tell QtCreator to build and link against the MyHTML library.

  1. In Qt Creator, right click on the project name and choose Add Library.
  2. In the Add Library Dialog, choose External Library then click Next.
  3. Next to Library File, click Browse.  Navigate to the lib folder that is inside the myHTML folder.  It is likely at /home/student/Downloads/myhtml/lib. Choose the file named  Click next and then finish to complete the addition.
  4. Wherever needed, you can include the myhtml api.h file #include <myhtml/api.h> and the compiler should be able to find it.

At this point, the example main method on the MyHTML github’s project page should build and execute.  If you create a new project to test myhtml in, don’t forget to add it to this new project as well.  However, you don’t need to do the build steps again.


Customizing Shell in your Terminal

I use  the terminal to do quite a bit on both my Mac laptop and Linux desktop.  Sometimes its easier to hammer out a shell command than it is find the right context menu or menu item to click to do something. On Linux, I use Guake Terminal and … [Continue reading]

Java – Exam Stats Example

This post is another in the series of small Java Programs and their evolution.  The scenario for the program today, Exam Statistics, is calculating a couple statistics for a set of grades entered by the user. You can see in the code below, I work on … [Continue reading]

Time for some Java

Let's take a simple program idea and refine it over the course of a few versions of the code.  The program we are writing is meant to print a box made of asterisks.  The width and height of the box is based on a value entered by the user.  For … [Continue reading]

Weimar 2018 – Photo Scavenger Hunt

Follow the Traces of History in Weimar Your Task: Find 15 of the following places and take a picture of your group in front of the historical monument. (Hint: don’t visit the places in the sequence they appear here). The Prize: Dinner with Dr. … [Continue reading]

Testing More than One Thing with Catch

In a modern piece of software, you wouldn't have tests for just one class.  You'd have exhaustive tests for all the functionality in your program.  However, it would be challenging to put all of the tests in one single tests.cpp file.   … [Continue reading]

Setting up Docker and MySQL

Docker is an application that simplifies the create/deploy/run software dev cycle by using the concept of containers.  A container is a way to package up an application and all of its dependencies. Do the following to get Docker installed and a … [Continue reading]

Spring 2018 Data Structures Prep

It is no secret that CSE 2341 - Data Structures - is a very demanding course.   The course requires a great deal of dedication and perseverance.  I have received a few requests about what to do over winter break in terms of review and prep.  This … [Continue reading]

Gearing Up for a taste of Data Science

Here are some things to do to gear up for getting a taste of Data Science in CSE 3330. Download and install R. You can download it from this link Download and install RStudio from this link. Scroll down to the bottom of the page to find the … [Continue reading]

SMU in Weimar 2017 Info

Some important/useful information for our amazing study-abroad trip this summer: SMU-in-Germany,2017 Student Handbook_3.30.16 SMU in Germany Orientation Meeting #1,2017 How to Order Train Tickets in Germany Travel Info Spreadsheet … [Continue reading]