1

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)

Lukas
  • 2,461
  • 2
  • 19
  • 32
  • It looks like this issue: http://stackoverflow.com/a/2850513/1262104 – Mesop Jun 01 '12 at 11:58
  • I did already what they suggest there but the linker finds somewhere .obj files compiled for x86 instead of x64. – Lukas Jun 01 '12 at 12:49
  • Are you *sure* you're using the x64 .libs? Looks to me like you're trying to use x86 libs with an x64 executable. – David Jun 01 '12 at 13:44
  • Yes it looks to me too like VS is using the x86 but that's the problem. I never specify which version of the runtime/standard library should get used, VS does that for me and if I switch before the first compilation it works fine, but if I switch afterwards it doesn't. How would I be able to tell VS to use the x64 runtime/standard library? – Lukas Jun 01 '12 at 14:08

2 Answers2

2

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

Community
  • 1
  • 1
Lukas
  • 2,461
  • 2
  • 19
  • 32
  • That's good Lukas, could you edit the answer with the actual answer instead of a link, this is in case the url changes, or the site goes down or drops the thread. (Which happens a lot actually). – David d C e Freitas Oct 17 '13 at 21:59
0

Lukas' answer above is correct. However, there may be additional complications.

If changing your Library Directory path is not working, ensure your vcxproj file is not read-only or try editing the paths directly in the vcxproj file.

With the VS Perforce add-in, changing the Library Directories paths and building may not actually save your project file and you won't get a warning that the file was read-only, allowing the build to proceed with the old, incorrect settings.

Nelno
  • 53
  • 1
  • 3