Binding to the Most Recent Visual Studio Libraries--说的很详细,很清楚
Every version of Visual Studio comes with certain versions of the Microsoft libraries, such as the C runtime library, the MFC library, and so on. For example, Visual Studio 2008 comes with version 9.0.21022.8 of the Microsoft C runtime library and version 9.0.21022.8 of the MFC library. You can easily check which version your application needs by checking its manifest. For example: open Visual Studio 2008 and start a new MFC dialog-based application. Activate the release build configuration and build the test application. Once it is built, open a command prompt from inside Visual Studio, go to Tools Visual Studio 2008 Command Prompt. Go to the folder containing the executable youve just built and use the following command to extract the manifest from your executable:
mt.exe -inputresource:bindingtest.exe -out:manifest.txtwhere bindingtest.exe is the name of your executable. The file manifest.txt will contain the exported manifest. The manifest for this test application, built using Visual Studio 2008, will look like the following:
What you see in this output is that your executable is dependent on the Microsoft C Runtime version 9.0.21022.8 and on the MFC library version 9.0.21022.8.
When you install the Visual Studio 2008 Service Pack 1, new versions of those libraries will be installed. However, by default, Visual Studio will keep linking to the old libraries unless you explicitly tell it to use the new versions. How to Force Visual Studio to Bind to the New LibrariesMicrosoft has defined a certain number of preprocessor definitions to tell the compiler/linker what version of the libraries to use. These definitions are also described in the MSDN. These definitions are:
The above defines allow you to tell the compiler/linker to use the latest version of the CRT, ATL, MFC and/or OpenMP libraries. To make it a bit easier, the following definition will bind to the latest version of all Visual Studio libraries:
#define _BIND_TO_CURRENT_VCLIBS_VERSION 1Try this in your example project. Go to Project xyz Properties. In the project properties window, select Configuration Properties C/C++ Preprocessor and edit the "Preprocessor Definitions." Right now, it probably is something like this:
WIN32;_WINDOWS;NDEBUGChange this to:
WIN32;_WINDOWS;NDEBUG;_BIND_TO_CURRENT_VCLIBS_VERSION=1Close the properties window and rebuild your application. After rebuilding, extract the manifest from the Visual Studio 2008 Command Prompt.
mt.exe -inputresource:bindingtest.exe -out:manifest.txtThe new manifest will look like the following:
Now the manifest tells you that your new application is dependent on version 9.0.30729.1 of the C Runtime and on version 9.0.30729.1 of MFC; these are the versions installed by Service Pack 1.
In real life, your application is much more complicated and will probably link to some other libraries, either third-party libraries or your own libraries. To ensure that your final application only depends on the latest version of the Visual Studio libraries, you need to make sure that all your other libraries are also only dependent on the latest version. For example, if you have a library that is still dependent on version 9.0.21022.8 of the C Runtime and you link it with your new application, your manifest might look like:
Which means it will need both version 9.0.21022.8 and version 9.0.30729.1 of the CRT.
If you are linking with libraries (.lib) files, you can use dumpbin to check what version of the libraries that lib file needs. For example:
dumpbin /directives name .libThe output might contain something like the following:
telling you it probably will force a dependency on version 9.0.21022.8 of the Microsoft CRT into your final manifest.
Its also important to know that the MSM merge modules that you can find in Program Files\Common Files\Merge Modules are updated to the new version when installing the Visual Studio 2008 service pack. This means that if your application is still dependent on the old version of the libraries and you are using the merge modules in your setup project, it will not work. In other words, if you want to keep using those merge modules, you are forced to use the latest version of the Visual Studio libraries.
In conclusion, if you want to link to the latest Visual Studio libraries, make sure all libraries that you are linking with are also using the latest version of the Visual Studio libraries.
相关文章
- 在Visual Studio 中使用git——同步到远程服务器-上(十一)
- Visual Studio提示“无法启动IIS Express Web服务器”的解决方法
- Visual Tracking with Fully Convolutional Networks
- C#学习记录——调试和错误处理:Visual Studio中的调试(一):非中断(正常)模式下的调试
- visual studio 2013 for windows desk报error MSB8020: The build tools for v141错误
- visual studio 2013常用快捷键
- UE4与Visual Studio版本对应关系
- 【Visual-Hull + Bregman】基于Visual-Hull + Bregman算法的三维重建算法matlab仿真
- 在Visual Studio中使用用例图描述参与者与用例的关系
- Developing ASP.NET Core Apps by Using Visual Studio Code
- Visual Studio 2019更新到16.2.3
- Visual Studio 2017强制更新方法
- Visual Studio Xamarin中找不到iOS模拟器
- 《Visual Studio程序员箴言》---- 1.5 状态栏
- 《数字图像处理与机器视觉——Visual C++与Matlab实现(第2版)》——1.2 数字图像处理与机器视觉
- windows 下使用cmake指定visual studio 版本
- Visual Studio新建的源文件的默认编码
- Visual studio C++程序内使用Sqlite3
- Visual studio C++桌面应用程序添加外部文件引用
- Visual Studio® 2010 Web Deployment Projects站点编译生成bin同时发表插件
- Unity 基础 之 Visual Studio(VS) 中的 断点调试在 Unity 中的简单使用
- [转]Visual Studio 2013 离线版msdn下载和安装