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

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:)

Related

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

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.

Enabling MSVC10 Platform toolset in VS2012 64bit project [duplicate]

Is there a simple way to compile a 64 bit app with the 32-bit edition of Visual C++ 2010 Express? What configurations, if any, are necessary?
Here are step by step instructions:
Download and install the Windows Software Development Kit version 7.1. Visual C++ 2010 Express does not include a 64 bit compiler, but the SDK does. A link to the SDK: http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
Change your project configuration. Go to Properties of your project. On the top of the dialog box there will be a "Configuration" drop-down menu. Make sure that selects "All Configurations." There will also be a "Platform" drop-down that will read "Win32." Finally on the right there is a "Configuration Manager" button - press it. In the dialog that comes up, find your project, hit the Platform drop-down, select New, then select x64. Now change the "Active solution platform" drop-down menu to "x64." When you return to the Properties dialog box, the "Platform" drop-down should now read "x64."
Finally, change your toolset. In the Properties menu of your project, under Configuration Properties | General, change Platform Toolset from "v100" to "Windows7.1SDK".
These steps have worked for me, anyway. Some more details on step 2 can be found in a reference from Microsoft that a previous poster mentioned: http://msdn.microsoft.com/en-us/library/9yb4317s.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.
How to: Configure Visual C++ Projects to Target 64-Bit Platforms
Ref:
http://msdn.microsoft.com/en-us/library/9yb4317s.aspx
And make sure you download the Windows7.1 SDK, not just the Windows 7 one. That caused me a lot of head pounding.
I found an important step to add to this - after you've installed the SDK, go to your project properties and change Configuration Properties->General->Platform Toolset from v100 or whatever it is to Windows7.1SDK. This changes $(WindowsSdkDir) to the proper place and seemed to solve some other difficulties I was encountering as well.
Note that Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed.
For instructions on resolving this, see KB2519277 on the Microsoft Support site.
Download the Windows SDK and then go to View->Properties->Configuration Manager->Active Solution Platform->New->x64.
Programming in a 64-bit environment is quite different than 32-bit environment.
Code generated has totally different assembly constitution in 32 & 64-bit code, even the protocols of communicating with functions change. So you can't generate 64-bit code using 32-bit compiler.
You might want to see an article on Microsoft's web site about targeting a 64-bit target but using a 32-bit development machine.
As what Jakob said: windows sdk 7.1 cannot be installed if MS VC++ x64 and x86 runtimes and redisrtibutables of version 10.0.40219 are present. after removing them win sdk install is okay, VS C++ SP1 can be installed fine again.
Kind regards

What development environment is required to target `C++ 2008 Redistributable`?

Last week I inherited a legacy unmanaged C++ application.
Unfortunately the project settings are not 100% reliable, and there is no documentation. What I do know is that the product was deployed with Microsoft Visual C++ 2008 Redistributable x86.
My question is: what combination of IDE, SDK, and Platform ToolSet would you recommend using?
Unfortunately I haven't worked with the Windows SDK before, and the Platform ToolSet option is new to me. To make matters worse, I haven't written a line of C++ code in eight years! So... any feedback you can provide would be greatly appreciated :D
KNOWNS
Client Operating System
Windows 2008 R2
C++ Redistributable
Microsoft Visual C++ 2008 Redistributable x86 is deployed in production
Integrated Development Environment (IDE)
I would prefer to use Visual Studio 2012 (we also have: Visual Studio 2008, 2010, 2012)
UNKNOWNS
Platform ToolSet
Can I use VS2012 and target the v90 platform, or is it more stable to simply use VS2008?
Windows SDK
Which version of the Windows SDK should I install on the development machine if the client is using Microsoft Visual C++ 2008 Redistributable x86 in production?
I would start by trying to get the project to compile successfully in Visual Studio 2008, since you mentioned you already have that available.
I wouldn't bother trying to install another version of the Windows SDK (one comes bundled with VS 2008) unless you can't get the project to compile successfully in an out-of-the-box install of VS 2008. If not and you do want to try installing another version of the SDK, I would opt for version 7.1, the one that targets Windows 7.
There is unlikely to be any advantage in using version 6.1 of the SDK; new versions might add new features, but they generally retain backwards compatibility with the old versions. I would not, however, install any version of the Windows 8 SDK because that might end up confusing you as the developer.
Once you get everything up and going on VS 2008, you could try switching over to VS 2012 if you'd prefer to use it. (I still can't get used to the UI, but apparently someone likes it.) As you point out in the question, the easiest way of making this work correctly would be to target "v90", which is VS 2008 (set using the Platform Toolset option). That will basically allow you to use the VS 2012 shell for editing purposes, but the VS 2008 compiler and headers for builds. You won't get any of the C++11 features introduced with VS 2012, however, because you're not using the new version of the compiler; you'll be stuck with what was supported back in VS 2008.

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 to compile a 64-bit application using Visual C++ 2010 Express?

Is there a simple way to compile a 64 bit app with the 32-bit edition of Visual C++ 2010 Express? What configurations, if any, are necessary?
Here are step by step instructions:
Download and install the Windows Software Development Kit version 7.1. Visual C++ 2010 Express does not include a 64 bit compiler, but the SDK does. A link to the SDK: http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
Change your project configuration. Go to Properties of your project. On the top of the dialog box there will be a "Configuration" drop-down menu. Make sure that selects "All Configurations." There will also be a "Platform" drop-down that will read "Win32." Finally on the right there is a "Configuration Manager" button - press it. In the dialog that comes up, find your project, hit the Platform drop-down, select New, then select x64. Now change the "Active solution platform" drop-down menu to "x64." When you return to the Properties dialog box, the "Platform" drop-down should now read "x64."
Finally, change your toolset. In the Properties menu of your project, under Configuration Properties | General, change Platform Toolset from "v100" to "Windows7.1SDK".
These steps have worked for me, anyway. Some more details on step 2 can be found in a reference from Microsoft that a previous poster mentioned: http://msdn.microsoft.com/en-us/library/9yb4317s.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.
How to: Configure Visual C++ Projects to Target 64-Bit Platforms
Ref:
http://msdn.microsoft.com/en-us/library/9yb4317s.aspx
And make sure you download the Windows7.1 SDK, not just the Windows 7 one. That caused me a lot of head pounding.
I found an important step to add to this - after you've installed the SDK, go to your project properties and change Configuration Properties->General->Platform Toolset from v100 or whatever it is to Windows7.1SDK. This changes $(WindowsSdkDir) to the proper place and seemed to solve some other difficulties I was encountering as well.
Note that Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed.
For instructions on resolving this, see KB2519277 on the Microsoft Support site.
Download the Windows SDK and then go to View->Properties->Configuration Manager->Active Solution Platform->New->x64.
Programming in a 64-bit environment is quite different than 32-bit environment.
Code generated has totally different assembly constitution in 32 & 64-bit code, even the protocols of communicating with functions change. So you can't generate 64-bit code using 32-bit compiler.
You might want to see an article on Microsoft's web site about targeting a 64-bit target but using a 32-bit development machine.
As what Jakob said: windows sdk 7.1 cannot be installed if MS VC++ x64 and x86 runtimes and redisrtibutables of version 10.0.40219 are present. after removing them win sdk install is okay, VS C++ SP1 can be installed fine again.
Kind regards