locked
How to build your own versions of the VS 2010 CRT? RRS feed

  • Question

  • In the previous 2 versions of Visual Studio, along with the CRT source, a batch file, make file and other tools were supplied to build your own (private) copy of the CRT libraries. I wish to be able to do the same with the VS 2010 CRT, to be able to optimize the CRT for speed, using my preferred compiler flags, and to provide more backwards compatibility for OS used. The source code is available after installation in a few hundred c/cpp files, but not the tools to build the DLLs like before, or any information about which files to include.

    How would I go about building the .DLLs myself for this version of MSVC? There is no documentation about it, apparently, apart from scattered mentions that "scripts to build the CRT are no longer supplied in VS 2010" -- Which basically makes the CRT src completely useless, as there is no way to build it without having the necessary information in the form of either a project file or makefiles/scripts...

    Any idea why this was crippled? It makes no sense to me, at least.

    Thanks in advance for any pointers/work instructions to get rolling with VS 2010 - I'd hate to have to resort to older versions which have given me the necessary headaches with internal compiler errors, etc.

    Saturday, May 7, 2011 10:21 AM

Answers

  • It is documented as no longer supported in the VC documentation itself. They seemed to have stuck it in a corner out of the way though as it gets a small mention in the Breaking Changes in Visual C++ part of the VC2010 documentaion.

    As to why it was crippled no idea.

    As far as ways of getting it working, I had read someone was trying to use the VC2008 stuff to build them, but I never checked up on it after that. But the biggest problem is that you don't have the complete CRT source. The C++ exception handling mechanism and a few other things have always been missing, and if you check 2008 you will notice that there are some .obj and .lib files in the CRT build directories. You would either have to reimpliment these, or copy them over and hope nothing has changed in any of them between 2008 and 2010.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://ccprogramming.wordpress.com/
    • Marked as answer by Rob Pan Friday, May 13, 2011 9:18 AM
    Saturday, May 7, 2011 3:54 PM
  • The CRT source is useful for debugging. If you end up with an assertation failure or an access violation in one of the CRT functions, it allows you to break and see what line it is on. It then allows you to get parameters passed in so you have full details at the crash site so when you go up the call list you can see where it could be going wrong.

    As for any chance of them allowing the CRT to be built. If there is enough demand then maybe, but nothing changed with VS2010 SP1 so it would be VC11 at the earliest if this changes.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://ccprogramming.wordpress.com/
    • Marked as answer by Rob Pan Friday, May 13, 2011 9:18 AM
    Saturday, May 7, 2011 6:14 PM

All replies

  • It is documented as no longer supported in the VC documentation itself. They seemed to have stuck it in a corner out of the way though as it gets a small mention in the Breaking Changes in Visual C++ part of the VC2010 documentaion.

    As to why it was crippled no idea.

    As far as ways of getting it working, I had read someone was trying to use the VC2008 stuff to build them, but I never checked up on it after that. But the biggest problem is that you don't have the complete CRT source. The C++ exception handling mechanism and a few other things have always been missing, and if you check 2008 you will notice that there are some .obj and .lib files in the CRT build directories. You would either have to reimpliment these, or copy them over and hope nothing has changed in any of them between 2008 and 2010.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://ccprogramming.wordpress.com/
    • Marked as answer by Rob Pan Friday, May 13, 2011 9:18 AM
    Saturday, May 7, 2011 3:54 PM
  • I have noticed there are some binary files in VS 2005 and 2008 CRT src directories, and of course it's fine to keep the exception handling and other parts proprietary if Microsoft wants - that's entirely up to them, after all.

    So.. if I understand correctly, it's simply not possible to build the VS 2010 CRT, unless you somehow, magically, re-implement parts of the source yourself that are nowhere specified nor documented. From scratch, reproducing what Microsoft has kept in-house for their own build methods for msvcrt100.dll and msvcp100.dll.

    I seriously doubt nothing will have changed in the binary parts, considering the quite noticeable changes otherwise in the RT functions. Simply copying the binary parts over is asking to break stuff.

    Then.. why supply CRT/src to begin with, if you are going to blackbox it anyway, and make it impossible to use? Why not simply NOT supply it at all and be clear about not wanting to disclose (part of) the source of the runtime? Seriously.

    I guess the only way to actually build the CRT ourselves would be if MS releases the parts that are missing, like they have done in the previous editions of MSVC... Any chance of that happening?

    Saturday, May 7, 2011 5:00 PM
  • The CRT source is useful for debugging. If you end up with an assertation failure or an access violation in one of the CRT functions, it allows you to break and see what line it is on. It then allows you to get parameters passed in so you have full details at the crash site so when you go up the call list you can see where it could be going wrong.

    As for any chance of them allowing the CRT to be built. If there is enough demand then maybe, but nothing changed with VS2010 SP1 so it would be VC11 at the earliest if this changes.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://ccprogramming.wordpress.com/
    • Marked as answer by Rob Pan Friday, May 13, 2011 9:18 AM
    Saturday, May 7, 2011 6:14 PM