Converting VC++ Solution and Project files from 32 to 64 bit - c++

Does devenv through any switch or any tool allow to convert a Visual Studio Project and Solution from x86 to X64/AMD64? I was particularly thrilled with the switch /Upgrade in devenv which automatically upgrades a solution/project from previous version to the current version and was looking forward for something similar to do a bitness conversion.
I have a set of vcxproj that I want to port from 32 bit and 64 bit. The process I understand should be straight forward as it only have to create a new configuration for x64, copy the settings for both Win32 Debug/Release and then do a blind replace of all the CRT/MFC libraries/dlls and toggle few switches to make it a 64 bit build.
Hacking through the vcxproj and sln files may be an option but I do not want to invest time and reinvent the wheel if one already exist.
Note If it matter's, currently my focus is only for Visual Studio 2010.

You don't need to "upgrade" your Project files from Win32 to x64. Just go into configuration manager for your solution and add an x64 platform for the project configurations that need it.

I wrote a python script to do it manually, kinda hacky but it seems to work :)
Pretty straight forward since both the solution and project files are plain text. At first I did it via configuration manager, then I diffed the files and did the same procedure in python.
In my case (protobuf 2) it was only a few 'replace all's.
in both sln and project replace Win32 with x64
in project replace
<TargetMachine>MachineX86</TargetMachine>
with
<TargetMachine>MachineX64</TargetMachine>
and
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
with
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
and finally change the OutDir so my cmake Find scripts pickup the build
Full source https://github.com/madeso/ride/blob/f7d7234972aeaa0ddb89cda030ecfe651678078d/scripts/windows.py#L163

Related

Trying to get an the pokerstove api to work

I want to mess around with pokerstove, but I'm having some issues.
"Windows
Getting boost to work under windows can be a bit of a challenge. One of the easier ways is to install precompiled librares. There is a batch of them available at sourceforge. If you're working with Visual Studio 2010, you will probably need the 32 bit libraries. boost precomplied libraries
Under windows, the cmake gui can be used to construct solution and project files for Visual Studio 2010. To do this, browse source to locate the programs directory git/pokerstove/programs. Then create a build dir for the project. At the bottom of the gui click Configure, then Generate. You may have to edit the git/pokerstove/programs/CMakeLists.txt to point cmake to your installation of boost.
Once you've done that, you should be able to select
Menu->Build->Build Solution
to build the sample program."
Those are the instructions it gives to windows users. I did most of that and tried to build solution, but I'm getting these errors. http://i.imgur.com/NknHKtk.png
I've tried moving around my boost folder with no luck.

LNK1113: invalid machine type 0x1C0

While building the project in VS2012, I'm getting the linking error as
LNK1113: invalid machine type 0x1C0
I'm not sure where to check and what would be the error. Any help would be appreciated.
Thanks
two minutes google for 'how to set module machine type in visual studio'
resulted in the following info, found at:
<http://stackoverflow.com/questions/3563756/fatal-error-lnk1112-module-machine-type-x64-conflicts-with-target-machine-typ>
Check your properties options in your linker settings at:
Properties > Configuration Properties > Linker > Advanced > Target Machine.
Select MachineX64 if you are targeting a 64 bit build,
or MachineX86 if you are making a 32 bit build.
Select Build > Configuration Manager
from the main menu in visual studio.
Make sure your project has the correct platform specified.
It is possible for the IDE to be set to build x64
but an individual project in the solution can be set to target win32.
So yeah, visual studio leaves a lot of rope to hang yourself,
but that's life.
Check your library files
that they really are of the type of platform are targeting.
This can be used by using dumpbin.exe
which is in your visual studio VC\bin directory.
use the -headers option to dump all your functions.
Look for the machine entry for each function.
it should include x64 if it's a 64 bit build.
In visual studio, select
Tools > Options from the main menu.
select Projects and Solutions > VC++ Directories.
Select x64 from the Platform dropdown.
Make sure that the first entry is:
$(VCInstallDir)\bin\x86_amd64
followed by $(VCInstallDir)\bin.
Once I did step 4 everything worked again for me.
The thing was I was encountering this problem on all my projects
where I wanted to compile towards a 64 bit target.

Makefiles, moving from VC6 to Visual Studio 2010

