none
Can VS2015 compiled C/C++ code run on Windows 2003?

    Question

  • I'm getting ready to get into pre-release phase with our customers and I tested an Win2003 VM for the upgrade process which includes the installation of vcredist_x86.exe (MFC v14) and I see that my EXEs "are invalid" to Windows 2003.

    Can VS2015 compiled C/C++ code run on Windows 2003?   

    Why would the vcredist_x86.exe setup install if it doesn't support Window 2003?

    Thanks

    PS: I still have many customer, including Enterprise customers who still use Window 2003.



    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com



    Friday, May 13, 2016 5:50 PM

Answers

  • Hi,

    did you set the Platform Toolset to Visual Studio 2013 - Windows XP? That is required to be compatible with XP. (Default for new projects is Visual Studio 2015).

    You can find the settings inside the Project Properties inside Configuration Properties -> General.

    With kind regards,

    Konrad

    Friday, May 13, 2016 6:56 PM
    Moderator
  • Hi Hector,

    you have to use the correct toolset. If you check the installation on your system, then you will find multiple Visual Studio directories inside your c:\Program Files (x86) directory:

    Microsoft Visual Studio 12.0 contains the toolset that you have to use to build applications for XP.

    (The default would be the 14.0 one.)

    Or in other words: The tools used should be the one from
    c:\program files (x86)\Microsoft Visual Studio 12.0\VC\bin

    And you have to provide the /SUBSYSTEM parameter to the cl.

    Please see the documentation for /SUBSYSTEM for details.

    So it could be something like /SUBSYSTEM:CONSOLE,5.01 for a XP 32bit Console application.

    I hope that I didn't forget anything. I did a quick search and maybe the following discussion on StackOverflow is also useful:
    http://stackoverflow.com/questions/16075171/how-can-i-compile-for-windows-xp-with-visual-studio-2012-from-the-command-prompt

    With kind regards,

    Konrad

    • Marked as answer by hector santos Saturday, May 14, 2016 10:53 PM
    Friday, May 13, 2016 9:57 PM
    Moderator

