Using Qt for Cross-platform Development – Building Grbl Controller

GrblController is built using the Qt framework. Building for most platforms is straightforward except for Mac OSX 10.5 32 bit (Core Duo).

Qt Basics

Qt is a cross-platform development system and libraries developed by Nokia for creating mobile apps but also desktop applications. For our purposes, we only care about the desktop app capability. You must be able to code in C++ to develop in this framework. In addition, Qt provides a simplified safe multithreaded event messaging system using “signals and slots”. If you plan on writing a windowed application with more than just the main window (i.e. settings dialog, worker thread, etc.) you should become familar with how signals and slots work, otherwise your app stands a very good chance of crashing for unknown reasons.

Qt Desktop supports Windows, Mac and Linux (Ubuntu, Debian and others), not any of the embedded or mobile varieties (even though they are typically included in the Qt development install.

Versions

GrblController will compile under various versions. It has been tested on Qt SDK 4.7 but currently is being compiled with version 4.8 on the three platforms. Update: The latest code also compiles and runs with 5.0.2 (tested under Ubuntu).

Static Build Issues

The ideal is to have a single executable with no dependencies of special libraries. These instructions will focus on the dynamic build approach because (a) the Qt Creator IDE is already setup for dynamic builds and (b) you don’t have to build the static libraries from the source yourself, which can be a herculean task. Unfortunately, using dynamic builds means that you need to distribute some helper libraries with your application, which can balloon the size of your distributable by over 10 MB.

Installers for your application

Qt provides a basic install-making tool to distribute your application, however, other installers can be used.

Compilers

Qt can leverage existing compilers or use open source, so for example, it can use XCode on the Mac or g++, likewise, it can use Visual Studio on Windows or g++/mingw.

Mac: Libraries vs. SDK

You have the option to install the libraries or the SDK (this is due to the way the Mac works) – Windows or Linux are simpler in that you just install the libraries (aka the SDK). On the Mac, libraries are automatically placed into a specific location and are used for building your app usually via a makefile, whereas the SDK allows you to install a small range of library versions into a user-chosen location along with Qt Creator and Qt library source. Qt Creator  automatically detects the libraries that were installed via the SDK. The Qt library source can be used to create static libraries. Use the Qt Creator that comes with the SDK, don’t install the standalone Qt Creator.

What I have discovered is that it is difficult or impossible to create 32 bit compiles with the 64 bit tools (even though the documentation implies it is possible). The only option that worked was to install the 4.7.3 carbon libraries off the Nokia ftp server and create a makefile from your pro file (instructions later in this document). Running the makefile allows you to create a 32 bit executable for older Macs. I have not been able to create PPC builds, only Intel, but PPC should be possible if additional libraries are installed. The “carbon” libraries are those specifically compiled for 32 bit Mac OSX. I include the 32 bit build option here because I assume some people may have older Mac Minis or laptops that they are ok with using in the shop near their CNC.

 

Installing Qt (Windows/Mac/Linux)

Building Linux

Building Windows using MinGW

Building Mac

 

 

2 thoughts on “Using Qt for Cross-platform Development – Building Grbl Controller

  1. I downloaded the Nokia QTSDK, installed github locally, migrated the grblhoming files from github, and was able to build Grblcontroller and run in within QT on my Win7 X64 system. But….

    - I cannot connect to the Ardunio duo – the GrblController error message are as you would expect if the cable was not connected. Windows can see the USB device and installs a driver.

    - If I try to run the Grblcontroller.exe (both debug and release) I get a system errror message “The program can’t start because QtCore4.dll is missing from the computer. Try reinstalling the program to fix the problem”.

    I’m sure I skipped over some really important step and I’m now lost in the weeds. I assumed that running the exe would bring up the installer (is this correct?)

    -Andy
    .

  2. Ignore my question about installers. I see you covered that above with “static and dynamic builds”.

    After I stumbled though the dll issues (there are 4 requried), it look like it just doesn’t build correctly with the Nokia. Not sure if it’s meanigful, but during build there are 5 warnings about the possibility of uniitialized variables. When running with QtSDK or as a dynamic build, there is no usb communication with the Ardunio. One hint may be that the COM Port drop down has nothing listed.

    -Andy

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>