Cross-Platform Development in C++
Building Mac OS X, Linux, and Windows
Applications
Reviewed by Jonathan Hoyle
![](Cross_files/image001.png)
Author: Syd
Logan
http://www.informit.com/store/product.aspx?isbn=9780321246424
Released: November 27, 2007
Pages: 576
$50 USD
ISBN: 032124642X
Strengths: A
great introduction to cross-platform issues for the C++ programmer, including
a one of the bestdetailed examinations of the wxWidgets framework.
Weaknesses: Rather
limited in its overview of C++ frameworks, focusing almost exclusively on
wxWidgets and the author's own framework.
|
![](Cross_files/image002.png)
![](Cross_files/image003.jpg)
|
Introduction
I can't tell you how often I have excitedly picked up a
book purporting to be about cross-platform development, only to be sadly
disappointed in just the first few pages. It seems that many authors define "cross-platform" to mean Windows and Linux only, with no mention of
the Macintosh. That is why I am so delighted to finally be able to recommend to
you a book that is both truly cross-platform and truly Macintosh friendly: Cross-Platform
Development in C++: Building Mac OS X, Linux, and Windows Applications by Syd Logan.
Rather than treat the Mac as a second-class citizen, Logan
treats all three operating systems fairly and completely. In fact, Mac OS X is
usually listed first in most discussions. What is even more pleasantly
surprising is finding the predominance of Mac OS X screen captures through the
book! I truly felt at home reading this book.
Chapters 1 and 2 (Policy and Management and Build System/Toolchain) deal with the benefits of a platform neutral
approach and give solid recommendations on choice of development tools. This
section is one you will likely read many times, as project startup efforts
require a number of tactical decisions which will have long-term effects down
the road. Although many options are placed in front of you, Logan wisely
directs you to use Xcode for the
Mac, Visual Studio for Windows,
and gcc for Linux. There are even
details for those wishing to use cross-compiler make files. Chapters 3 and 4 (Software
Configuration Management and Installation
and Deployment) follow this up with
cross-platform bug-tracting, source control and installation sofware options.
Chapters 5 and 6 (Operating System Interfaces and
Libraries and Miscellaneous
Portability Topics, respectively) deal with
portability issues for compiling your cross-platform project. Differences
between development environments like Visual Studio and Xcode can be subtle and lead to compilation and debugging problems down the line.
The author gives great helpful hints on avoiding some of these pitfalls by
configuring your environment in a way which is compatible and standards
compliant. Logan also gives good advice on a number of tools useful for the
purpose.
One of my favorites is Chapter 7 entitled User
Interfaces. In it, the author describes
what is the most important design pattern for any cross-platform projects: the model/view
paradigm (which others know as MVC:
Model-View-Controller). The model is the core logic of the program (which is usually
fairly cross-platform), whilst the view is the user interface portion (typically platform-specific) presented
on behalf of the model. Many programmers make the mistake of mixing this code
together. Logan nicely outlines the benefits for separating these two to
facilitate cross-platform development. With this approach, the developer may
leverage different OS particular tools in GUI design without compromising the
model. The author then describes both native and for cross-platform strategies
for GUI development. This nicely segues into the remaining two chapters, the
first on an existing C++ framework, and the final on how to develop your own.
The main criticism I have for this book is Chapter 8's
narrow examination of cross-platform frameworks. This entire chapter, and a
significant percentage of the book, is devoted exclusively to the wxWidgets toolkit, while only passing references are made to Qt, and no mention at all of any other frameworks like CPLAT. People interested in buying this book would
certainly wish to get an overview of all the options available. The preferred
framework choice of wxWidgets does not appear to come about from the author's opinion that it is the best
one; in fact, he encourages the reader to investigate others such as Qt. Rather, it appears that he chose it because this is
the one used in the development of AOL Communicator (for which he was on the engineering team). This
does not seem to me to be a very compelling reason to exclude all other
frameworks.
Having said that, Chapter 8 is still an excellent
beginning tutorial on wxWidgets. Unlike
native Mac building tools like Xcode and Interface Builder, wxWidgets is very command line-centric, making it rather awkward
for most Mac developers. The information available from the wxwidgets.org web
site is sometimes vague and contradictory, and it is never given from a
Macintosh perspective. Unaided Mac programmers trying out this framework for
the first time often feel like they are pogo-sticking through a minefield,
blindfolded: things explode unexpectedly and without warning. Logan removes
much of the scary mystery by handholding you through all the installation
steps. And not just for the Mac, but also Linux and Windows.
The final Chapter, Developing a Cross-Platform GUI
Toolkit in C++, is a wonderful resource on
building your own C++ cross-platform framework. If you do not need the
complicated awkwardness of wxWidgets,
and if you can ill-afford the outrageous sums demanded by Trolltech for Qt licenses, then rolling your own toolkit may make a
great deal of sense. But where to start? Well this is the chapter for you (and
could itself be a primer for a second book devoted exclusively on the subject).
Putting the pieces you need in place can be both a satisfying and productive
experience. Nor will you need to await some third party to fix a critical bug
that stands in your way when it is your source. Putting his money where his
mouth is, Syd Logan designed and developed Trixul, an open source cross-platform toolkit inspired by
the Netscape/Mozilla toolkit XUL.
Being lightweight and free to use, Trixul is an excellent starting point for those needing to taylor-make their
own C++ framework.
Conclusion
In conclusion, Cross-Platform Development in C++ is a must have by anyone interested in the subject.
More importantly, it treats Mac OS X as a true first class citizen, including a
plethora of Macintosh screen captures. As the Mac OS X marketshare continues to
grow, outpacing even the most optimistic forecasts, developing for multiple
platforms upfront is a great time and money saver. With that in mind, this book
will be a wonderful resource on the desk of any C++ programmer.