Archive

Archive for the ‘Software Development’ Category

Just turn off the precompiled headers option

April 22nd, 2011 Comments off

I have been bitten for years whenever I have used precompiled headers with C++ platforms. It doesn’t matter what platform I’m using, they just never quite seem to work properly and reliably. From time to time you just get bizarre error messages that just don’t make any sense. So as a matter of course I just leave that option turned off and suffer the extra compilation time.

Recently, I’ve been working with Xcode 4 which we use for our Scorecerer iPad development. Precompiled headers are enabled by default and one of the first things I did was turn that option off and forgot about it.

However, one of my partners who also just switched to Xcode 4 did not turn off that option and guess what — he just got bitten. In his case, he built an update of the product with changes that I checked into our version control system. The code compiled and built perfectly but the Xcode IDE still displayed a bunch of those red error marker icons in various places and suggested that some classes and some variables were missing. Cleaning the project and rebuilding made no difference.

My partner futzed with it for an hour or so and then told me he was having the problem. I told him to turn off the precompiled headers option. He did that, did a clean followed by build and everything is fine.

So just turn off precompiled headers. You won’t be sorry.

Categories: Software Development Tags:

Apple OSX App Store and Qt Applications

January 12th, 2011 Comments off
Mac OSX App StoreIf you use Qt to build your application for Mac OSX – you must have heard about the new OSX App Store that just opened in January, 2011.
The App store resembles the app store used for iOS devices hoping to bring the similar, streamlined experience, to the end-user. For us developers – this is great news … as long as we make our software so it doesn’t break the rules that Apple set forth.
In particular, there are certain steps one needs to perform to create a package compatible for submission to the app store and the application itself needs to follow certain guidelines. Files cannot be written to certain folders, UI must have a consistent OSX look and so on …
We are not sure yet what that means for Qt based applications, but we are willing to give it a shot.
Our music notation product – Scorecerer has a desktop application that is built on top of Qt and it runs on OSX and Windows. We have built a free version of Scorecerer (Scorecerer Lite) and submitted it to the OSX app store. We are still waiting for the verdict and will soon know if Qt applications can or cannot be included in the OSX app store.
There seems to be a big debate going on in various forums, but most seem to simply speculate and paint Apple as “evil” without even trying to submit their app. Once we have the verdict – we will share it here with you so you will know for sure.
If Scorecerer Lite gets approved and published on the OSX app store – I will post the exact steps on how to prepare and submit your Qt app to the app store. Make sure you check our blog often for the latest news on this.
In the meantime we can only wait and hope that Qt libraries themselves do not break some of the Apple’s rules.
UPDATE: Today we got a rejection email from Apple. The list of reasons is long and we could address most of the issues, but there is one related to Qt itself
The application is creating files or writing to the following locations:
~/Library/Preferences/com.trolltech.plist
This is obviously done by Qt itself and as long as it is there – we will not be able to submit to the app store. We will try to see if there is a solution to this problem, but in the mean time – your Qt application will be rejected because of this!
Categories: Software Development Tags:

Deploying Qt 4.x applications on Mac and Windows

April 28th, 2010 Comments off
If you are using Qt as your development tool – most likely you are targeting different platforms. Deployment techniques for different platforms vary and there are a few “gotchas” that you should be aware of.
For OSX – you should use the macdeployqt command that comes with Qt on OSX. To use it – simply go into the folder where your application is and run the tool giving it your app name as the parameter.
macdeployqt Foo.app
This packages everything nicely into one bundle that you can distribute to someone who does not have Qt installed on their system. I assume that this build is a “Release” build and I assume that you will be able to either create an installation package or an installable .dmg file
On Windows – things seem to be simple at a first glance as well, but there are a few things you should pay attention to.
Copy your .exe into a new folder and try to run it. You will immediately get a note about some missing dlls. You can keep trying this and copying the dlls needed into the folder, but a better way is to use Dependency Walker tool and drop your executable into it. It will show you most dlls you need to run the application.
The fun starts when these modules are loaded on demand in the application’s code. This is the case with the Qt “plugins”. They will not show on your dependency tree and your application may appear to be running, while in fact it will crash or worse – continue to work without desired functionality when these plugins are required and you are NOT on a machine that has Qt installed.
The real trouble is that Qt will look for those in a specific folder within your application AS WELL AS the main Qt plugins folder – this makes your installation impossible to test unless you are on a machine that does not have Qt installed.
An example of this are the Qt image processing plugins that allow you to load various file formats into a QImage object.
Plugins are located under the “plugins” folder in your main Qt installation folder. Within that folder you will have subfolders for each group of plugins. For image processing – the name is “pluginsimageformats”.
To make this available on the target machine – you have to place the folder called “imageformats” under the main folder where your executable file is. So if you are installing your application into “C:Program FilesMyGreatAppMyGreatApp.exe – you have to install a folder “C:Program FilesMyGreatAppimageformats” into it and copy all the dlls you need there.
So – it’s really easy to deploy a Qt App on Windows or Mac, but watch for a few of these little tricks. Always test your build on a machine that does not have Qt Installed before deployment. (something I didn’t do last time and a reason for this blog entry :))

