fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

# fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

• Monday, July 11, 2011 2:16 PM

I've read a lot of similar problems to mine, but none had a solution that helped. I'm building a program that runs the functions of a DLL. Everything compiled fine in 32 bit, but now that I'm tryign to compile for x64 I get a lot of errors.

I get the error in the title for the following libraries:
mfcs100.lib  msvcrt.lib  msvcprt.lib

I tried adding them to the ignored libraries list, but then got a large number of unresolved linker errors. The program I'm creating is using MFC in a Shared DLL, if that helps.

Any help would be greatly appreciated

(an example of my error output follows)

1>------ Rebuild All started: Project: SpellCheckTest, Configuration: Release x64 ------

1>Build started 7/11/2011 9:08:54 AM.

1>_PrepareForClean:

1> Deleting file "x64\Release\SpellCheckTest.lastbuildstate".

1>InitializeBuildStatus:

1> Touching "x64\Release\SpellCheckTest.unsuccessfulbuild".

1>ClCompile:

1> SpellCheckTest.cpp

1> stdafx.cpp

1>

1> Searching libraries

1> Searching SpellCheckUI.lib:

1> Searching C:\Documents and Settings\MyName\Desktop\code\SpellCheckUI\\Hunspell\hunspell-1.2.14\src\win_api\Debug_dll\libhunspell\libhunspell.lib:

1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\lib\mfc100.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\msimg32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\comctl32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\shlwapi.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:

1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\lib\atls.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\oledlg.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\urlmon.lib:

1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\gdiplus.lib:

1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\comsuppw.lib:

1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:

1>msvcprt.lib(MSVCP100.dll) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

1>

1>Build FAILED.

1>

1>Time Elapsed 00:00:03.48

========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

### All Replies

• Monday, July 11, 2011 2:23 PM

Yes, it is not a good idea to ignore those libraries as the are required to actually get the application to build and run.

The issue here is that it is trying to link with the 32 bit version of these libraries. How did you set up the x64 target? Did you make sure the x64 compilers were installed? Did you modify any basic paths along the way?

This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/
• Monday, July 11, 2011 2:26 PM

The target system is set as: MachineX64 (/MACHINE:X64). I set this up by going to the configuration manager and switching the platform to x64

Yes, the compilers are definitely installed. I can compile the DLL I'm using fine, but this program (which uses the DLL) won't compile.

As far as I know, I didn't modify anything else.

• Monday, July 11, 2011 2:29 PM

Can you create a new console/windows project and build that for x64? (A simple hello world would do).
This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/
• Monday, July 11, 2011 2:33 PM

Yeah, a simple Hello World program runs no problem. Which makes me think that it has something to do with the 'Use of MFC'?
• Monday, July 11, 2011 2:42 PM

It is possible that the project itself has had the lib path modified in the project itself and is pointing at the wrong version.

Go to Project Properties->Configuration Properties->VC++ Directories and look at Library Directories. If this is in bold then you need to check to see if all of the lib paths point to the x64 libs. The default value is either

\$(LibraryPath);\$(VSInstallDir);\$(VSInstallDir)lib\amd64

or

\$(WindowsSdkDir)lib\x64;\$(VCInstallDir)lib\amd64;\$(VCInstallDir)atlmfc\lib\amd64;\$(VSInstallDir);\$(VSInstallDir)lib\amd64

as you probably have guessed, the x64 or amd64 in these paths are vitally important. If this isn't bold but the paths are still wrong, you'll need to check out something else, but that can come later.

But a way for you to test whether it is MFC or not is to create a simple MFC application and build that.

This is a signature

Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
Visit my (not very good) blog at
http://ccprogramming.wordpress.com/
• Marked As Answer by Monday, July 11, 2011 4:31 PM
•
• Monday, July 11, 2011 4:31 PM

I believe this has solved my problem. Thanks a ton for the help!
• Tuesday, July 24, 2012 2:49 AM

I solved this by changing \$(VCInstallDir)lib to \$(VCInstallDir)lib\amd64

or removing it and adding \$LibraryPath)