Which is the minimum Visual Studio version or edition to develop both for Win32 and Win64? - c++

Our Windows application (developed in Delphi) is shipped in 32-bit and 64-bit editions. Users can write plugins for it. If they target the 32-bit edition, the need to create a 32-bit dll. If they target the 64-bit edition, they need to target a 64-bit dll.
I would like to create a sample application in Visual Studio C++ that can be used as a reference to help hacking it.
I would like that the Visual Studio solution provided as an example is able to have everything in place to compile a sample dll both for Win32 and for Win64.
Which is the minimum (preferably free) Visual Studio C++ edition or version that I need to be able to compile both for Win32 and Win64. I tried with Visual Studio 2010 Express but it does not seem to let you add Win64 as a target platform.

VS2012 Express includes the 64 bit compiler. It is possible to persuade earlier versions of the Express edition to use the 64 bit tools, but it's quite tricky to set up.

Related

Which Visual Studio to target broadest array of Windows machines?

I develop a large open source C++ program. On Windows, we typically build our downloadable releases with Visual Studio Express. In the past, I've tried to use an old version of Windows and an old version of Visual Studio to try to maintain compatibility with as many user's machines as possible -- and to also keep the development environment as accessible as possible to contributors.
We do use some C++11. We currently use VS 2010 Express on Windows 7 Enterprise SP1 (64 bit). We target Win32. We do not use any .Net stuff.
Unfortunately, as built, our program crashes on Windows 8.1 -- it starts to load, but crashes with a non helpful error message 'myprogram.exe Has stopped working.' I can't yet tell if this 'should work', or if it is a bug in our program that only Win8 triggers (it works fine on earlier Windows as well as OSX and Linux).
I'm finding it very difficult to figure out the target compatibility matrix for Windows & Visual Studio. Assume that all versions of Windows and Visual Studio are available.
So, what version of Visual Studio and/or Windows SDK 'should work' to produce a single executable that will work on the widest range of Windows versions?
Or, what is the minimum number of builds (and how) we could do to target the widest array of Windows versions?
Alternatively, would MinGW provide a substantially better result for us? If so, which version & platform should we use?
We currently only build 32-bit versions, but how would going 64-bit change this discussion?

is it possible to create 64 bit program using a 32 bit OS

i have 32 bit windows 7 and I am using visual studio 2010 express.
Is it possible to create a solution for a 64 bit platform?
If it is possible, how is it done?
If you write managed code and target AnyCPU, the code will be jitted to appropriate assembly for the platform it's executed on
http://www.hanselman.com/blog/BackToBasics32bitAnd64bitConfusionAroundX86AndX64AndTheNETFrameworkAndCLR.aspx
To directly target 64 bit apps from Visual Studio Express, install Windows Software Development Kit (SDK) in addition to Visual C++ Express.
http://msdn.microsoft.com/en-us/library/9yb4317s.aspx
Maybe "How to: Enable a 64-Bit Visual C++ Toolset at the Command Line" at MSDN helps, but it's for VS2010 not express. Basically it's all about having a cross compiler.
Edit: In addition to that, there is also How to: Configure Visual C++ Projects to Target 64-Bit Platforms.
cl64.exe itself is a 32 bit program. It just produces 64 bit code. In Visual Studio create a Win32 project, and create a new target platform in the configuration manager.

Visual C++11 executables and Windows XP [duplicate]

I compile my C++ source code with Visual Studio 11 Developer Preview. I statically link to the runtime library.
The resulting executable cannot be executed on Windows XP. When I try to execute it on Windows XP I get the error message "[Executable Path] is not a valid Win32 Application.".
According to Microsoft Visual Studio 11 won't support Windows XP.
How does it work that the resulting executable cannot be executed on Windows XP? Is there anything special within the executable?
They seem to drop support for older systems in every new release of VS (NT4,2000,XP) Even if you don't use the CRT at all, they still force the PE subsystem version to high numbers. You can work around that by changing the numbers back to 5.0 in a post build step. Just changing those numbers should allow the exe to start on XP unless the new CRT is using WinAPI functions that don't exist on XP.
The other alternative if you want to keep using VS11 is to use multi-targeting and older compilers...
Visual Studio 2012 will be able to target Windows XP later in 2012:
Targeting Windows XP with C++ in Visual Studio 2012
"Later this fall, Microsoft will provide an update to Visual Studio 2012 that will enable C++ applications to target Windows XP. This update will make the necessary modifications to the Visual C++ 2012 compiler, runtime, and libraries to enable developers to create applications and DLLs that run on Windows XP and higher versions as well as Windows Server 2003 and higher."
Edit: This has now happened (phew!)
The workaround is to use a different Platform Toolset, which will link a different version of CRT and produce binaries compatible to older operating systems.
See more here: Target Windows XP in Visual Studio 11 Beta using the Visual Studio 2010 compiler and libraries.
With v90 toolset your binary will be able to run even in older systems, such as Windows 2000.
http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-69/7444.BlogPic.png
The runtime libraries bundled with VS 2010 and higher enforce your executable to import two new functions from kernel32.dll that are missing on Windows XP: EncodePointer and DecodePointer. Those are needed for yet another idiotic naive attempt to enhance the software "security".
In VS 2010 there is an option to use the runtime libraries of Visual Studio 2008, which solves this problem. I don't know if there's such an option in later versions of VS.