I'm trying to migrate some projects from VC6 to Visual Studio 2010 but I'm running into issues with makefiles - at the moment they don't work! (Which was expected).
Any ideas or pointers how they should be written now (before it was a line beginning with msdev... which cannot be found now, is there an up to date equivalent to use? I read about vcbuild but I believe this is not present in VS10).
Is it possible to just build a whole project in one line?
i.e. the current line to build is:
msdev project.dsp /MAKE "$(component) - Win32 Release" /build
Any ideas what this would change to?
VS2010 no longer uses DSP style projects. The project file format has changed radically since VC6. The extension now is vcproj, not dsp.
Your best bet is to migrate the project to VS2010 format by opening it in the new IDE, and make sure it builds and runs OK there. Note that some working VC6 code will not compile in VC10 since the newer compiler is strongly conformant, while the old was not. Then, try the command line build using the resulting project.vcproj file.
I'm not sure if VS2010 will recognize and import VC6 projects. If not, then you can use Create Project from Existing Code to create a VS2010-style project from your source. This is going to be harder than just opening the old DSP file, but still easier than manual migration of all the DSP settings into a valid VS2010 vcproj file. If you are on VS2010 Express, then even this is out since that option is only in paid versions.
The VS2010 app name is devenv. From the command line, as long as you've run the right vcvars32.bat file, just type devenv /? to get the command line build help. Essentially, it's:
devenv solutionfile.sln /Build "Release"
So once you upgrade your projects and create a solution, you should be ok. There may be a way to build a project without a solution file, but I don't know how to do that.

64bit deployment

I would like to start making my application's 64bit, however, I am not sure on the changes I should make on my sln and vsproj files. What changes should I make to my sln and vsproj to make them 64bit?
On the same note, are there changes to the default sln or project file that are good for game development? I am using Visual Studio 2010.
From the VS menu select Build|Configuration Manager.
On the Configuration Manager dialog, open the Platform drop down and select <New...>.
On the New Project Platform dialog select x64 as your platform and click Ok.
To add to what was said before, make sure you understand why you need 64-bit support. In most cases you won't need access to larger memory allocations. Also, be aware that there will be x86/x64 P/Invoke compatibility problems (if you plan on using third-party unmanaged assemblies - in case you are working with managed C++).
For more information, read what Scott Hanselman has to say about this. Also, just as a sidenote, I would recommend reading this blog post that explains some of the migration ideas.
you need to add x64 solution platform:
Build -> Configuration Manager -> Active Solution Platform -> New -> New platform = x64
if you don't see "x64" make sure you installed it in Visual Studio installer
then just select "x64" as active solution platform and build

How to downgrade solution from Visual Studio 2010 to Visual Studio 2005?

I have a huge Visual Studio 2010 solution. I work with Visual Studio 2005, so I want to convert the solution to the desired version. Basically, it's a portable C++ code so it should compile on Visual Studio 2005 too. Changing the version in the *.sln file doesn't help because the *.vcxproj format is completely different from the old *.vcproj format.
Recreating the solution by hand is not an option because of its size. Also there may be some non-default compiler flags, dependencies, etc. that I don't know of (and I can't look through ALL this XML junk that I don't understand).
There is already a related question on How Do I Downgrade a C++ Visual Studio 2008 Project to 2005. However, the utility suggested there supports at most Visual Studio 2008.
Any suggestions?
It really totally sucks, that every proprietary IDE today thinks it needs to create its own project file format.
"Dear IDE developers, just use Makefiles and create a nice GUI for it so that also people without Makefile knowledge can use it!" In VS6 it was at least possible to import/export Makefiles, but not today anymore. And it was possible to use nmake for automated builds. No IDE needed to be installed, just the toolchain which could be grabbed by a simple checkout without installation.
I use CMake now. It's free, it's cross-platform, it is well supported in free IDEs like KDevelop, QtCreator, etc. It can generate Makefiles and Visual Studio projects.
So you maintain only one project source, the CMakeLists.txt file and can work with any IDE. No pain with different versions of Visual Studio or with other proprietary project file formats.
This way you can generate or VS projects for developing and you can generate Makefiles for commandline builds using nmake like in the good old days.
BTW, it's much easier to change settings in a CMakeLists.txt than clicking through various GUI dialogs. But this is a matter of personal preferences.
In my work made a utility which utilized the EnvDTE.dll and scanned a vcproj-file and optionally all vcproj-files within a sln-file. It compared all settings with a "template" and would issue a warning or optionally update the setting to correct values. We used this utility so that settings would be verified to be correct and consistent throughout all projects. I haven't updated the utility to 2010 yet due to other priorities.
EnvDTE hasn't changed much from Visual Studio 2008 to Visual Studio 2010. Perhaps it is possible to create a simple utility which opens the vcxproj-file using DTE100 and saves it using DTE90, or earlier.
Easiest way is probably to create a new project in VS 2005, and use the add existing item dialog to add the code to the project. I'd suggest using 'Empty Project' as the project type, so you don't have a lot of rubbish autogenerated for you that you'll just delete anyway.
I haven't tried it, but this looks promising:
http://www.emmet-gray.com/Articles/ProjectConverter.htm
edit: Nope, not promising, sorry :-(