All replies

  • According to this link:

    https://www.visualstudio.com/en-us/products/visual-studio-2015-compatibility-vs.aspx


    VS2015 is compatible with Window 2003.   What I am missing?


    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Friday, May 13, 2016 5:55 PM
  • I hope this is a simple issue (compiler switch?) because all my tools, such Depends loads the EXE fine, shows all the DLLs, etc, but it doesn't run it.   Says its invalid.   I have over 100+ exes and dlls recompiled under VS2015.

    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Friday, May 13, 2016 6:30 PM
  • >I hope this is a simple issue (compiler switch?)

    Have you chosen the Windows XP compatible platform toolset setting?

    Dave

    Friday, May 13, 2016 6:52 PM
  • Hi,

    did you set the Platform Toolset to Visual Studio 2013 - Windows XP? That is required to be compatible with XP. (Default for new projects is Visual Studio 2015).

    You can find the settings inside the Project Properties inside Configuration Properties -> General.

    With kind regards,

    Konrad

    Friday, May 13, 2016 6:56 PM
    Moderator
  • Thank you Konrad, I just saw how to do this -- Targeting XP (which targets 2003 as well).  

    I selected V140 XP, recompiled an example, after re-inheriting the library directory, and it now works in Windows 2003.

    Oh Boy, I wish I knew this upfront. I have to now change this across 100+ projects.  :)

    Short of having to write a tool to scan and change the XML properies in the *.VCXProj, any tips here to globally set this?   There will be two properties to change:

    Platform Toolset --> Visual Studio 2015 - Windows XP (v140_xp)

    Library Directories: --> c:\local\wc7\lib;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86);

    The prefix path "c:local\wc7\lib;" is where all my libs are for my dll projects.  Maybe I can stick/inherit that from somewhere else?

    Also  if possible, now that I know about this target stuff.  is it possible to COPY over from another machine the VS2010 setup for the ToolSet to that I can include it in my VS2015 IDE and use it if needed?   

    Thanks




    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com




    Friday, May 13, 2016 7:15 PM
  • Konrad, how do you set the Toolset via the command line compiler, cl or link?  I have many standalone tools that are compiled with CL.  They are not part of a VCXPROJECT file.

    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Friday, May 13, 2016 9:20 PM
  • Hi Hector,

    you have to use the correct toolset. If you check the installation on your system, then you will find multiple Visual Studio directories inside your c:\Program Files (x86) directory:

    Microsoft Visual Studio 12.0 contains the toolset that you have to use to build applications for XP.

    (The default would be the 14.0 one.)

    Or in other words: The tools used should be the one from
    c:\program files (x86)\Microsoft Visual Studio 12.0\VC\bin

    And you have to provide the /SUBSYSTEM parameter to the cl.

    Please see the documentation for /SUBSYSTEM for details.

    So it could be something like /SUBSYSTEM:CONSOLE,5.01 for a XP 32bit Console application.

    I hope that I didn't forget anything. I did a quick search and maybe the following discussion on StackOverflow is also useful:
    http://stackoverflow.com/questions/16075171/how-can-i-compile-for-windows-xp-with-visual-studio-2012-from-the-command-prompt

    With kind regards,

    Konrad

    • Marked as answer by hector santos Saturday, May 14, 2016 10:53 PM
    Friday, May 13, 2016 9:57 PM
    Moderator
  • I have now.  XP means 2003 support as well.  I wonder what are the CONS of using this "V140 with XP" platform?


    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Saturday, May 14, 2016 1:25 AM
  • thanks, I have many standalone consoles I compile with CL.   I don't see how to tell it to use the proper Kernel32.lib perhaps with setting the proper SET LIB= paths.   I will explore that, unless you feel there is a switch for it. 

    I did try the MSBUILD /p switch but I still need to change the LIB path./

    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Saturday, May 14, 2016 1:29 AM
  • >I have now.  XP means 2003 support as well.  I wonder what are the CONS of using this "V140 with XP" platform?

    Hopefully none, but I'm afraid I don't know as I've not yet released
    anything that still supports XP with a later compiler than VS 2010 -
    which can still be used with the improvements of the 2015 IDE and
    debugger.

    Dave

    Saturday, May 14, 2016 7:22 AM
  • Hi Hector,

    I completly missed this 140_xp setting. Using that should give you all improvements that the c++ got over the time.

    Just check the announcements of the all the updates, e.g. Visual Studio 2015 Update 2:

    So better support for the C++ standards is a good reason to use it (in my eyes) but the bug fixes might be important, too.

    With kind regards,

    Konrad

    Saturday, May 14, 2016 7:32 AM
    Moderator
  • Hi,

    you are right. The lib path should be set, too. The user in the linked stackoverflow thread was using 

    set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%

    So it was pointing to the libs of the windows sdk 7.1.

    With kind regards,

    Konrad

    Saturday, May 14, 2016 7:36 AM
    Moderator
  • Hi, minor typo, it should be "v7.1a" 

    anyway, I can't figure it out with a simple hello world cpp program compiled with CL.EXE.   I got it to compile and link with the vc140_xp lib paths (taking the 4 paths from the IDE expanded macro view):

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\lib
    C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86
    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\lib


    but it won't run under win2003, so perhaps there is some other compiler/binding/linking switch or image stamping thing somewhere.   might be another environment string.... exploring....   



    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com


    Saturday, May 14, 2016 9:19 PM
  • I haven't pinpointed it all down yet, but it appears its not just CL, but maybe a different LINK.EXE or perhaps RC.EXE are being used for a "v140_xp" target since the paths change for executables as well.  



    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Saturday, May 14, 2016 9:51 PM
  • Konrad, thanks, I had to set the /SUBSYSTEM:xxxxxxx,5.01 for the linker.  You mentioned that above.  

    I found for the simplest of programs,  that is all you had to add to the CL /LINK option or LINK command,

    /SUBSYSTEM:WINDOWS",5.01"OR CONSOLE",5.01" 

    Thanks for your time.


    Hector Santos, CTO Santronics Software, Inc. http://www.santronics.com

    Saturday, May 14, 2016 10:58 PM