How can I configure visual c++ 2008 for 64 bit? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to compile a 64-bit application using Visual C++ 2010 Express?
How can I compile 64 bit with visual c++ 2008
I am trying to compile an application that contains CUDA code. I have visual c++ 2008 express version (the free version) on my computer. To be able to use the cuda compiler I followed the steps from here, here and here. The cuda files (with *.cu extension) now compile fine, but the other normal C++ files are using 32 bit because at the drop box on the top (configuration manager) of IDE, it says Win32. There is no option to make it Win64. What should I do to tell configuration manager to use 64 bit. Note that I have 64 bit compilation tools now that I installed the Windows SDK.
Visual Studio Express 2008 doesn't ship with the x64 compiler, that's reserved for the pro versions.
The command-line version is included in the Windows SDK though, which is available for free. You can find some information about adding the 64bit compiler to Visual Studio Express on the internet, but it's a big hack. Just a quick search on google revealed for example this blog-entry: https://jenshuebel.wordpress.com/2009/02/12/visual-c-2008-express-edition-and-64-bit-targets/
http://msdn.microsoft.com/en-us/library/9yb4317s%28v=vs.90%29.aspx
"64-bit tools are not available on Visual C++ Express by default. To enable 64-bit tools on Visual C++ Express, install the Windows Software Development Kit (SDK) in addition to Visual C++ Express. Otherwise, an error occurs when you attempt to configure a project to target a 64-bit platform using Visual C++ Express."
Right click the solution -> Active solution platform -> New... -> x64 (under "Type or select the new platform:)

What is special about the executables compiled with Visual Studio 11 which results in that the executables cannot be executed on Windows XP?

I compile my C++ source code with Visual Studio 11 Developer Preview. I statically link to the runtime library.
The resulting executable cannot be executed on Windows XP. When I try to execute it on Windows XP I get the error message "[Executable Path] is not a valid Win32 Application.".
According to Microsoft Visual Studio 11 won't support Windows XP.
How does it work that the resulting executable cannot be executed on Windows XP? Is there anything special within the executable?
They seem to drop support for older systems in every new release of VS (NT4,2000,XP) Even if you don't use the CRT at all, they still force the PE subsystem version to high numbers. You can work around that by changing the numbers back to 5.0 in a post build step. Just changing those numbers should allow the exe to start on XP unless the new CRT is using WinAPI functions that don't exist on XP.
The other alternative if you want to keep using VS11 is to use multi-targeting and older compilers...
Visual Studio 2012 will be able to target Windows XP later in 2012:
Targeting Windows XP with C++ in Visual Studio 2012
"Later this fall, Microsoft will provide an update to Visual Studio 2012 that will enable C++ applications to target Windows XP. This update will make the necessary modifications to the Visual C++ 2012 compiler, runtime, and libraries to enable developers to create applications and DLLs that run on Windows XP and higher versions as well as Windows Server 2003 and higher."
Edit: This has now happened (phew!)
The workaround is to use a different Platform Toolset, which will link a different version of CRT and produce binaries compatible to older operating systems.
See more here: Target Windows XP in Visual Studio 11 Beta using the Visual Studio 2010 compiler and libraries.
With v90 toolset your binary will be able to run even in older systems, such as Windows 2000.
http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-65-69/7444.BlogPic.png
The runtime libraries bundled with VS 2010 and higher enforce your executable to import two new functions from kernel32.dll that are missing on Windows XP: EncodePointer and DecodePointer. Those are needed for yet another idiotic naive attempt to enhance the software "security".
In VS 2010 there is an option to use the runtime libraries of Visual Studio 2008, which solves this problem. I don't know if there's such an option in later versions of VS.