[Qt-interest] Developing for multiple platforms (os)?
Yves Bailly
yves.bailly at sescoi.fr
Mon Feb 16 09:13:41 CET 2009
Hello Knapp,
Knapp wrote:
> Hi, I am looking at a project that needs to run on Linux, MS (all
> forms) and Apple. Are there any pitfalls to watch out for? Does it
> take a lot of work to make sure it works cross platform or can I just
> write it to work on my Linux machine and know it will work fine on all
> the others?
> Thanks for any advice or insights!
It all depends on what your project will do. If you consider doing
some low-level work (using USB device, manually editing the raw
filesystem, doing some nasty things with windows handles, ...), then
obviously this is all highly system-dependent. You'll most probably
have to insert things like this in your code:
#if defined(Q_OS_WIN32)
// ...Windows specific...
#elif defined(Q_OS_LINUX)
// ...Linux specific..
// ...and so on...
Have a look at Qt's header "qglobal.h" to get an idea.
For a general-purpose application, I guess the most annoying is the
differences regarding paths: no "C:" on Linux, use "\" as separator
on Windows, and so on. But Qt provides tools to deal with that (see
QFileInfo and QDir, and QSettings is great for user preferences).
If you stay strictly within standards' and Qt's boundaries, when you
should be fine. About Qt, the doc always tells you when a given function
is not available on a given platform. If you take care of this, then
almost all you'll have to fight with is compilers differences, e.g.
you have to #include <ciso646> if you want MS Visual C++ to recognize
"and", "or", "not" etc. as keywords.
<self-promotion>
If you want an example of a non-trivial application which compiles and
runs on Linux and Windows, using either GCC or MS Visual, all of this
with very (very) few special-cases tweakings, have a look at
http://bloqus.tuxfamily.org - not tested on MacOS though, if anyone has
a few spare minutes to give it a try and tell me about it... :-)
</self-promotion>
Hope this helps.
--
/- Yves Bailly - Software developper -\
\- Sescoi France http://www.sescoi.fr -/
"The possible is done. The impossible is being done. For miracles,
thanks to allow a little delay."
More information about the Qt-interest-old
mailing list