Condividi tramite


Cross-platform Development Part 1: Few tools and libraries to get started with

Continuing from Getting started, here we will see some of the basic tools and libraries that one should be acquainted with to make the cross platform development fun and easy (while respecting the audience request to consider non-Windows platforms also).

One of the most challenging parts of cross-platform development is ensuring portability/correctness across all the intended platforms. And this is not just the coding or binary portability we are talking about. Nightmares start even before the compiler can hit the code, right in the build stage or  even before (inode access problems while reading samba mounted windows folder files etc... ). A coherent toolset forming a decent build, code and release pipeline is invaluable under such circumstances.

Before we embark on tools for non-windows platforms, one windows-specific tool worth mentioning (even something that is considered as holy-grail of development for non-windows platforms) is: Visual Studio. Do not mistake me, but if you have not worked with Visual studio to code, build or debug, then you have missed lot of fun. Even one can say, you haven't really done serious development. Go ahead and try the latest Visual Studio and its unparalleled intellisense and Debugging features. (Did you try the latest Intellitrace feature for .Net? Sad that its still not available for C++ though).

Now, having said that, there are tons of other good open-source and  non-commercial tools, frameworks and libraries for non-windows systems that can rival Windows Visual Studio and its component tools, libraries and frameworks, some of which we discuss below.

In the next article, we will discuss on how to setup build structure, linux accessible windows shares and other coding pipeline details vital for the multi-platform development. Below are some of the recommended/required components for building such pipeline.

Framework: Choosing the right multi-platform framework forms a solid foundation for any development project. (Frameworks like Java and .Net are essentially platforms in themselves and are not considered as true multi-platform by many).

Qt is a very good multi-platform framework for your applications. It supports wide range of platforms ranging from Windows, Linux, Mac OSx to Mobile Android and Symbion. It can be also be easily integrated into MFC and .Net. The only problem is most of its components are somewhat tightly integrated with its UI related components. So its a take-it-all or none kind of framework, unless you want to leave a heavy dependency. (However, after Nokia bought Trolltech, Qt is undergoing heavy changes and recently there is very good seggregation creeping in among Gui and other reusable components.)

Some consider frameworks like Gtk are good alternates for Qt. But given Qts rapid adoption and evoluation, the others are becoming obsolete fast.

Qt comes with its own IDE (Qt Creator), Build system (QMake) and Scripting mechanism along with complete SDK filled with advanced features such as Signals/Slots, rapid UI controls and re-usable Qt solutions (such as Property browser, color picker), Python integration etc.

In case you are not aware, award winning products like Next Limit Realflow and Autodesk Maya use Qt !!

IDE & Build system: For projects that do not use Qt, CMake is a good multi-platform build system. In fact its more of a meta-build system (a system that generates build files). While there are other alternates like Automake etc., CMake is rapidly gaining adoption among open source projects and can target multiple platform make files, can generate Visual Studio, Eclipse and Codeblocks solution/project files.

As for IDEs, CodeBlocks is a good one to start with if you are coming from VS. Its small in size - but the debugging can fast become tedious. Eclipse and KDevelop are others you can try. If you are using Qt, Qt Creator is a good option (vital if you are designing Qt Forms, though there are VS plugin options to host the Qt Designer right in Visual Studio).

Now, you have two options to actually do the build for targeting a non-windows machine: 1. Cross compiling the binaries on Windows 2. Using a Virtual Image of the target OS and performing a native build

Second option is the preferred one, especially if you have dependencies on third-party components. Besides establishing a cross-compilation tool chain is not that easy nor fun. If you wish to try that path of cross-compilation, checkout MinGW or the GCC Cross compilation techniques: https://wiki.osdev.org/GCC_Cross-Compiler

In the next blog, we will go through the details of settingup a Virtual Host/Guest and a reasonably standard build directory structure for out-of-source builds.

Versioning: Ensure that you are using a versioning system that can keep track of your modifications to your project. SVN is a good one and is supported by many open source hosting sites such as sourceforge. Tools like  TortoiseSVN that integrate into the shell are the best bet for your SVN client. Standalones like RapidSVN become too restrictive ovre time. For linux machines, checkout KdeSVN that integrates into Nautilus (https://www.clickoffline.com/2008/12/ubuntu-alternatives-for-tortoise-svn-in-linux/) One major advantage of shell-integrated SVN clients is - just by checking the file icon in the file folder you can tell if the file is modified and need to be committed. The chances of your forgetting to commit your work are minimal with such tools.

CVS is a good alternative for SVN, if you know the differences. If you are unsure, go for SVN. (Git is another good alternative if you are a heavy user of branching and merging, which would be the case if your project is too large with multiple versions/features being developed simultaneously)

Libraries & Tools: Based on the nature of your work you might be needing different libraries. Below are few multi-platform tools and libraries I usually find useful in my work.

GMP: Multi-precision Arithmetic (LGPL) - Good for Scientic & Research arithmetic manipulations
MPIR: Windows/VS2010 port of GMP
MINGW: Minimalist Gnu for Windows (Good for cross-compiling Linux binaries on Windows)
FontForge: OpenType and TrueType Font creator, editor
Volt: OpenType font editor - very good tool by Microsoft for Kerning pairs and for creating Lookup tables
Latex: Document preperation system - Standard for scientic, research and journal publications. Latex is document publishing system unlike Word which is document 'editing' system.
MikTex: Windows port for Latex - Recommended for working with Latex on Windows
Poppler: PDF Rendering library

Many of these above are used in much of my multi-platform work including the below:

CFugue: C++ Runtime for MIDI Score programming
CarMusTy: Carnatic Music Typesetting and Publishing application

Stay tuned for next blog in this series of cross-platform development. Meanwhile, feel free to post questions, comments and feedback.