Posts Tagged ‘Cross-platform’

Deploying Qt 4.x applications on Mac and Windows

April 28th, 2010 No comments
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.
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 No comments

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 . 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 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