没有合适的资源?快使用搜索试试~ 我知道了~
Dynamic Library Programming Topics
需积分: 0 5 下载量 147 浏览量
2008-08-21
11:03:37
上传
评论
收藏 751KB PDF 举报
温馨提示
试读
82页
介绍动态库编程,包括MAC机上的动态库编程
资源详情
资源评论
资源推荐
Dynamic Library Programming Topics
2006-11-07
Apple Computer, Inc.
© 2006 Apple Computer, Inc.
All rights reserved.
No part of this publication may be
reproduced, stored in a retrieval system, or
transmitted, in any form or by any means,
mechanical, electronic, photocopying,
recording, or otherwise, without prior
written permission of Apple Computer, Inc.,
with the following exceptions: Any person
is hereby authorized to store documentation
on a single computer for personal use only
and to print copies of document ation for
personal use provided that the
documentation contains Apple’s copyright
notice.
The Apple logo is a trademark of Apple
Computer, Inc.
Use of the “keyboard” Apple logo
(Option-Shift-K) for commercial purposes
without the prior written consent of Apple
may constitute trademark infringement and
unfair competition in violation of federal
and state laws.
No licenses, express or implied, are granted
with respect to any of the technology
described in this document. Apple retains
all intellectual property rights associated
with the technology described in this
document. This document is intended to
assist application developers to develop
applications only for Apple-labeled or
Apple-licensed computers.
Every ef fort has been made to ensure that
the information in this document is
accurate. Apple is not responsible for
typographical errors.
Apple Computer, Inc.
1 Infinite Loop
Cupertino, CA 95014
408-996-1010
Apple, the Apple logo, Carbon, Cocoa,
iTunes, Mac, and Mac OS are trademarks
of Apple Computer, Inc., registered in the
United States and other countries.
Objective-C is a registered trademark of
NeXT Software, Inc.
Simultaneously published in the United
States and Canada.
Even though Apple has reviewed this document,
APPLE MAKES NO WARRANTY OR
REPRESENTATION, EITHER EXPRESS OR
IMPLIED, WITH RESPECT TO THIS
DOCUMENT, ITS QUALITY, ACCURACY,
MERCHANTABILITY, OR FITNESS FOR A
PARTICULAR PURPOSE. AS A RESULT, THIS
DOCUMENT IS PROVIDED “AS IS,” AND
YOU, THE READER, ARE ASSUMING THE
ENTIRE RISK AS TO ITS QUALITY AND
ACCURACY.
IN NO EVENT WILL APPLE BE LIABLE FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES
RESULTING FROM ANY DEFECT OR
INACCURACY IN THIS DOCUMENT, even if
advised of the possibility of such damages.
THE WARRANTY AND REMEDIES SET
FORTH ABOVE ARE EXCLUSIVE AND IN
LIEU OF ALL OTHERS, ORAL OR WRITTEN,
EXPRESS OR IMPLIED. No Apple dealer, agent,
or employee is authorized to make any
modification, extension, or addition to this
warranty.
Some states do not allow the exclusion or
limitation of implied warranties or liability for
incidental or consequential damages, so the
above limitation or exclusion may not apply to
you. This warranty gives you specific legal
rights, and you may also have other rights which
vary from state to state.
Contents
Introduction to Dynamic Library Programming Topics 7
Organization of This Document 7
See Also 8
Overview of Dynamic Libraries 9
What Are Dynamic Libraries? 9
How Dynamic Libraries Are Used 11
Dynamic Library Design Guidelines 15
Designing an Optimal Dynamic Library 15
Managing Client Compatibility With Dependent Libraries 16
Defining Client Compatibility 16
Specifying Version Information 18
Specifying Your Library’s Interface 19
Deciding What Symbols to Export 19
Naming Exported Symbols 20
Symbol Exporting Strategies 20
Locating External Resources 24
Library Dependencies 24
Module Initializers and Finalizers 25
C++–Based Libraries 27
Exporting C++ Symbols 27
Defining C++ Class Interfaces 28
Creating and Destroying C++ Objects 28
Objective-C–Based Libraries 30
Defining Class and Category Interfaces 31
Initializing Objective-C Classes 33
Creating Aliases to a Class 34
Design Guidelines Checklist 34
Dynamic Library Usage Guidelines 35
Opening Dynamic Libraries 35
The Library Search Process 36
Specifying the Scope and Binding Behavior of Exported Symbols 37
3
2006-11-07 | © 2006 Apple Computer, Inc. All Rights Reserved.
Using Symbols 39
Using Weakly Linked Symbols 42
Using C++ Classes 43
Using Objective-C Classes 45
Getting Information on an Address 47
Creating Dynamic Libraries 49
Creating Libraries 49
Defining the Library’s Purpose 50
Defining the Library’s Interface 50
Implementing the Library 51
Setting the Library’s Version Information 53
Testing the Library 53
Updating Libraries 57
Making Compatible Changes 57
Updating the Library’s Version Information 60
Testing the New Version of the Librar y 61
Using Dynamic Libraries 67
Installing Dependent Libraries 67
Using Dependent Libraries 68
Using Runtime Loaded Libraries 71
Interposing Functions in Dependent Libraries 73
Logging Dynamic Loader Events 79
Document Revision History 81
4
2006-11-07 | © 2006 Apple Computer, Inc. All Rights Reserved.
Figures, Tables, and Listings
Overview of Dynamic Libraries 9
Figure 1 Application using static libraries 10
Figure 2 Application using dynamic libraries 11
Dynamic Library Design Guidelines 15
Figure 1 The life cycle of a dynamic library and a client 17
Listing 1 A simple dynamic library 21
Listing 2 Person module hiding a symbol with the static storage class 22
Listing 3 File listing the names of the symbols to export 23
Listing 4 Person module using visibility attribute to export symbols 23
Listing 5 Inifi initializer and finalizer definitions 25
Listing 6 The Trial.c file 26
Listing 7 Execution order of a dynamic library’s initializers and finalizers 26
Listing 8 Definition of a static initializer 27
Listing 9 Declaration for the Person class 28
Listing 10 Interface and implementation of a C++ class in a dynamic library 28
Listing 11 Client using a C++ class implemented in a r untime loaded library 29
Listing 12 Header and implementation files of the Person class 31
Listing 13 Header and implementation files of the Titling category to t he Person class
32
Listing 14 Client using the Person library 32
Dynamic Library Usage Guidelines 35
Figure 1 Application with dependent library hierarchy 40
Table 1 Environment variables that define dynamic-loader search pat hs 36
Listing 1 Bindings resolved during call to dlopen using immediate binding 38
Listing 2 Application image using symbols exported by dependent libraries through
undefined external references 40
Listing 3 Application image using a symbol exported by a dynamic library loaded at
runtime 41
Listing 4 Library image using an interposed symbol 41
Listing 5 Application image calling an interposed function 42
Listing 6 Header file with a weakly linked symbol declaration 42
Listing 7 Using a weakly linked symbol 43
Listing 8 C++ class interface 43
Listing 9 Client using a C++ runtime loaded class 44
5
2006-11-07 | © 2006 Apple Computer, Inc. All Rights Reserved.
剩余81页未读,继续阅读
kevin_yuanhui
- 粉丝: 4
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0