Archive for the ‘Development’ Category

NetBeans and Qt5


After upgrading from NetBeans 8.0.1 and switching to Qt5 I noticed that the compiler C++ standard switch was set to c++0x and when setting the C++ standard to C++14 in the project settings the compiler standard switch is left out completely with the result that the compilation fails. I’m currently using the g++ 4.8 compiler, the documentation states that c++0x is deprecated and c++11 should be used instead and the switch for experimental C++14 support is c++1y.

Digging through the various make and project files showed the addition of -std=c++11 to QMAKE_CXXFLAGS was made only when the major version of Qt equalled 4. Oddly c++11 is added to a symbol called CONFIG if the major version is 5. These additions are found in qt-Release.pro and qt-Debug.pro project files. If the selected standard is set to C++14 the addition to CONFIG is missing. I haven’t been able to determine where the -std=c++0x comes from.

It’s clear that NetBeans 8.1 and earlier version don’t properly support Qt5. Switching back to Qt4 resulted in the correct standard switches been added for C++11 and C++14, the C++14 failed build failed because g++ 4.8 doesn’t recognise -std=c++14.

NetBeans can be used with Qt5 with the correct settings for the C++ standards. First set the standard to default:

Setting C++ standard to default

Setting C++ standard to default

Even if C++11 is be used this will suppress the addition of -std=c++0x. The required C++ standard option can be added using the custom definitions in the expert section of Qt project properties:

Custom definitions

Custom definitions

adding the required compiler switch for C++11:

Adding the C++ standard option

Adding the C++ standard option

The custom definition is truncated in the picture, in full it is:

equals(QT_MAJOR_VERSION, 5) { QMAKE_CXXFLAGS+="-std=c++11"}

The check for Qt 5 can be omitted if you don’t intend to swap between Qt4 and Qt5.

So the correct standards can be set when using Qt5 with NetBeans, experimental C++14 support in g++ 4.8 can also used by using c++1y instead. There are currently 3 g++ branches, the latest versions being 4.9, 5.3 and 6.1, these compilers accept -std=c++11 and -std=c++14, in addition 6.1 accepts -std=c++1z for the forthcoming C++17. The appropriate standard can be set depending on your compiler, if your using 6.1 then the custom definition can be deleted as the default standard id C++14.

In short if your using Qt5 with NetBeans always set the C++ compiler standard to default and specify the standard you want to use in Qt custom definitions.

Posted 9 June 2016 by element90 in Development, Linux

Tagged with , , , , ,

Migration to Qt5   Leave a comment


So far I’ve been using Qt 4.8 on both Linux and Windows 7. The compiler used on Windows 7 was Microsoft Visual Studio C++ version 10.0 which came with Visual Studio 2010 Express. The Microsoft compiler had poor support for C++11 features which meant I had to code my fractal software such that it would successfully compile on Linux and Windows.

Fed up with not being able to use C++11 fully on Windows led me to upgrade to Visual Studio 2015 Community. Since Windows 8, 8.1 and 10 have been released since I first released my software for Windows I went the whole hog and upgraded to Windows 10, upgraded to Qt5 built for 32-bit and Qt5 built for 64-bit using Visual Studio 2015 and upgraded QtCreator to version 4.0.0.

Over on Linux Mint the shift to Qt5 was easy, all I had to do was install the Qt5-default package:

Selecting Qt5

Selecting Qt5

If need be I can easily switch back to Qt4 by uninstalling Qt5-default and installing Qt4-default instead.

Building SaturnQt using Qt5 required just one change to its NetBeans project:

Select project properties

Select project properties


Add QtWidgets

Add QtWidgets

The location of Qt classes has been rearranged so QtWidgets is required for Qt5 but not for Qt4.

The project built without any problems and when SaturnQt was started some differences in appearance were evident, first the main window and the settings window for the Qt5 build:

Main window using Qt5

Main window using Qt5


Settings window using Qt5

Settings window using Qt5

and these are main and settings windows for the Qt4 build:

Main window using Qt4

Main window using Qt4


Settings window using Qt4

Settings window using Qt4

There are some obvious differences:

  • The window background colour is lighter using Qt5.
  • The height of the iterations box is the same as the zoom selection combobox using Qt5, they are not when using Qt4.
  • The list cursor is blue instead of green using Qt5.

There are other minor differences. In short Qt5 doesn’t match the MATE theme I’m currently using with Linux Mint. It should be possible to solve this issue and when I do I’ll post it on this blog.

Back to Windows. The project file for SaturnQt already had a check for Qt5 and automatically adds QtWidgets. QtCreator was then configured to use the 32-bit build of Qt 5.6 and to use the Visual Studio C++ version 14.0 compiler. The first build failed as std::max requires the inclusion of <algorithm> which is not required for Linux it has been added to the source code causing no issues for the Linux build. In addition there were a large number of warnings, I’ll cover these when I compare g++, clang++ and the Microsoft compiler in an other post.

Running the project successfully started SaturnQt on Windows 10:

Main window on Windows 10

Main window on Windows 10


Settings window on Windows 10.

Settings window on Windows 10.

I haven’t yet built a 64-bit version for Windows 10 as I need 64-bit libraries for MPIR and MPFR (for multi-precision arithmetic) and the QtCreator project file needs to be modified to support 64-bit builds. There will be a post on building 64-bit versions of my software for Windows in due course.

Qt5 versions of my software will not be available until I’ve finished the next versions and sorted out the release packages which will be affected by the transition to Qt5.

Mandelbrot Division


So far adding critical point support to some of the formulae in Saturn and Titan, for the next release, has been straight forward. The next formula “Mandelbrot Division” is somewhat trickier. The formula features two parts that match a standard Mandelbrot with powers that are not necessarily 2, one part is divided into the other, in addition there are two parameters added to the result. All parameters in the new version of Saturn can be a number or a number modified by multiplying or dividing the location in the complex plane, strictly speaking the “Mandelbrot parts” aren’t Mandelbrot unless the parameter is modified, so Mandelbrot Division is only a loose description but it is convenient as a name.

The current formula is as follows:

z = (zα + β)/(zγ + δ) + ε + ζ

To ensure that the critical points can be found a new version of the formula “Mandelbrot Division IP” will be added where IP indicates Integer Power.

z = (zA + α)/(zB + β) + γ + δ

The critical points are found as usual by solving f'(z) = 0, γ and δ simply disappear leaving the Mandelbrot parts to be differentiated using the quotient rule:

(f(z)/g(z))’ = (f'(z)g(z) – g'(z)f(z))/g(z)2 = 0

Multiplying both side by g(z)2 simplifies things so critical points are the solutions of the following:

f'(z)g(z) – g'(z)f(z) = 0

The Mandelbrot parts form the definitions of f(z) and g(z):

f(z) = zA + α
g(z) = zB + β

Their differentials are:

f'(z) = AzA-1
g'(z) = BzB-1

So the formula to solve is:

(AzA-1)(zB + β) – (BzB-1)(zA + α) = 0

which simplifies to:

(A – B)zA+B-1 + βAzA-1 – αBzB-1 = 0

When the values of A and B are known the smallest power can be factored out and the other powers reduced accordingly, as a power of z has been factored out it follows that Mandelbrot Division IP always has a critical point of zero. The other critical points are found by solving the remaining polynomial which will be handled by Saturn and Titan.

This formula hasn’t yet been implemented so I can only show some pictures using the current Mandelbrot Division formula where the initial value is set to zero (a critical point).

Mandelbrot Features

Example 1 – Mandelbrot Features

Example 1 - parameter settings

Example 1 – parameter summary

Example 2 - Multibrots

Example 2 – Multibrots

Example 2 parameter summary

Example 2 parameter summary

The two Titan summaries show changes from the currently released software the most noticeable of which is the display of colour maps at the bottom.

NetBeans, Qt and Git   Leave a comment


