Redistributing an Application and Binding It to Specific Libraries


Visual Studio 2008

Updated: July 2008

The libraries for Visual Studio often are updated after a release. For example, this can occur when you install a service pack. Applications that are designed with the updated libraries might depend on some changes that were made in the latest releases. The application might behave in unexpected ways if you transfer it to a user who has not installed the same libraries. To protect against this unexpected behavior, you can bind your application to a specific version of the libraries.

Default Binding Behavior


This section describes the default behavior of applications compiled with Visual C++ 2008 and later releases. When you compile an application, it is bound to the original release version of libraries available. This is true even if you have a later release installed on your computer. For example, if you have Visual C++ 2008 SP1 installed on your computer, any applications that you compile on this computer will still depend on the original release version of Visual C++ 2008.

This behavior is of no consequence if you deploy your application by installing in a central location. By using this distribution scheme, the latest libraries will always be available to the end user. However, if you use a local deployment method, such as with private assemblies as described in the topic How to: Deploy using XCopy, this behavior is important.

The default binding behavior enables you to recompile your program after you obtain a new release, and to distribute the new executable. The end users who already installed the necessary libraries will need only the new executable; you will not have to package and reinstall the latest libraries.

NoteNote:

If your application depends on functionality introduced in the latest release, you must distribute and reinstall the new libraries, or else the application will not run.

How to Bind to Specific Versions


If you want to force your application to require that the latest libraries be installed on your computer, use one or more of the following lines of code:

Copy

#define _BIND_TO_CURRENT_CRT_VERSION 1
#define _BIND_TO_CURRENT_ATL_VERSION 1
#define _BIND_TO_CURRENT_MFC_VERSION 1
#define _BIND_TO_CURRENT_OPENMP_VERSION 1

Use the following line of code to bind your application to the current version of all your Visual C++ libraries. This is a union of all the previous lines of code.

Copy

#define _BIND_TO_CURRENT_VCLIBS_VERSION 1;

NoteNote:

We recommend that you define these macros at the command-line level. If you prefer to include the definitions in code, you must put them at the very start of every compilation unit - such as the first lines in stdafx.h.

When you bind your application to a set of libraries, it will not run on a computer that has an earlier version of those libraries. If you bind your application to a specific minimum version, we recommend that you ship your application together with the required version of the libraries.

See Also


Concepts

Redistributing Visual C++ Files


本文转自海天一鸥博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2010/09/19/1831306.html,如需转载请自行联系原作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值