Cross-platform desktop development options: Lazarus and other Object Pascal options

February 10th, 2010 Comments off

Object Pascal is a wonderful programming language! It is easy to read and understand while giving you a full array of modern object oriented language features. Strings are easy to work with, constructors are virtual, functions can be nested – these are only some of the goodies that come with the language.

I am by no means “religious” when it comes to languages though. It all depends on the project that one works on. The framework that one works with is much more important than the language itself in my opinion.

Object Pascal got popularized by the development environment called Delphi. It was initially created by Borland. If you programmed in the 80’s or early 90’s – chances are – you used Turbo Pascal (procedural Pascal) which was Borland’s best product at the time. They later evolved the idea of IDE into a modern language and framework.

Delphi’s strength was(still is), not only in basing itself on a great language – the VCL (Visual component Library) that came with the development environment was phenomenal. Moreover – it was extremely easy to develop your own components for repeated tasks and extend the IDE.

People who use Delphi will tell you that it is the best thing since sliced bread, but unfortunately – this was not enough to make Delphi or Object Pascal widely accepted. Delphi is still around and it is actively supported and developed by Embarcadero Technologies http://www.embarcadero.com/ . New versions work with .NET as well as windows native libraries.

An effort to bring Delphi to other platforms was made by Borland at some point. They called the product Kylix. It was a nice piece of software, but at that time – there was simply no market to sell the product to so the effort died.

Free Pascal is the open source implementation of Object Pascal. It is an actively developed, very modern language that runs on myriad of platforms and CPUs. If you have a device on your desk or your pocket – chances are – you can compile for that target using Free Pascal. It is a very mature project that started when Borland decided not to release Turbo Pascal 8 and focus solely on the windows platform (this later became the first version of Delphi). Since version 2.2 – Free Pascal supports Generics for example which are the equivalent of C++ Templates. Many other modern features are already built into the language.

Lazarus http://www.lazarus.freepascal.org/ is a free, open source IDE for Free Pascal. It is an effort to port the Delphi VCL to work with FPC and therefore on other platforms.

While the promise and potential of these tools was really appealing to us, the stability and maturity of Lazarus at the time of our evaluation was really not up to our standards. We could create and compile simple GUI applications and target different platforms, but the overall IDE was simply not usable in production environment.

While we would love to use Object Pascal in all our projects – there was simply no usable IDE for Free Pascal at the time and Embarcadero worked only on Windows. Free Pascal however is very mature, stable and full featured and we hope that Lazarus will catch up with it soon.

If you plan to develop a very simple application however – take a look at Lazarus and Free Pascal – it may be just the right toolset for you.

Next: Cross-platform desktop development options: .NET, Mono and Java

When NULL == false in QVariant

December 21st, 2009 Comments off
I (Nebojsa) spent some time hunting down a problem where our QSettings (a Qt framework settings class) derived convenience class would not read Boolean values properly.
We wrapped the “Read” function with a code similar to this
  
template  T Read(ConstString name, T defaultValue)
{
   T result = defaultValue;  // Assume
     if (Exists(name))
        then QVariant v = this->value(name);
     if (v != NULL)
        then result = v.value();

   return result;
}
The idea is simple – if the value exists we read it, if not we use the supplied default value.
The line
   If (v != NULL)
fails miserably if v is a Boolean value.
If v is a boolean type and its value is false – then the v == NULL expression evaluates to true.
This is understandable since NULL expands to 0 and 0 is considered false. I wish NULL would be reserved for pointers in C++ so that the compiler could complain whenever one tried to use it for anything else but to signify a NULL POINTER!
So rather than testing the QVariant for NULL – use its member function isNull to test if it is really null.
The if statement above should be written as
   If (!v.isNull())   ...
Everything works perfectly afterwards.
Btw. If you are wondering what is a Pascal style “then” doing in our C++ if statements – we believe that “then” is making our if statements much more readable. It is simply defined as nothing
#define then
Categories: Software Development Tags: