Sunday, February 21, 2010

Redistribution of the shared C runtime component in Visual C++

There have been a couple of issues related to the CRT deployment with the MapServer and GDAL binary packages causing the application to fail to run properly, so you might have to keep a couple of things in mind when deploying your application on the target computer. Most of these issues are documented in the related MS articles so refer to these documents for the details.

1. Mixing dll-s compiled with different compilers/ CRT dependencies

This scenario is not supported by Microsoft and you should avoid this according to the following article: Potential Errors Passing CRT Objects Across DLL Boundaries
"When you pass C Run-time (CRT) objects such as file handles, locales, and environment variables into or out of a DLL (function calls across the DLL boundary), unexpected behavior can occur if the DLL, as well as the files calling into the DLL, use different copies of the CRT libraries.
A related problem can occur when you allocate memory (either explicitly with new or malloc, or implicitly with strdup, strstreambuf::str, and so on) and then pass a pointer across a DLL boundary to be freed. This can cause a memory access violation or heap corruption if the DLL and its users use different copies of the CRT libraries." This issue not necessarily cause problems when each dll takes the responsibility to de-allocate the memory it has been allocated within the same dll or executable. However we cannot be certain about this for each dlls deployed along with the MapServer and GDAL binary packages, but we should keep this danger out of the door as the packages have been compiled the with the same compiler and CRT setting (/MD). Just make sure you won't mix the dll-s from different packages within your deployment.

2. Expected locations of the CRT redistributables

"When you build an application in Microsoft Visual Studio, and the application uses the C run-time libraries (CRT), distribute the appropriate CRT DLL from the following list with your application:
  • Msvcr100.dll/Msvcp100.dll for Microsoft Visual C++ 2010
  • Msvcr90.dll/Msvcp90.dll for Microsoft Visual C++ 2008
  • Msvcr80.dll/Msvcp80.dll for Microsoft Visual C++ 2005
  • Msvcr71.dll/Msvcp71.dll for Microsoft Visual C++ .NET 2003 with the Microsoft .NET Framework 1.1
For Microsoft Visual C++ .NET 2003, you should install the CRT DLLs into your application program files directory. You should not install these files into the Windows system directories. For Msvcr80.dll and for Msvcr90.dll, you should install the CRT as Windows side-by-side assemblies." For more information see KB326922 and Redistributing Visual C++ Files. According to the suggestions above I've copied the msvcrt71 dll-s in the packages compiled with MSVC2003. With regards to the MSVC2005/2008 packages you should probably install the corresponding Visual C++ redistributable (vcredist_) package (or incorporate the msm module in your application installer). Make sure to install the package for your desired platform/architecture (x86 or x64)

Microsoft Visual C++ 2005 Redistributable Package (x86)

Microsoft Visual C++ 2005 Redistributable Package (x64)

Microsoft Visual C++ 2008 Redistributable Package (x86)

Microsoft Visual C++ 2008 Redistributable Package (x64)

3. Application manifests

