Code Coverage Of Unit Tests Using Qt 5 On macOS

Qt Library

Qt Framework

I was inspired while watching a talk by Kevin Ottens about refactoring OpenGL code in Qt to take a look at gcov & lcov. gcov is used to analyze code coverage – which lines of code have actually been executed while running an application. lcov is a tool that can produce HTML reports from the gcov output.

If you have a suite of unit tests that you run on your code, you can use these tools to see which the lines of code are covered by your tests and which are not.

I couldn’t find a decent primer on how to set this up properly for my Qt projects on macOS so I could run it from Qt Creator, so I thought I’d write up how I did it.

Continue reading

Packaging a Mac OS X Application Using a DMG

I learned early on in my software career that packaging up a release of an application can be a real pain. Not only is it time consuming, but it is quite easy to forget a file or miss something when there are so many steps involved and you have to do it frequently. The solution to this is to automate the process. Putting together scripts to package up a release helps avoid missing steps and speeds up development and deployment of releases and updates.

One of the challenges of automating this on Mac OS X is figuring out how to script the creation of Apple disk image (DMG) files. Getting the arguments to hdiutil correct can be quite a challenge! In this post, I’ll give an example of a script I use to do the following:

  • Copy all the necessary files to a staging area
  • Strip and compress the executable files and libraries
  • Create a DMG of the correct size for the release
  • Add a link to /Applications to the DMG
  • Add a background to the DMG so when it opens up your company logo or application graphic appears
  • Check the background image’s DPI to ensure it is 72. Fix it if it’s not.
  • Resize the window and icons, and position items in the DMG so when it opens everything is in the right place
  • Create a final, compressed DMG

Packaging An Application Using a DMG

Packaging An Application Using a DMG

Let’s take a look… Continue reading

Compiling OpenCV On Mac OS X 10.6

A couple of years ago I needed to do some basic image processing and found OpenCV. OpenCV is a BSD-licensed library for digital image processing which implements several hundred computer vision algorithms. Unfortunately compiling it on the Mac was not straightforward—requiring Fink or MacPorts—and the one existing Mac framework was out of date and no longer maintained.

OpenCV Library

OpenCV Library

Fast forward to last week. I had another requirement for some image processing magic and I thought I’d check out OpenCV again. What a difference! It’s now really easy to compile and use on the Mac. I didn’t find a writeup online on how to compile on the Mac—the one on the OpenCV site is out of date—so I thought I’d write up a short summary for future reference and any Googlers out there in internet land.

Here’s how I did it…

Continue reading

Point Cloud Library on Mac OS X: A Build Diary

I’ve been using and contributing to various open source projects for almost 20 years. I love the fact that we can leverage each other’s work and help other developers save time instead of reinventing the wheel or fighting the same problem a thousand times over. Open source tools and libraries make what I do possible.  Whenever I use open source, I like to compile from the source so I can contribute back to the projects – even if only little patches for fixing compilation warnings, clarifying error messages, or adding to documentation.  I used to enjoy configuration and build challenges – such as tweaking and compiling my own Linux kernels – but that’s behind me now.  I just want things to work.

I’m a solo developer working on a commercial cross-platform Mac OS X/Windows application.  This means that I have to be careful how I allocate my development time since I also have research to conduct and a business to run.  Part of this is maintaining control of my development “ecosystem”.  The more moving pieces there are – tools, 3rd party libs, etc. – the more overhead, and the less time I have for actual development.  Keeping it simple means saving myself a lot of time.  It also makes it quick and easy to bring short-term contractors on board.

I started to investigate open source tools for processing point clouds for a future version of my software – I want to handle scan data from FARO and Leica scanners.  I quickly zeroed in on the Point Cloud Library which is a BSD-licensed library to read, visualize, manipulate, and process point clouds. It looks like exactly what I need and includes a bunch of capabilities I don’t understand in the least, but seem like they might be useful in the future as I learn about it. Most of the capabilities are too advanced for me to contribute much to them directly, but I thought I’d be able to contribute “around the edges”, so I wanted to build it from source.

Point Cloud Library

Point Cloud Library

This article is a blow-by-blow account of the steps I took while trying to build the Point Cloud Library (PCL) on Mac OS X 10.6 starting with the information from PCL’s Compiling from Source page. The first thing I tried to do is build and link PCL with only the mandatory dependencies. After that, I’ll want to look at the optional pieces and build them if I need them.

As I was working through it, I put together notes for myself on what I did in case I had to do it again or have a contractor do it.  As with most other things I have on this site, I thought at least one other person might benefit through the power of Google, so I decided to put the notes up here verbatim.  Knowing what I know now, I could shorten this dramatically into “Steps to Build PCL on Mac OS X” [even though I haven’t been successful yet], but I decided it might be interesting to show the action-packed sequences of what actually happened…

I hope this is taken in the spirit it’s intended – documentation of some of the problems just getting PCL to configure and build, along with what I hope are some constructive recommendations [at the end of this voluminous tome]. [Warning: I get a little rant-like in the last commentary section – it’s not directed specifically at the PCL, but software development projects in general.]

I have to point out that the PCL guys have been great, answering my initial question quickly, and they’ve been encouraging [so far – hope they still are after this!]. This doesn’t always happen in open source projects, so it’s great to see. They deserve a lot of credit for their work, which is of great value to many  developers and companies worldwide.  All the developers and supporting companies are super-awesome for making this library available as open source. Very much appreciated!

[If you want to skip the gruesome details – don’t forget they’re action-packed! – I list some bugs and recommendations near the end.]

So… here we go!

Continue reading

qmake and the Info.plist File

I use the Qt library and qmake to build my bloodstain pattern analysis software. qmake is a great tool for cross-platform development because it lets you use one relatively succinct description [a .pro file] to generate Xcode projects, MSVC projects, and makefiles. On the Mac OS X side of things, I use one qmake .pro file to generate three xcode projects: release, beta, and demo. My directory structure looks like this:

Example File Structure

Example File Structure

Overall this works well, but there’s an issue with the Info.plist file.

Continue reading