Installing Qt on Linux (Old instructions)

Please note – these are possibly outdated instructions. Use with caution!

There are two options for developing Qt applications, download off the Qt Project web site or the Nokia web site.

Qt Project:

http://qt-project.org/downloads

Nokia (recommended):

http://www.developer.nokia.com/Develop/Qt/Tools/

The Qt Project provides both open source and commercial versions of Qt. There are certain restrictions if creating a commercial application with Qt. The Nokia version is essentially the same except that it is about 100 times faster to get setup since you don’t need to build sources or install MinGW. As of this writing it appears that Nokia recently began requiring an account to download their SDK.

Since the Qt Project installers are more complicated, instructions for Qt Project downloads are given here.

NOTE: References to opening Grbl Controller’s .pro file in Qt Creator imply that you have installed git (sudo apt-get install git) and then did a git clone https://github.com/zapmaker/GrblHoming. A folder called GrblHoming will be created and inside of it will appear the .pro file along with all the source files.

Linux (Debian and Ubuntu)

This was tested with Debian 6 and Ubuntu 11 and 12.

Option 1: Download Qt Creator from Qt Project downloads web site. (Linux)

The advantage of this approach is that you get the latest Qt Creator code, however, you still need to install libraries. The easiest way is to first install the Qt Creator from Synaptic Package Manager or Ubuntu Software Center (USC recommended as that has replaced SPM in the latest Ubuntu versions) and after that is done, run the one downloaded and installed here in Option 1- it should find the necessary library version from Option 2.

Download Qt Creator from Qt Project downloads web site.

Rename the downloaded file qt.bin for ease of typing.

Note: The version for 12.04 LTS is 2.4.1, which is pretty old, as the current version on qt-project.org is 2.7.1. Thus, it is recommended to install and then install the version off qt-project.org. See further instructions…

NOTE: You can type a few characters and then hit the Tab key – Linux will autocomplete if there are no ambiguities. Then you don’t have to rename.

Do a chmod 764 qt.bin to allow execution

Open a terminal window in the Downloads folder and do a ./qt.bin which will launch the installer. Follow the instructions in the installer.

Follow instructions in Option 2.

In terminal window go to home folder and type (adjust version as necessary): ./qtcreator-2.6.0/bin/qtcreator

NOTE: Qt Creator may get installed such that you can use Dash to find it quickly without having to type an explicit path.

Also see note about permissions to open COM port in Option 2 below.

Option 2: Install Qt Creator via Synaptic Package Manager or apt-get (Linux)

This is the easiest way to install Qt Creator and it also automatically adds shortcuts for the Qt tools to the system.

Use Ubuntu Software Center to find Qt Creator.

Search for each of the following. Check mark each for installation (accept each item’s required packages). On Ubuntu, g++ is already installed. You can also use the command line apt-get for these:

  • qtcreator
  • g++
  • libudev-dev

Apply

Packages will download and install.

Go to Applications menu, Programming. Under that you should see Qt Creator. Launch it.

Open the .pro file and build.

NOTE: It is possible your user may not have sufficient privileges to open the COM port (typically /dev/ttyUSB0) from within GrblController. You may need to modify the Qt Creator launch properties to prefix qtcreator with gksudo if you wish to debug within Qt Creator. Running GrblController on its own may requiring prefixing with sudo, i.e. sudo ./GrblController

When using Ubuntu’s unity interface, it is slightly more complicated to permit sudo permissions. Run this command:

sudo nano /usr/share/appications/qtcreator.desktop

or

gksudo gedit /usr/share/appications/qtcreator.desktop

and change the line

Exec=qtcreator %F

to

Exec=gksudo -k -u root qtcreator %F

After saving the file, launch from the Unity interface. You should be prompted for administrative password. If yes, enter it and Qt Creator should come up. Since you may have two versions installed, pin the current one to the launch bar to prevent the other one from causing confusion when searching for Qt Creator in dash.

Side Note – Installing Qt5

Download the appropriate Qt5 from qt-project.org. Do the same chmod as mentioned above to the downloaded file, open a command window and type ./<the file name you just downloaded> which should open an installer (about 300 MB). Click OK or Next and it should install and offer to run its bundled Qt Creator. Since you’ve probably already installed Qt 4, you will need to switch over to the new Qt 5 in Qt Creator by opening Tools > Options > Build and Run > Kits. Select Auto-detected (which is Qt 5 hopefully) and choose the Make Default button. Now if you do a rebuild all, you and look at the Compile Output window, you should see paths showing up in the output to Qt5.

Option 3: Static build (Linux)

Download the Qt Linux SDK from Qt Project and extract to ~/Qt/4.8.4 or whatever the version is

See this link for info:

http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Linux

Create static libraries:

1. Open terminal to ~/Qt/4.8.4 and do a ./configure -static

2. After about 10 minutes it should be done. Either do a make or do a make sub-src

3. The latter is better as it won’t build everything. After about 6-10 hours it should be done with no errors (make sure you computer doesn’t go to sleep!)

4. Do the following

sudo make install_qmake

sudo make install_mkspecs

sudo make install_subtargets

(if you did a make sub-src earlier, the last line needs to be sudo make sub-src-install_subtargets)

The latter step can take 10 minutes or more.

This will install the libraries to the “Trolltech” folders where qmake expects them.

Enter GrblHoming folder and execute the following command

~/Qt/4.8.4/bin/qmake “CONFIG+=static” -release -spec ~/Qt/4.8.4/mkspecs/linux-g++ GcodeSenderGUIthreads.pro

Type make

If everything was setup right, you should get a statically built executable.

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>