Upon establishing the option of the side-by-side assembly cache (as of Win2003 Server and Windows XP) the binaries (dll-s or executables) should declare their (CRT) dependencies in the application manifest file. Without this declaration the application is a candidate to have the following error: C Run-Time Error R6034. "An application manifest is an XML file that describes and identifies the shared and private side-by-side assemblies that an application should bind to at run time. These should be the same assembly versions that were used to test the application. Application manifests may also describe metadata for files that are private to the application. Application manifests should be included as a resource in the application's EXE file or DLL." Fortunately the dlls and executables in the MapServer and GDAL binary packages contain these manifests embedded as a resource in the binary files (for MSVC2005/2008). This is not an issue with the packages build with MSVC2003 where the CRT implementation is located is the application directory (see #2 above) and not in the shared assembly cache.
Note: For some reason with Visual Studio 2010 Microsoft has reverted the behaviour to VS2003 and no manifests are generated by default. In these cases the CRT dll-s should be installed along with the applications.

4. Licensing issues

In general you should have a valid license for a "VC.NET 2003" product to be able to redistribute msvcr71.dll, please refer to the redist.txt file in your "Visual" product installation folder which files are allowed to be redistributed. This is not the case with the vcredist_ packages (for VS2005/2008) which are allowed to be installed on a per-user basis within the terms of the corresponding EULA.

35 comments:

  1. Tamas,

    It's worth to add that it only applies to Release binaries and that Visual Studio/Visual C++ EULA forbids distributing Debug versions.

    ReplyDelete
  2. Mateusz,

    Did you refer to the Debug version of the CRT libraries or the Debug version of the development target? I don't see any specific restrictions when distributing "your" code. With regards to the Visual Studio components - in most cases - the files enumerated in redist.txt can be redistributed within the terms of the Visual Studio license agreement.

    ReplyDelete
  3. I mean Debug CRT. I rather don't discuss debug binaries that are not linked to Debug CRT as such debug binaries are fairly useless for debugging purposes.

    ReplyDelete
  4. redist.txt doesn't enumerate the debug versions of the CRT dll-s so these files are not redistributable indeed.
    If we don't require advanced CRT debug features (like tracking heap allocation requests) it's not necessary to link against the debug versions using /MD /Zi for the development target would also be sufficient to step into the code in the debugger. However, when using the debug CRT options (like /MDd) it would also be essential to compile all of the dependencies with the same CRT setting to avoid the potential problems described in #1. Having a large number of the libraries in the package (more than 30 in my case) it would be quite a challenging task to modify all the corresponding makefiles or solution/project files this way.

    ReplyDelete
  5. Your post helped me in solving one of my university assignment. Thanks for sharing. C++ in Urdu

    ReplyDelete
  6. I also had problem with Microsoft Visual Studio Msvcr71.dll file on my laptop. You can easily solve. Just download missed .dll library file from http://fix4dll.com/msvcr71_dll and add in into the system32 folder.

    ReplyDelete
  7. I'm also a software engineer, and I love C language so much, I do an internship on software engineer and I'm find Pay Someone To Do My Class For Me, because I've no time to do my academic work please help in my bachelor's academic work.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. The company paper writer offers a full range of services for the preparation of dissertations and other works to order. We have been successfully cooperating in this area for over 16 years. We know how research work can impress the supervisor (consultant) and we do it all the time! See for yourself

    ReplyDelete
  10. Tragically, complaints list mischievous limits we can't respect. Find out about our progression code methodology. Best Discount code site Summer move away is a colossal time for youngsters summer vacation This is an extremely euphoric time for them. During these occasions. A complete travel guide for visiting London from the specialists at Condé Nast Traveler. london travel guide .. Add class to your look with this scandalous overall dress brand that is known to be up-scale with striking quality. Emporio Armani Whether it's California surfing, Maine tide pooling, or Florida swimming that invigorates the pilgrim, Beach Vacations a reasonable ocean side move away is hanging on. Sea side Vacations Grab your markdown code now and set aside to 70% at Fashion Discount code Save up to half with these persistent coupons The most recent coupon codes at voucherpro. Beauty Discount code

    ReplyDelete
  11. It's great for all the readers but we are sharing to all about the nursing students they are also found these writers like best nursing coursework help London is there based in the UK and only focused on education.

    ReplyDelete
  12. Legislative and enforcement jurisdiction must meet the conditions set forth in Article 234, which does not give for unlimited authority, as discussed in the aforementioned essay. One of these standards is a responsibility of due attention to shipping, commonly known as international navigation,    PhD thesis writer USA  which requires that every action be rationally justified using the most up-to-date scientific knowledge. The best dissertation aid can be found at https://essaybishops.com/. Writers in the US who can do PhD dissertations It is unclear what constitutes "due respect," but it stands to reason that jurisdiction should be exercised only to the degree required by the rule's spirit and in a way that is consistent with and proportional to the need to control pollution (ie without unnecessarily encroaching on or arbitrarily denyingthe freedom of navigation in the EEZ) Topics for Research Papers

    ReplyDelete
  13. For a style of the Far East, why not try your likelihood at Dragon Tiger, which effortlessly captures the glitz and glamour of Macau-based brick and mortar casinos. Casino newbies, right by way of to 아벤카지노 the seasoned gamblers, are sure to seek out|to search out} one thing to their liking at Caxino. Evolution are at the very high of their game, and the developer’s stay studio productions showcase their knack for bringing popular game formats into the digital realm with flair. He did so after a few of} spins of the virtual slot reels, serving to himself to a life-altering prize worth €17.8million courtesy of a progressive jackpot game.

    ReplyDelete
  14. Join tens of millions of players and enjoy a unbelievable experience on the net or any system; from PCs to tablets and cell telephones . Welcome bonuses reward players once they make their first real money deposit. The exact terms 1xbet and necessities differ from casino to casino and some presents that appear too good to be true in all probability shall be.

    ReplyDelete



  15. I won't understand much about it prior to viewing your blog and videos, but after doing so, I realized how fantastic it was and how much I wanted to complete it. Many individuals then advised me to get assistance from the expository essay writing service. Should, and I'm now delighted that I may create my own.

    ReplyDelete
  16. The CRT deployment issues with MapServer and GDAL binary packages serve as a reminder to always thoroughly test your deployments before releasing them to the public. It's important to have a reliable partner like Earthwork service texas in USA to ensure your project runs smoothly.

    ReplyDelete
  17. It's important for developers to understand the role of application manifests in declaring dependencies for their binaries. Then there is the best kdk exhaust fan uaeavaible in the region

    ReplyDelete
  18. This is a technical explanation about a potential problem with passing objects across DLL boundaries. It's important to keep in mind when working with DLLs and memory allocation to prevent errors and corruption. Similarly, Car Detailing Ottawa requires attention to detail and proper technique to avoid damaging the vehicle's exterior.

    ReplyDelete
  19. The CRT deployment issues with MapServer and GDAL binary packages can be resolved by following the related MS articles. However, to ensure that your application reaches your target audience, it is important to invest in seo services dubai that can improve your website's search engine ranking and drive more organic traffic to it

    ReplyDelete
  20. The issues related to the CRT deployment in Visual C++ can be critical, especially when it comes to running an application smoothly. It's always important to follow the documentation and guidelines to avoid any mishaps. Similarly, when it comes to chemical injection in UAE, following proper guidelines and precautions is crucial to ensure safety and efficiency in the process.

    ReplyDelete
  21. You may avoid problems and guarantee a smooth deployment by keeping a few important factors in mind. Don't forget to take advantage of the advantages of benefits of double oven which provides increased cooking capacity, flexibility, and efficiency in your kitchen and simplifies meal preparation as you manoeuvre the technical aspects of your programme.

    ReplyDelete
  22. Microsoft Visual C++ is a widely used integrated development environment (IDE) and programming language toolset that allows developers to create and build applications for the Windows operating system. Useful for the explain how duty of care relates to duty of candour it is offering developers a powerful and efficient environment to write, debug, and optimize their code.

    ReplyDelete
  23. I wish to thanks for your great efforts to share us an useful information. Keep sharing us...leyes de divorcio nueva jersey

    ReplyDelete
  24. Thanks to this article I can learn more. Expand my knowledge and abilities. Actually the article is very real. MyAARPMedicare

    ReplyDelete

  25. The redistribution of the shared C runtime component in Visual C++ is a crucial topic for developers, ensuring seamless compatibility across different systems. Similarly, when it comes to Building Demolition in Edmonton, expert planning and execution are essential to ensure safety and efficiency

    ReplyDelete
  26. Navigating the intricacies of shared C runtime components in Visual C++ can be complex. Just like the precision required for the perfect haircut, seek expertise from the Best Barber Shop in Canada for a seamless experience. Both programming and grooming require attention to detail for exceptional results.

    ReplyDelete
  27. Redistribution of the shared C runtime component in Visual C++ discusses a technical aspect in software development. Similarly, streamline your multi-day conference with efficient Multi-day conference catering services in Houston Texas, offering seamless sustenance for productive session

    ReplyDelete
  28. Estate Planning Lawyer
    The redistribution of the shared C runtime component in Visual C++ has received positive feedback from developers and users. The change simplifies deployment, simplifies the installation process, and ensures better compatibility. It reduces the need for end-users to download separate runtime components, making it a win-win for both developers and users. The update is praised for its long-awaited improvements, enhancing the overall user experience and simplifying software distribution. It also reduces the headache of runtime libraries, making it a significant improvement. The changes have already noticed a difference in application performance, making it a step towards more reliable software. The effort Microsoft is putting into enhancing the development experience is appreciated, as the change improves the consistency of runtime components across different applications. This is a win for both developers and users, and it is a testament to Microsoft's commitment to user-friendly software. However, these comments are fictional and provided as an example of the kind of positive feedback expected for improvements in the redistribution of shared C runtime components in Visual C++. Actual experiences and opinions may vary among developers and users.

    ReplyDelete
  29. The redistribution of the shared C runtime component in Visual C++ is a critical consideration for developers. Just as code components are distributed, secure your commercial property with a robust perimeter using commercial chain link fence edmonton—providing both visibility and durability for enhanced security.

    ReplyDelete
  30. Exploring the redistribution of the shared C runtime component in Visual C++—a crucial insight for developers! Just like the meticulous cleaning you'll find with tank cleaning houston, ensuring precision and efficiency in every aspect. Elevate both your coding strategies

    ReplyDelete
  31. Unexpected behaviour can arise when C Run-time (CRT) objects like as file handles, locales, and environment best muscle growth supplements variables are sent into or out of a DLL (function calls across the DLL border) if the DLL and the files calling into the DLL use different versions of the CRT libraries.

    ReplyDelete
  32. The redistribution of the shared C runtime component in Visual C++ is crucial for deploying applications, ensuring proper distribution of runtime libraries for seamless execution across different systems. Developers must handle dependencies meticulously to avoid errors and compatibility issues. Thorough review is essential for a smooth end-user experience. Abogado Conducir Sin Licencia de Condado Essex

    ReplyDelete
  33. The "Redistribution of the shared C runtime component in Visual C++" is a crucial update, emphasizing efficiency in software development. Similarly, Mobile Car Wash services in Ottawa excels in optimizing automotive performance, offering meticulous services that enhance the overall driving experience. Both instances underscore the significance of streamlined processes, whether in coding or car care, ensuring a smooth and reliable outcome

    ReplyDelete
  34. If you're facing divorce related issues then Contact our lawyers today to schedule a consultation. With their experience, focus, and commitment, you can trust us to provide a tenacious defence, safeguarding your rights and working towards the best possible outcome in your case.

    cost of legal separation vs divorce

    ReplyDelete