RCode

a software development blog by Bojan Resnik

  • Archives

Using Visual Studio 2008 with Visual C++ 6.0 compiler

Posted by Bojan Resnik on October 28, 2009

04/11/2010 Update: If you are interested in using older compilers with Visual Studio 2010, there is an interesting solution by Owen Wengerd, described here.

The Microsoft Visual C++ 6.0 is a product that has been present for a long time. A lot of software was written with it, carefully tailored around the many bugs of the compiler. The IDE itself is not too pretty and lacks a lot of functionality that we expect modern IDEs to have. It’s a pitty that we have to use it to maintain legacy code.

Well, turns out this is not the case. There is a way to use the Visual Studio 2008 IDE with all its capabilities, and have it compile the code using Visual C++ 6.0 compiler. There is some fiddling with options to be done in order to have everything compile and link without errors, but I find that once the project is set up I can enjoy the features of Visual Studio 2008.

works-on-my-machine-starburst_3 Works On My Machine Disclaimer: This is released with exactly zero warranty or support. If it deletes files or kills your family pet, you have been warned. It might work great, and it might not.

Starting Visual Studio 2008 with Visual C++ 6.0 Environment

All Visual Studio IDEs since the ancient Visual Studio 6.0 have had a convenient switch: /useenv. The documentation for the switch states the following:

Starts Visual Studio and uses the environment variables for PATH, INCLUDE, LIBS, and LIBPATH in the VC++ Directories dialog box.

Combined with the vcvars32.bat file that Visual Studio installations traditionally create, this switch gives us the ability to run any Visual Studio IDE with any version of the compiler and support tools. That’s in theory, of course. I only tried Visual Studio 2005 and Visual Studio 2008 IDEs with Visual C++ 6.0 tools.

For convience, I have a batch file that first sets up the environment for Visual C++ 6.0 and then starts Visual Studio 2008 with the /useenv switch:

call "C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
start "" "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /useenv

I use ‘start’ instead of directly running devenv.exe in order to immediately close the window that opens for the batch file. ‘start’ command will run devenv.exe asynchronously and the process started for the batch file will exit. Of course, the paths in the batch file are specific to my machine. They may be different on other systems, depending on where the products have been installed.

Setting C++ Compiler Options

The first part is done – Visual Studio 2008 has been started and it will use the correct environment settings. To verify this, go to Tools/Options/Projects and Solutions/VC++ Directories. You should see something similar to this:

image

Notice that the first four paths actually reference folders in the Visual C++ 6.0 installation. You will find similar references in “Include files” and “Library files” directories.

This all looks great, but if you create a new VC++ console application and try to build it, you will be greeted with some errors:

image

As the compilers have evolved, so have their options. The VS 2008 IDE supports more options than the old VC6 compiler. In order for the IDE to pass correct options to the VC6 compiler, we need to do some tweaking.

The first warning above comes from an apparently unknown option related to error reporting. A quick search through the properties of the project gives us this:

image

Setting this option to Default will cause it to be omitted from the options passed to the compiler.

The other two problematic messages involve a strange character. When compiling, IDE first creates a special file (called response file) containing all options for the compiler, including the names of the source files and the compiler reads this file to determine what needs to be done. In Visual Studio 6.0 that file is regular ASCII text file, while newer versions of Visual Studio use Unicode encoding by default. To instruct Visual Studio 2008 not to use Unicode, we need to set options for the compiler and for the linker:

image

image

Setting these option to No will cause the response files to be created as plain ASCII, just as the VC6 compiler needs. If you have a static library project, you would have to do this in the librarian’s options as well.

After these changes, we can build the project again:

image

Again, hunting for the /RTC1 option brings us to this property screen:

image

Setting the Basic Runtime Checks to Default will again solve the warning issue.

The linker’s /INCREMENTAL option was supported in VC6, but with a different syntax. In VC6 you can use either /INCREMENTAL:YES or /INCREMENTAL:NO, but you can’t specify /INCREMENTAL by itself. Fortunately, we don’t have to give up incremental linking, but we have to specify the correct option manually. First, we need to set the Enable Incremental Linking option to Default:

image

Then, we need to manually include this option in linker’s Command Line:

image

Compiling again will produce some new issues:

image

The actual error here is that the IDE is instructing the linker to create a manifest file, which is not supported by VC6 linker. To turn this off, we need to go to linker’s Manifest File properties:

image

And set the Generate Manifest option to No. In order to take care of the other unknown options DYNAMICBASE, NXCOMPAT and ERRORREPORT:PROMPT, we need to go to linker’s Advanced properties and set the corresponding properties to Default:

image

Compiling now finally yields an error-free output:

