Cross-Platform Development in C++: Building Mac OS X, Linux, and Windows Applications (Paperback) (跨平台開發:使用 C++ 建立 Mac OS X、Linux 和 Windows 應用程式)
Syd Logan
- 出版商: Addison Wesley
- 出版日期: 2007-11-01
- 定價: $1,820
- 售價: 9.0 折 $1,638
- 語言: 英文
- 頁數: 576
- 裝訂: Paperback
- ISBN: 032124642X
- ISBN-13: 9780321246424
-
相關分類:
C++ 程式語言、Linux、MAC OS 蘋果電腦、Windows App
立即出貨
買這商品的人也買了...
-
$1,080Windows System Programming, 3/e (Hardcover)
-
$880$695 -
$880$695 -
$450$351 -
$720$562 -
$350$298 -
$990$891 -
$600$480 -
$720$612 -
$1,188CCNA Official Exam Certification Library (CCNA Exam 640-802), 3/e
-
$1,200$1,020 -
$1,180$1,003 -
$2,200$2,090 -
$580$458 -
$980$774 -
$680$537 -
$450$351 -
$720$569 -
$490$387 -
$580$458 -
$490$387 -
$960$758 -
$780$663 -
$880$695 -
$690$587
相關主題
商品描述
Description
Cross-Platform Development in C++ is the definitive guide to developing portable C/C++ application code that will run natively on Windows, Macintosh, and Linux/Unix platforms without compromising functionality, usability, or quality.
Long-time Mozilla and Netscape developer Syd Logan systematically addresses all the technical and management challenges associated with software portability from planning and design through coding, testing, and deployment. Drawing on his extensive experience with cross-platform development, Logan thoroughly covers issues ranging from the use of native APIs to the latest strategies for portable GUI development. Along the way, he demonstrates how to achieve feature parity while avoiding the problems inherent to traditional cross-platform development approaches.
This book will be an indispensable resource for every software professional and technical manager who is building new cross-platform software, porting existing C/C++ software, or planning software that may someday require cross-platform support.
Build Cross-Platform Applications without Compromise
Throughout the book, Logan illuminates his techniques with realistic scenarios and extensive, downloadable code examples, including a complete cross-platform GUI toolkit based on Mozilla’s XUL that you can download, modify, and learn from. Coverage includes
- Policies and procedures used by Netscape, enabling them to ship Web browsers to millions of users on Windows, Mac OS, and Linux
- Delivering functionality and interfaces that are consistent on all platforms
- Understanding key similarities and differences among leading platform-specific GUI APIs, including Win32/.NET, Cocoa, and Gtk+
- Determining when and when not to use native IDEs and how to limit their impact on portability
- Leveraging standards-based APIs, including POSIX and STL
- Avoiding hidden portability pitfalls associated with floating point, char types, data serialization, and types in C++
- Utilizing platform abstraction libraries such as the Netscape Portable Runtime (NSPR)
- Establishing an effective cross-platform bug reporting and tracking system
- Creating builds for multiple platforms and detecting build failures across platforms when they occur
- Understanding the native runtime environment and its impact on installation
- Utilizing wxWidgets to create multi-platform GUI applications from a single code base
- Thoroughly testing application portability
- Understanding cross-platform GUI toolkit design with Trixul
Table of Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
Areas That Can Affect Software Portability . . . . . . . . . . . . . . . . . . . 3
The Role of Abstraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1 Policy and Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Item 1: Make All of Your Platforms a Priority . . . . . . . . . . . . . . . . . 17
Item 2: Code from a Common Codebase . . . . . . . . . . . . . . . . . . . . 22
Platform Factory Implementations . . . . . . . . . . . . . . . . . . . . . . . 29
Implementation Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Platform-Specific ProcessesImpl Classes . . . . . . . . . . . . . . . . . . . 32
Creating the Instance Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . 42
Organizing the Project in CVS or SVN . . . . . . . . . . . . . . . . . . . 45
Makefiles and Building the Code . . . . . . . . . . . . . . . . . . . . . . . . . 49
Item 3: Require Developers to Compile Their Code
with Different Compilers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Item 4: Require Developers to Build Their Code on
Multiple Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Item 5: Test Builds on Each Supported Platform . . . . . . . . . . . . . . . 60
Item 6: Pay Attention to Compiler Warnings . . . . . . . . . . . . . . . . . . 61
GNU Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Microsoft Visual C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2 Build System/Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Item 7: Use Whatever Compiler Makes the Most Sense
for a Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Item 8: Use Native IDEs When Appropriate . . . . . . . . . . . . . . . . . . 67
Item 9: Install and Use Cygwin on Windows . . . . . . . . . . . . . . . . . . 71
Item 10: Use a Cross-Platform Make System . . . . . . . . . . . . . . . . . . 76
Make . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Building on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Autoconf/Automake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Imake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Installing on Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Installing on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Using Imake, an Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Imakefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Building a Complete Program from Multiple Sources . . . . . . . . . 95
Overriding Defaults with site.def . . . . . . . . . . . . . . . . . . . . . . . . 99
Eliminating #ifdefs in Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Files Used by Imake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Building Projects with Subdirectories . . . . . . . . . . . . . . . . . . . . 108
Building Debug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3 Software Configuration Management . . . . . . . . . . . . . . . . . . 131
Item 11: Use a Cross-Platform Bug Reporting and
Tracking System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Ability to Track Platform-Specific Bugs . . . . . . . . . . . . . . . . . . 133
Bugzilla . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Item 12: Set Up a Tinderbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Item 13: Use CVS or Subversion to Manage Source Code . . . . . . . 147
Setting Up and Using CVS . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Item 14: Use Patch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Patch Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Dealing with Rejects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Patch and Cross-Platform Development . . . . . . . . . . . . . . . . . . 163
4 Installation and Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Item 15: Provide Support for Native Installers . . . . . . . . . . . . . . . 165
XPInstall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Platform Installs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
5 Operating System Interfaces and Libraries . . . . . . . . . . . . . . . 221
Item 16: Use Standards-Based APIs (For Example, POSIX) . . . . . . 222
POSIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Support for POSIX, SVID, XPG, and BSD . . . . . . . . . . . . . . . 226
Using Standards Support in GCC . . . . . . . . . . . . . . . . . . . . . . . 227
Microsoft Runtime Library Support for POSIX . . . . . . . . . . . . 231
Using GCC on Microsoft Windows . . . . . . . . . . . . . . . . . . . . . 234
Deciding Which Standards to Support . . . . . . . . . . . . . . . . . . . 240
Item 17: Consider Using a Platform Abstraction Library
Such as NSPR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Why NSPR? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
NSPR Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Additional NSPR Functionality . . . . . . . . . . . . . . . . . . . . . . . . 260
6 Miscellaneous Portability Topics . . . . . . . . . . . . . . . . . . . . . . . 273
Item 18: Take Care When Using Floating Point . . . . . . . . . . . . . . . 274
Don’t Serialize Floating-Point Values as Binary . . . . . . . . . . . . 276
Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Item 19: Be Explicit Regarding the Sign of Char Types . . . . . . . . . 278
Item 20: Avoid the Serialization of Binary Data . . . . . . . . . . . . . . 280
Item 21: Avoid Problems Related to the Size and
Organization of Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Size of Integer Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
NSPR and Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Sizes and Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Integer Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Struct Alignment and Ordering . . . . . . . . . . . . . . . . . . . . . . . . . 299
7 User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Item 22: Separate the User Interface from the Model . . . . . . . . . . 304
Separating the User Interface and Application Logic
with Model/View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Using Publish/Subscribe to Communicate between
the View and the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Item 23: Develop a Cross-Platform User Interface Strategy . . . . . . 323
Issues Affecting Portable Cross-Platform GUI
Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Choosing a GUI Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
8 wxWidgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
wxWidgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Installing wxWidgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
A Simple Example: Hello wxWidgets . . . . . . . . . . . . . . . . . . . . 335
Creating the Application User Interface . . . . . . . . . . . . . . . . . . 337
Building wxWidgets Applications . . . . . . . . . . . . . . . . . . . . . . . 345
Controls and Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Container Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
Composite Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
Internationalization and Localization . . . . . . . . . . . . . . . . . . . . 410
9 Developing a Cross-Platform GUI Toolkit in C++ . . . . . . . . . . . 427
What is XUL? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
DHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Scripting Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
The Document Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Style Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
XUL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
Windows and Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Other Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Programming with XUL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Adding Logic to the UI with JavaScript . . . . . . . . . . . . . . . . . . 443
Interfacing JavaScript and C/C++ Code with XPCOM
and XPConnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
Trixul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Widget Support in Trixul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Basic Operation of Trixul . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Implementation Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
Creating Widget Implementation Objects . . . . . . . . . . . . . . . . . 459
Widget Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Application Main Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Steps Taken by Trixul to Create a User Interface . . . . . . . . . . . . 471
Documents, Elements, and the DOM . . . . . . . . . . . . . . . . . . . . 472
Widget Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Scrolled Windows and Layout . . . . . . . . . . . . . . . . . . . . . . . . . 484
Integration with JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Integrating with C++ Components . . . . . . . . . . . . . . . . . . . . . . 496
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
商品描述(中文翻譯)
《C++跨平台開發》是一本關於開發可在Windows、Macintosh和Linux/Unix平台上原生運行的可攜式C/C++應用程式代碼的權威指南,不會影響功能、易用性或質量。
長期從事Mozilla和Netscape開發的Syd Logan系統地解決了與軟體可攜性相關的所有技術和管理挑戰,從規劃和設計到編碼、測試和部署。借助他在跨平台開發方面的豐富經驗,Logan全面涵蓋了從使用本地API到最新的可攜式GUI開發策略的各種問題。在此過程中,他演示了如何實現功能平衡,同時避免傳統跨平台開發方法固有的問題。
本書將成為每個正在開發新的跨平台軟體、移植現有C/C++軟體或計劃將來可能需要跨平台支援的軟體的軟體專業人員和技術經理的必備資源。
在整本書中,Logan通過實際情境和大量可下載的代碼示例來闡明他的技術,包括一個基於Mozilla的XUL的完整跨平台GUI工具包,您可以下載、修改和學習。內容包括:
- Netscape使用的政策和程序,使他們能夠在Windows、Mac OS和Linux上向數百萬用戶提供網頁瀏覽器
- 在所有平台上提供一致的功能和界面
- 了解領先的平台特定GUI API(包括Win32/.NET、Cocoa和Gtk+)之間的主要相似性和差異
- 確定何時使用本地IDE,何時不使用以及如何限制其對可攜性的影響
- 利用基於標準的API,包括POSIX和STL
- 避免隱藏的可攜性問題