C++ – How to force Visual Studio 2010 to use x64

cplatformvisual studio 2010

Whenever I create a new project in Visual Studio 2010 and don't set the specific platform (in my case x64) at first, I won't be able to completly change it afterwards.
So I setup everything a need with an external library (compiled as x64) and then press compile it obviously fails since the two platforms do not match.

sfml-graphics-s-d.lib(RenderStates.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

Noticed that I change it to x64 with Build->Configuration-Manager->Active projectplattform->New…->x64. That's the same thing I'd do before doing anything else and it works, but if I do it afterwards I get the linker error:

libcpmtd.lib(uncaught.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

The *.obj file can change from project to project (e.g. cout.obj) and from my understanding Visual Studio picks the x86 standard library and doesn't change it's decision after I've switched the platform.

So for the question: How do I force VS to use the new specified x64 platform – also for the standard library?

Note: Creating a new configuration setup will automatically change the linker setting for the target machine to: MachineX64 (/MACHINE:X64)

Note: Not sure if it's relevant but I'm linking the runtime library statically Multithreaded-Debug (/MTd)

Best Answer

If anyone would ever run into the same problems as I did, he can find the discussion and solution over at the MSDN 'forum'.

OK, I found it, LibraryPath corresponds to Library Directories property in VC++ Directories project property page. That explains what happened, that value is usually inherited so it changes automatically when you create add x64. But since you modified that value it is now local to the project and it simply gets copied when add x64... with all those x86 specific dirs.

I suppose it's simpler and safer to just add that lib dir in Linker\General\Additional Library Directories

Related Topic