image

The linker warning here cannot be removed, but is completely harmless.

Incremental Building

Although everything compiles and links now, you will soon notice that the enitre project is being rebuilt every time. It seems that Visual Studio determines what needs to be built by reading the program database that is created by the compiler, and it expects the database to have a certain name. By default, Visual Studio 2008 uses vc90.pdb as the name of the program database, but Visual Studio 6.0 uses vc60.pdb. To change this, open the C/C++ properties window again:

image

After this, your project will rebuild once again and generate the vc60.pdb database. Subsequent builds should be incremental, as expected.

Wrapping It All Up

Depending on your project’s requirements and options, you might need to tweak some more options. However, the two techniques presented here (setting to Default and manually specifying in Command Line) should get you through it. In the end, it is up to you to decide whether it is all worth it. To me, having a much better debugger and not needing to close the solution in order to attach it to a process are more than worth a little fiddling with options.

04/11/2010 Update:

As Christian I reported in the comments, you might need to add compiler options /FD /GR /GX and linker options /pdbtype:sept /machine:I386.

88 Responses to “Using Visual Studio 2008 with Visual C++ 6.0 compiler”

  1. JD said

    Great post!

    There’s only one thing that isn’t working for me: Incremental building.

    Everytime I build my project in VS2008, it builds it from scratch. Being a rather large (huge) project, it takes something like 1 to 1.5 hours to compile. I have followed your guide to the letter (especially the /INCREMENTAL:YES part), still it’s no go.

    Can you help me somehow?

    • Bojan Resnik said

      /INCREMENTAL:YES is a linker option, but your project is being rebuild before it ever reaches the linker. For some reason, the VS2008 IDE seems to think you need a rebuild.

      Can you try going into Properties/C++/Output Files and setting the program database file name to $(IntDir)\vc60.pdb?

      Let me know if this helped.

      • JD said

        Thanks for the quick answer 🙂

        Just did that, and it started from the beginning again. However, I stopped the compilation and started it again, and this time it didn’t recompile the files which were already compiled.

        I will let it finish the compilation (hope it ends before the work day is over 😀 ), and then report back.

        Thanks again!

        • Bojan Resnik said

          The initial rebuild was supposed to happen, because the program database file was changed and had to be recreated.

          Did subsequent builds behave correctly?

          • thedarkpt said

            Hey, I’m JD, only I’m logged in now 😀

            I think the problem described above is solved, but can’t be sure yet.

            The compilation did not finish in time for me to see the result before going home, so I left it finishing, and when I came back today, it had an error stating something like “vc60.pdb doesn’t contain all the information”, something along those lines.

            So I cleaned up the solution, and am now waiting for it to finish.

            I’ll come back when it finishes.

          • thedarkpt said

            I’m giving up for now. Can’t spend any more time around this, I’ll be back to it next week, probably.

            Thanks again for your time, and for the article!

            • Bojan Resnik said

              No problem, glad to be of assistance. I take it that your project is still compiling? Or did you receive another error?

              • thedarkpt said

                I have compiled it 3 times today, now compiling a 4th on VC++ 6.0.

                The vc60.pdb error persisted, and I really need to get some work done, so I’m leaving it for now.

                • Bernd Schneider said

                  Thank you for the tutorial and espacially for the fix of the program database file name – it works perfect for me now. using VS2008 instead of VC98 is a blast 🙂

  2. Johan said

    Hello
    Great tutorial its just what i needed
    i got a few questions though, first one is i keep getting this warnings now:

    C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\vector(47) : warning C4786: ‘std::vector<std::basic_string<char,std::char_traits,std::allocator >,std::allocator<std::basic_string<char,std::char_traits,std::allocator > > >::vector<std::basic_string<char,std::char_traits,std::allocator >,std::allocator<std::basic_string<char,std::char_traits,std::allocator > > >’ : identifier was truncated to ‘255’ characters in the debug information

    and also is there a way to save this project settings so i don’t need to redo this every time i create a new project? thanks

    • Bojan Resnik said

      The warning is expected and entirely harmless. You can disable it in a couple of ways:

      1. Using a command line option
      The command line option is /wd4786 and you can put it in C++/Command Line box in the properties of your project.
      I’m not sure, but I seem to remember that this option didn’t work for some warnings, though I can’t remember which.

      2. Using a #pragma directive
      Put the following at the top of your precompiled header file (usually stdafx.h), below `#pragma once` line:
      #pragma warning(disable:4786)

      I am not aware of a straightforward way to save the settings and reuse them. An option would be to write a custom project wizard that would generate the projects with all required settings.

  3. umesh said

    I have created one application in VS2005. It is working perfectly. But when i am building same application in VS 2008 it is showing these errors please help.

    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(771) : error C2065: ‘T’ : undeclared identifier
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(818) : error C2061: syntax error : identifier ‘T’
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(774) : error C2065: ‘T’ : undeclared identifier
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(820) : error C2065: ‘ppT’ : undeclared identifier
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(821) : error C2065: ‘ppT’ : undeclared identifier
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(823) : error C2065: ‘ppT’ : undeclared identifier
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(839) : error C2065: ‘T’ : undeclared identifier
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\atlbase.h(847) : error C2065: ‘T’ : undeclared identifier

    • Bojan Resnik said

      Do you mean that the application is compiled with Visual Studio 6.0 under VS 2005 or that it is a regular VS 2005 application?

      If the former, then most probably you did not run the vcvars32.bat file that came with Visual Studio 6.0 or you did not supply the /useenv switch when starting VS 2008.

  4. ariel said

    can you please tell me how to get my settings back to its original?

    • Bojan Resnik said

      To start Visual Studio 2008 with its own compiler, simply run it as you usually would, e.g. by clicking its icon in the Start menu. If you don’t use the /useenv switch, Visual Studio sets its own environment and uses its own compiler.

  5. A. Auer said

    Hi there… I have set everything up as described here, and it works about 60% of the time. The other 40%, it also appears to compile (or else will be partway through either compiling or linking) and then VS2008 (the entire environment) will crash out completely, and I’ll have to start it again.

    Have you (or indeed anyone reading this post) seen this? Do you have any idea what might be causing it?

    I’m considering just throwing all my compile options into a makefile and avoiding the build process from within the IDE, but that would be a pain. I’m hoping you might be able to make an educated guess.

    Thanks so much for this blog entry, I’m really excited to be able to dump the VC6 environment.

    • Bojan Resnik said

      I’ve never seen that happen, with or without VC6 – VS 2008 has been remarkably stable for me. I’ve been using VS 2005 and VS 2008 with VC6 compiler for almost two years without any problems.

      Is your Visual Studio stable without VC6? Do you have the latest service packs for VC6 *and* VS 2008 installed?

      • A. Auer said

        Heh… no, VC6 service pack isn’t installed. I’ll try to get local admin on my machine and install it an post back.

        Thanks for the quick response!

  6. A. Auer said

    Duh. Sometimes we (read: I) need someone to point out the obvious.

    Yeah, installing the service packs worked. The compile is executing exactly as you describe above.

    Thanks again for the help… I’m overjoyed to not have to load the VC6 IDE anymore.

  7. Ganesh said

    does this work with 2010 as well??

    • Bojan Resnik said

      I haven’t tried it, but if VS2010 supports /useenv switch it should work.

      Regards,
      Bojan

  8. Alex Bryant said

    Hi, I’m about to try and get this to work with vs2010. Any last minute updates? Stay tuned!

    Thanks,
    Alex

    • Alex Bryant said

      Well, here’s the error I’m getting now:

      >—— Rebuild All started: Project: icsrvnt, Configuration: Debug Win32 ——
      1>Build started 6/11/2010 2:18:10 PM.
      1>_PrepareForClean:
      1> Deleting file “.\Debug\icsrvnt.lastbuildstate”.
      1>InitializeBuildStatus:
      1> Touching “.\Debug\icsrvnt.unsuccessfulbuild”.
      1>ClCompile:
      1> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80×86
      1> Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
      1>
      1> cl  ■/
      1>
      1>CL : Command line warning D4024: unrecognized source file type ‘ ■/’, object file assumed
      1> Microsoft (R) Incremental Linker Version 6.00.8447
      1> Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
      1>
      1> /out:.exe
      1>  ■/
      1>LINK : fatal error LNK1181: cannot open input file ” ■/.obj”
      1>
      1>Build FAILED.
      1>
      1>Time Elapsed 00:00:00.84
      ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

  9. Sushil Gandhi said

    Bojan,

    Have you tried or have any ideas on how to install/run Visual Studio 6.0 Compiler under windows 7. As you must know VS 6.0 is not supported in Windows 7 and would not install on 7.

    Any Ideas would be appreciated as we have large projects which are still under VS 6.0 and need to be compiled under winows 7, as we are planning the migration from Xp to Windows 7.

    Thanks!
    Sushil

    • Bojan Resnik said

      Sushil,

      Actually, I’ve been running VS6.0 on Windows 7 x64 for several months now, without any problems. I don’t remember having any installation issues either. I do not run the VS6 IDE, but the command line tools work as expected.

      If you are having installation issues, you might try disabling UAC and explicitly running the VS6 setup as administrator.

      Cheers,
      Bojan

      • BatKing said

        Hi,

        the Visual studio 6.0 C++ IDE will crash immediately on Windows 7 64 bit when opening a existing VS 6.0 C project which is working perfectly fine under windows XP 32 bit. the error is the devdbg.pkg. I don’t have any problem during installation (run setup.exe as administrator and UAC turned off). also SP6 installed fine. VB 6.0 also works. but VC++ crashes. Here is the error from Event Viewer

        Faulting application name: msdev.exe, version: 6.0.9782.2, time stamp: 0x40400977
        Faulting module name: devdbg.pkg, version: 6.0.8804.0, time stamp: 0x38ce5149
        Exception code: 0xc0000005
        Fault offset: 0x0004b182
        Faulting process id: 0x1074
        Faulting application start time: 0x01cb53e4101c59a0
        Faulting application path: C:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98\Bin\msdev.exe
        Faulting module path: C:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98\Bin\IDE\devdbg.pkg
        Report Id: 4f52f54e-bfd7-11df-8f2f-78dd08ab5f91

        • Jawahar said

          Hi,
          I am having the same problem… Could you solve this issue. If so can you please tell me how you overcame this problem.

          Warm regards,

          Jawahar

        • venkata reddy said

          I have the same problem,plz let me know how to solve.

          tq

  10. BatKing said

    Hi Everyone,

    I am facing some strange behavior. I have both VC 6.0 projects and VC++ 2008 express projects. on my old Windows XP, I have VS6.0, VC++ 2008 express and VS 2008 pro. all 3 installed. and everything has their own purpose. VS 6.0 for some very old VC projects. VC++ 2008 is only for one C project for IIS 6.0 and 7.0 ISAPI programing and I had this before VS 2008 pro and my .net development. everything was working fine.

    Then I upgraded to Windows 7 64 bit. and for the old VC project I tried this guide and it works. Thanks for the guide. However now my VS 2008 environment seems broken. it is always default to use VS 6.0 compliers and library. I didn’t install VC 2008 express and directly using VS 2008 pro for my VS 2008 express project. for this I am Not using the Batch file or /useenv switch to trigger VS 2008. but after VS 2008 IDE started, the Tools/Options/Projects and Solutions/VC++ Directories it is all the same as I trigger the VS 2008 with the batch file. it still has has all the VC98 directory and the worst, all the Include folders is all pointing to VC98 only folder. so my original VC2008 projects won’t compile and link correctly.

    any thing I am missing? how can I maintain one VS 2008 installation for both VC++ 6.0 and VC++ 2008 (9.0) projects?

    Thanks

    • Bojan Resnik said

      I have not had such a case – I have been using VS 2008 for both 6.0 and 2008 projects with the /useenv switch. You may, however, try to reset the Visual Studio to its factory settings by running: devenv /resetsettings (additionally you may also try running ‘deveenv /resetuserdata’). Note, however, that this will probably reset any customizations you have made, including keyboard mappings and window layout.

      Hope this helps,
      Bojan

  11. Sbaush said

    Hi,
    have you idea if is possible to do the reverse procedure?
    I have a VisualStudio 2008 project and i can’t compile it under VisualC++ 6.
    Can you help me please? Thanks!

    • Bojan Resnik said

      Sorry, I’ve never tried to do that. VC 6 may also support the /useenv switch, so you might try that.

      However, if you actually thought to compile using the VC6 compiler, this might not be possible without significant changes to the code. VC6 is an old and notoriously buggy compiler, so if your project is of any significant complexity, chances are it won’t compile under VC6.

      • Sbaush said

        Thank you for the reply!
        unfortunately i can’t decide to use VisualStudio 2008/2010, so I have to use the VC6 nevertheless the bugs inside it!

        Bye.

  12. Nauman said

    I am getting following error , please help me , i have created CLR console Application, i followed Your steps but
    error is still there,
    Thanks

    1>—— Build started: Project: nmchecking, Configuration: Debug Win32 ——
    1>Linking…
    1>LINK : fatal error LNK1104: cannot open file ‘MSVCMRTD.lib’
    1>Build log was saved at “file://c:\Users\nauman\Documents\Visual Studio 2008\Projects\nmchecking\nmchecking\Debug\BuildLog.htm”
    1>nmchecking – 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    • Bojan Resnik said

      VC6 is an old compiler, built before .NET existed, so it has no idea about CLR. Try creating a plain console application.

      HTH,
      Bojan

      • Nauman said

        i tried it with win32 console Application,
        but now when i compile it , some times it crash and some time
        give following error,

        1>—— Rebuild All started: Project: Nauman_fin, Configuration: Debug Win32 ——
        1>Deleting intermediate and output files for project ‘Nauman_fin’, configuration ‘Debug|Win32’
        1>Compiling…
        1>na_test.cpp
        1>c:\microsoft visual studio\vc98\include\utility(81) : warning C4346: ‘_It::iterator_category’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1> c:\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation ‘std::iterator_traits’ being compiled
        1>c:\microsoft visual studio\vc98\include\utility(81) : error C2146: syntax error : missing ‘;’ before identifier ‘iterator_category’
        1>c:\microsoft visual studio\vc98\include\utility(81) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\utility(82) : warning C4346: ‘_It::value_type’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\utility(82) : error C2146: syntax error : missing ‘;’ before identifier ‘value_type’
        1>c:\microsoft visual studio\vc98\include\utility(82) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\utility(83) : warning C4346: ‘_It::distance_type’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\utility(83) : error C2146: syntax error : missing ‘;’ before identifier ‘distance_type’
        1>c:\microsoft visual studio\vc98\include\utility(83) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\utility(224) : warning C4348: ‘std::istreambuf_iterator’ : redefinition of default parameter : parameter 2
        1> c:\microsoft visual studio\vc98\include\utility(226) : see declaration of ‘std::istreambuf_iterator’
        1>c:\microsoft visual studio\vc98\include\utility(226) : warning C4346: ‘_Tr::off_type’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1> c:\microsoft visual studio\vc98\include\utility(279) : see reference to class template instantiation ‘std::istreambuf_iterator’ being compiled
        1>c:\microsoft visual studio\vc98\include\utility(226) : error C2923: ‘std::iterator’ : ‘_Tr::off_type’ is not a valid template type argument for parameter ‘_D’
        1>c:\microsoft visual studio\vc98\include\utility(226) : error C2955: ‘std::iterator’ : use of class template requires template argument list
        1> c:\microsoft visual studio\vc98\include\utility(67) : see declaration of ‘std::iterator’
        1>c:\microsoft visual studio\vc98\include\utility(231) : warning C4346: ‘_Tr::int_type’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\utility(231) : error C2146: syntax error : missing ‘;’ before identifier ‘int_type’
        1>c:\microsoft visual studio\vc98\include\utility(231) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\utility(289) : warning C4348: ‘std::ostreambuf_iterator’ : redefinition of default parameter : parameter 2
        1> c:\microsoft visual studio\vc98\include\utility(291) : see declaration of ‘std::ostreambuf_iterator’
        1>c:\microsoft visual studio\vc98\include\xstring(25) : warning C4346: ‘_A::size_type’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1> c:\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation ‘std::basic_string’ being compiled
        1>c:\microsoft visual studio\vc98\include\xstring(25) : error C2146: syntax error : missing ‘;’ before identifier ‘size_type’
        1>c:\microsoft visual studio\vc98\include\xstring(25) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\xstring(26) : warning C4346: ‘_A::difference_type’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\xstring(26) : error C2146: syntax error : missing ‘;’ before identifier ‘difference_type’
        1>c:\microsoft visual studio\vc98\include\xstring(26) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\xstring(27) : warning C4346: ‘_A::pointer’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\xstring(27) : error C2146: syntax error : missing ‘;’ before identifier ‘pointer’
        1>c:\microsoft visual studio\vc98\include\xstring(27) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\xstring(28) : warning C4346: ‘_A::const_pointer’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\xstring(28) : error C2146: syntax error : missing ‘;’ before identifier ‘const_pointer’
        1>c:\microsoft visual studio\vc98\include\xstring(28) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\xstring(29) : warning C4346: ‘_A::reference’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\xstring(29) : error C2146: syntax error : missing ‘;’ before identifier ‘reference’
        1>c:\microsoft visual studio\vc98\include\xstring(29) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\xstring(30) : warning C4346: ‘_A::const_reference’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\xstring(30) : error C2146: syntax error : missing ‘;’ before identifier ‘const_reference’
        1>c:\microsoft visual studio\vc98\include\xstring(30) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\xstring(31) : warning C4346: ‘_A::value_type’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\xstring(31) : error C2146: syntax error : missing ‘;’ before identifier ‘value_type’
        1>c:\microsoft visual studio\vc98\include\xstring(31) : error C4430: missing type specifier – int assumed. Note: C++ does not support default-int
        1>c:\microsoft visual studio\vc98\include\xstring(32) : warning C4346: ‘_A::pointer’ : dependent name is not a type
        1> prefix with ‘typename’ to indicate a type
        1>c:\microsoft visual studio\vc98\include\xstring(32) : error C2144: syntax error : ‘std::iterator’ should be preceded by ‘;’
        1>c:\microsoft visual studio\vc98\include\xstring(32) : error C2208: ‘std::iterator’ : no members defined using this type
        1>c:\microsoft visual studio\vc98\include\xstring(32) : fatal error C1903: unable to recover from previous error(s); stopping compilation
        1>Build log was saved at “file://c:\Users\nauman\Documents\Visual Studio 2008\Projects\Nauman_fin\Nauman_fin\Debug\BuildLog.htm”
        1>Nauman_fin – 27 error(s), 15 warning(s)
        ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

        • Bojan Resnik said

          Sorry, can’t help you there – it sounds like it is trying to compile with VC++ 2008 compiler while using VC6 headers, which won’t work.

          If this is the case, then it seems to be finding cl.exe from VC2008 first for some reason. Make sure that you can access the VC6 compiler from within VS 2008, perhaps by temporarily adding its directory to the front of the PATH environment variable.

          Regards,
          Bojan

        • M. v. Kleef said

          Adding \VC98\Include and \VC98\Lib directories to Tools -> Options -> Projects & Solutions -> VC++ Directories and restarting Visual Studio solved this same issue for me

  13. Cristian I. said

    Good stuff!

    I managed to build an old VC6 MFC project in VS2008.

    In addition to the above, I had to add compiler options /FD /GR /GX, otherwise it would compile but crash at run time. Especially /GR is important. VS 2008 thinks these options are enabled by default and does not explicitly add them to compiler options.

    Also added /pdbtype:sept /machine:I386 to linker options.

  14. owenwengerd said

    After some work building the needed platform toolsets, I’ve been very happy using VS 2010 for targeting older build tool versions:
    http://otb.manusoft.com/2010/10/visual-studio-2010-native-multi-targeting.htm

  15. Scott S. said

    Thanks for posting this! This could be a huge help to me.

    So I got everything compiled, it’s compiling incrementally, etc. However, the debugger cannot examine anything that isn’t a primitive type (not even the “this” pointer). Anyone have an idea what the problem could be?

    • Pierre N. said

      Usually the debug information is stored in PDB files, so make sure you used the /debugtype:cv /pdbtype:con linker options instead of /pdbtype:sept so that all symbols get stored in one file (whose path is set with the /PDB option, and try to have it in the same directory as the EXE file).

      This page has more information about the different file formats used by multiple Visual Studio versions:
      http://www.debuginfo.com/articles/gendebuginfo.html#gendebuginfovc6

  16. Lukasz said

    Hi,

    I am having this strange issue, when I try to build a solution it compiles correctly but crashed VS 2008 right after. I have verified that this project works corrects (it builds fine on other machines) Any ideas?

    • Hi,

      I am having the same issues as Lukasz: a crash of the VS 2008 right after a **successful** build. This occurred after a reboot of the workstation where both VS6 and VS 2008 are installed. I suspect that it has to do with certain DLLs registered with he installation of VS 6 but still can’t figure out what it is exactly.

      Does anyone have the same symptoms? any solutions ?

      With kind regards.

  17. Belen S. said

    Hi,

    I am having an issue that I think that no one else has reported in this post. The problem is that when I build the solution, it seems that only the cpps that have been modified are builded, but not other cpps that have been influenced by the changes.

    To give an easy example if I add a new parameter to a function (in the h file where it is declared and the cpp where it is defined), but I do not change anything in other cpps that use this function, I get a link error instead of the typical compilation error “xxx does not take x parameters”.

    The only thing I can do to avoid this situation is to rebuild the solution, which takes me too long to do it everytime I need to build it.

    Am I missing anything? Thanks in advance.

  18. Very good, however what do you do about editing resources?

    My VC6 .rc files are “corrupt” in VS2008. They compile fine (because they are using the VC6 resource compiler).

    • Okay, I think I’ve got this working:

      Before:
      call “C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT”

      I added:
      call “%VS90COMNTOOLS%vsvars32.bat”

      Note that I have also modified my calling batch file to “SET INCLUDE” the WinDDK and WinSDK include folders

      • Bojan Resnik said

        Nice tip, thanks for sharing!

        Cheers,
        Bojan

      • How exactly do you mean you got it working? Does the VS2008 resource editor no longer complain that those *.rc files are corrupted only after including the paths from “%VS90COMNTOOLS%vsvars32.bat” to the environment? Or can you actually edit them from within VS2008 with the VS6.0 resource editor? Do the WinDDK and WinSDK INCLUDE paths have anything to do with the resource editor?

        Regards,
        Lucian

  19. Victor said

    Hi, thanks for your post.

    I have a couple of questions:

    1.- Do you think all this works in the Express Versions?
    2.- How would a complete set of options for the linker and compiler be if I did all this from the command line?

    For Example:
    cl /c /errorReport:prompt /GZ /RTC1 /FD /GR /GX ….. etc

    link firstlib.lib vicobj.obj /pdbtype:sept /machine:I386 /NODEFAULTLIB:otherlib.lib ….. etc

    Thank you,
    Victor

    • Bojan Resnik said

      I have never used Express versions, so I have no idea whether this would work. I’m guessing it should, if the IDEs give you the same options. You can find the full command lines in Visual Studio, if you open Properties/Linker/Command Line and Properties/C/C++/Command Line, they are displayed in the top portion of the dialog.

      Cheers,
      Bojan

  20. Madrice said

    THANK YOU! THANK YOU! THANK YOU! This article saved so much time!

  21. Bass2Four said

    I have 2008 currrently installed on my W7 box and I am currently running VS6 in Windows XP Mode. Can I install VS6 onto my W7 box now and then setup using the steps above, or does the VS6 have to be installed first. Secondly, during the VS6 install, it asks to register the environment variables, should I say “NO” to this option? Thanks for the info…

    • Bojan Resnik said

      I never allow it to register environment variables, as they are not needed anyway. They will be set by vcvars32.bat when needed. As for the installation, VS6 has always worked nicely side-by-side with all other VS products on my machine. I have no idea whether about the order of installation though – I’ve always installed lower versions first.

      HTH

      • Bass2Four said

        After the setup, when you open a VC6 project, does VS2008 still ask to convert the project to VS2008 project, can I still use the existing VC6 project under VC6 and Windows XP?

        • Bojan Resnik said

          Yes to both of these – conversion of VC6 projects to VS2008 should only create new files, without modifying existing ones. Of course, make a backup before converting, just to be safe. This will allow you to use both VC6 and VS2008 project files, but you will have to make project changes to both of them – after the conversion they are completely separate files and they have to be maintained separately.

          HTH,
          Bojan

          • Bass2Four said

            So, I should NOT convert the VC6 project when opening in 2008, because I am using the VC6 compiler to build, correct?

            • Bojan Resnik said

              No, that’s not correct. The only way to open the project in VS2008 is to convert it. Conversion, however, does not modify the original project files which you can still use with VS98 IDE. After converting the project to VS2008, you can use VS2008 IDE and compile with VC6 compiler by following the steps described in the article.

              If you have VS2010, you can use its native multitargeting feature to build with whatever compiler you want while using VS2010 IDE. The excellent Daffodil project (http://otb.manusoft.com/2010/10/visual-studio-2010-native-multi-targeting.htm) provides build scripts for Visual Studio versions from 6.0 to 2008.

  22. Juraj Babec said

    Hi,

    We followed all steps which are present in this article. Everything works as expected one case. Our final product is a DLL which is loaded by external tool (some program.exe) . We are able to debug if we set a break point in the source code (step in and step out works). But if run in debug mode and some crash occurred (e.g. null pointer exception) we did not get call stack (as it was in VC 6) .

    We are using Windows 7 64 bit operation system
    Could you please help us with this issue? Also please let us known if our description of this issue is not clear.Thanks.

    • Bojan Resnik said

      It may be that your settings in Debug/Exceptions for breaking on C++ or Win32 exceptions are not set. Other than that, I’m not sure what could be the cause.

      HTH,
      Bojan

  23. Max said

    Hello Bojan,

    Grate article !

    May be you can help me with my problem:
    Nowdays I’m tring to migrate from VC6 to VC9.
    At first I would like to try to compile my old project on the VC9.
    It is a large project wich consists of a several projects with dll’s.

    Some of the projects I succeded to compile and some have this kind of failure:
    ” 1>LINK : fatal error LNK1104: cannot open file ‘mfc42d.lib’ ”

    May be you can suggest me what can I do in this case ?

    Thanks,
    Max.

  24. M. v. Kleef said

    I have finally converted my VS6 workspace to a solution with projects in VS2008 and it all builds as it should, but when running the application I get “Application failed to initialize (0xC0000005).”
    The OS is WinXP 32 bit. Please, any tips on how to continue from here?? Thanks

    • Bojan Resnik said

      I have no idea what might be going on, sorry. Your best bet would probably be to enable catching of Win32 exceptions and debug the application.

  25. Richard Voinier said

    Hi, Thank you for this very useful post. It’s works great with our VC
    projects.
    We still have a trouble when debugging an application step by step, if we enter in a MFC function the code shown is not the good one. VS shows the code of the MFC7 which is in the directory of VS2008 instead of the code of the MFC4.
    Do you have any idea ?
    Thanks

    • Bojan Resnik said

      I am sorry, I have stopped using VS 2008 long ago. I would suggest trying Oven Wengerd’s excellent Daffodil project with VS 2010 or VS 2012, to see if it solves your problem.

  26. Pooja PANDEY said

    I am converting one module from vc6 to visual studio 2005, while build i am getting error in rc.exe file.

    fatal error RC1109: error creating .\debug/clean95/
    Project : error PRJ0002 : Error result 1 returned from ‘C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\rc.exe’.

    –> I am able to open resource files
    –> It is not read only
    –> rc file exists at the given path with rcdll.dll
    Please Help..

  27. baskelandbretcj7 said

    Does this work around allow you to open a VC6 solution in vs2010 and not have to convert the solution to vs2010? I need a way i can work with the code in a different IDE from visual c++ 6 and not have to convert the solution.

    I don’t tend to make any actual solution changes and if needed can do so in vc6.

    I follow the steps above and the .bat file worked great, although opening my solution from vc6 it wants me to convert to 2010. Not sure if this has any implications since it will want me to check out the solution from TFS and i don’t want to keep a lock on it.

    Thanks for work-around and thoughts would be helpful.

    • Bojan Resnik said

      No, all solutions must be converted to the format the IDE understands. However, I don’t think you need to have your solution checked out after the conversion – you could just undo any changes (there shouldn’t be any), and work offline using the VS2010 solution.

      By the way, a much better (and more integrated) way of using older compilers with new IDEs is Owen Wengerd’s Daffodil project. It doesn’t require using batch files or starting Visual Studio in a specific way.

      Cheers,
      Bojan

  28. Arthur said

    Thank you very much!
    Helped me to use VC++ 6.0 compiler in Windows 8.1 Pro x64 with my project
    Now I’m using Visual Studio 2005 IDE and the compiler above 🙂

  29. Jen said

    Thanks a lot for the post. Recently we have a port one of our very old vc6 project to windows 2008 64bit and your post helped us a lot.
    I never thought we would ever need going back to vc6 stuff, but, you never knows.

    Thanks.

  30. Saurabh Suman said

    This error ocurred while migrating from visual c++ 6.0 to 2008

    c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(1310) : error C2872: ‘DOMDocument’ : ambiguous symbol
    could be ‘c:\program files\microsoft sdks\windows\v6.0a\include\msxml.h(171) : DOMDocument’
    or ‘c:\hat\common\xercesparser\src\xercesc\dom\domdocument.hpp(65) : xercesc_2_8::DOMDocument’

  31. Masih said

    Hi Bojan,
    I really enjoyed your nice and well-organized and fully comprehensive article. It helped me a lot towards dealing with a huge and old code in VC6 using the more advanced IDE (VS2008). I deeply appreciate the time you spent on writing this and sharing it with everyone.
    A part of the code I’m working on right now is written in VB6 which is for the software interface. Do you think it would be possible to do same with VB? (i.e. use VS2008 as debugger and code editor along with VB6 compiler)
    Kind Regards,
    Masih

    • Bojan Resnik said

      Hi Masih,
      Unfortunately, I don’t know anything about VB6, and I can’t guess what it would take to do a similar thing. I’m sure that VB.NET would just work with almost any newer version of VS.

      Regards,
      Bojan

  32. Masih said

    Hi again,

    Thanks for your answer. I also have another issue with this setup. When I run VS2008 with that batch file, and I add some include, library and executable directories to VS2008 paths (under Tools->Options->Projects and Solutions->VC++ Directories), after I close this instance of VS2008 down and open it again, those directories are not there and should be added again. Do you know why this happens and how to avoid it?

    Kind Regards,
    Masih

    • Bojan Resnik said

      Hi,
      Sorry, I can’t help you much – it has been at least 6 years since I last used this setup. Currently, I would consider Visual Studio’s native multitargeting to be far superior. Please see the link to Owen Wengerd’s post at the top of the blog.

      Regards,
      Bojan

      • Masih said

        Hi Bojan,

        Your short hint led me to compile, edit and debug this huge VC6 code in VS2015 in a few seconds. And I am overjoyed now. Imagine how much happiness has entered into my heart by this amazing work. And that I owe you and Owen.

        I again appreciate your spreading of good stuff!!

        Kind Regards,
        Masih

  33. […] IDE di Visual Studio 2008 con VC6 compilatore. Recentemente ho scritto un blog su questo: resnikb.wordpress.com/2009/10/28/… Bene, la soluzione inviato da Bojan ha funzionato bene. Ancora mi permette di eseguire il debug da […]

Leave a comment