An important aspect of software development is “source control”, enabling the tracking of changes, bug fixes and releases. I used Subversion for this purpose. There are several other source control systems available, one of which is Git which appears to me to be on the rise in popularity. I develop my software using NetBeans IDE (currently version 8.0) which integrates well with Subversion, two other source control systems are also supported by NetBeans: Mercurial and Git. The best way to get a feel of NetBeans and Git is to try it out.

Subversion is organised such that a single repository can contain many projects, Git usually has a repository for each project. To try out Git, projects in the Subversion repository have to be converted into Git repositories. For this post I’m using TitanQt as an example. Here’s its structure shown in a RapidSVN window:

TitanQt in Subversion

TitanQt in Subversion

The structure of TitanQt is common to many Subversion projects, there’s the main development trunk, two version branches and three tagged releases. Ideally the tagged versions should be a snapshot of the code, however, in Subversion they are code branches and there is nothing to stop revisions being applied to them.

I’m not going to show the steps involved in converting a Subversion project into a Git repository, I followed the instructions detailed here missing out step 3. One thing not mentioned in the steps to convert a Subversion repository is that extra branches and tags may appear, they have the form of an existing name qualified by an @ symbol followed by a revision number. Any extra branches and tags can be safely deleted.

A Git repository is usually embedded within a working directory. Git repositories shared between users are shorn of their working directories, such remote or “bare” repositories can be stored anywhere, usually on a server, in my case, development is on one computer and the repository only has one user. I keep bare Git repositories in a separate directory to project development and there are off site backups in the “cloud”.

To open a NetBeans project from a remote Git repository it needs to be cloned:

Cloning a repository step 1

Cloning a repository step 1


Cloning a repository step 2

Cloning a repository step 2


Cloning a repository step 3

Cloning a repository step 3

IMPORTANT: select all the remote branches, if you don’t only the branches selected will be available to the cloned repository.

Cloning a repository step 4

Cloning a repository step 4

TitanQt is a NetBeans Qt project, many files are automatically generated. When I first put TitanQt under source control I was unaware of the extent of the auto generated files and as a consequence several of them are in the Git repository. The contents of the nbprojects directory can be stripped back to just two files: configurations.xml and project.xml. Once these files have been deleted the changes are committed. There are two ways in NetBeans of listing the changes to be committed via the Team menu or by using the popup menu when right clicking on the project name in the Project or File tabs.

Show changes via Team menu

Show changes via Team menu

Show changes via popup menu

Show changes via popup menu

The list of file changes to be committed:

List of files affected

List of files affected

Commit the changes

Commit the changes

Qt implements many of its features by the use of a C++ preprocessor thus Qt classes generate file of the form moc_*.cpp, Qt resource file also generate files of the form qrc_*.cpp. By default these files are generated in the same directories as the project’s source files, they can be kept separate by setting project properties:

Project properties

Project properties

Qt properties

Qt properties

Specifying MOC and RCC directories keep the auto generated files away from the project source files.

Building the project and showing the changes reveals a list of changes including auto generated files. The auto generated files are just clutter and should be ignored.

Changes after build

Changes after build

In the picture above the build and dist directories are grey and NetBeans ignores these directories for source control purposes. There is a discrepancy between NetBeans and the git status command at the command line:

git status

git status

The dist directory is mysteriously missing from git status, but the directories for build, moc and qrc are present along with .dep.inc, NetBeans, however lists every file in directories moc and qrc and .dep.inc isn’t mentioned at all.

Directories and file can be ignored using NetBeans via the pop up menu or the Team menu.

Ignoring a directory

Ignoring a directory

As soon as something is ignored a .gitignore file is created. To get the build directory to disappear from git status the .gitignore file has to have “/build/” added to it using the editor as NetBeans doesn’t allow build to be ignored or unignored. The .gitignore file is used by Git to ignore files and directories and is very flexible, a pattern such as “nbproject/*.mk” can be added which indicates that all files that match that pattern should be ignored, NetBeans does not provide a means for adding such patterns from the menus but, of course, the file can be edited. Adding the appropriate patterns results in git status reporting that only the .gitignore file is being tracked. NetBeans doesn’t take account of patterns it only handles files and directories, some files and directories are grey and they can’t be added to .gitignore via the menus. In order to get git status and NetBeans to agree with each other the .gitignore file must be edited and it must not include patterns.

The .gitignore file

The .gitignore file

Now the .gitignore file can be committed. The local and remote repositories now differ, the local changes are applied to the remote repository using “push”.

Push

Push

That’s tidied up the project files for master (trunk in Subversion). Branches version-4.0 and version-4.1 have to tidied up in the same way. But what of the tags? To show that the Git repository matches up with the Subversion project the repository browser can be started from either the Team menu or from the pop up menu.

Repository browser

Repository browser

All the branches have been expanded showing master, two version branches and three tagged releases. Note that branches only exist at this stage on the remote repository, to start work on a branch a copy needs to transferred to the local copy using checkout. Checkout is available from both the the Team menu and the pop up menu.

Checkout step 1

Checkout step 1

Checkout step 2

Checkout step 2

At this stage a commit revision id, branch name or tag name can be entered or the select button used.

Checkout step 3

Checkout step 3

Once the revision has been selected the “Checkout Selected Revision” dialogue reappears.

Checkout step 4

Checkout step 4

Note the check box for creating a local branch, when a local branch is created it corresponds to the remote branch which allows changes made locally to pushed to the remote repository.

Git tags correspond to a snapshot of the code when it was tagged, in the case of tagged release code no changes should be allowed. To achieve this the create branch check box should remain unchecked.

Checking out a tag

Checking out a tag

Any changes to a tag can not be pushed to a remote. Sometimes changes have to made to get a program to build for example the names of boost libraries can change, on Linux Mint 15 the boost library names used ended in -mt on Linux Mint 17 none of the boost library names end in -mt and the boost system library is now required. It isn’t necessary to commit such changes but they can be added to the repository by creating a new branch applying changes to that and creating a new tag.

So that’s it, TitanQt is now in a Git repository, NetBeans integrates well with Git with the exception of .gitignore and changes have to pushed to the remote repository unlike Subversion where the repository is in effect always remote.

Update

Since I wrote this post I’ve become aware of some aspects of using NetBeans that I missed.

  • Push should be applied to each branch.
  • Patterns can be used in a .gitignore file but NetBeans only recognises them once the .gitignore file has been checked in.
  • When checking out a branch it is only necessary to check the create branch box if the branch doesn’t already exist in the local repository.
  • NetBeans displays a dialogue (see below) when a local branch is created when checking out a revision.

The following dialogue is displayed when a new local branch is created when checking out a revision even though git status from the command line reports no local modifications.

Unexpected dialogue

Unexpected dialogue

Select review. The new local branch is created but NetBeans refuses to switch branches, reverting to the command line the checkout completes without a murmur and NetBeans switches to the new branch.

Posted 7 July 2014 by element90 in Development

Tagged with , , , , ,

Daily Fractal No. 699   Leave a comment


Exiled Mandelbrot No. 41

Exiled Mandelbrot No. 41

Available as a print, poster or card from the shop, Redbubble and Artflakes.

Posted 7 July 2014 by element90 in Art, Development

Tagged with , , , , , ,

Daily Fractal No. 685   Leave a comment


Spiral Intrusion No. 1

Spiral Intrusion No. 1

Available as a print, poster or card from the shop, Redbubble and Artflakes.

Posted 23 June 2014 by element90 in Art, Development

Tagged with , , , , , ,

Daily Fractal No. 684   Leave a comment


Ob a Bridge Across the Divide No. 1

Ob a Bridge Across the Divide No. 1

Available as a print, poster or card from the shop, Redbubble and Artflakes.

Posted 22 June 2014 by element90 in Art, Development

Tagged with , , , , , ,

%d bloggers like this: