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

  • السؤال

  • 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>Link:

    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\advapi32.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 ==========

     

    10/شعبان/1432 02:16 م

الإجابات

  • 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/
    • تم وضع علامة كإجابة بواسطة submergd 10/شعبان/1432 04:31 م
    10/شعبان/1432 02:42 م

جميع الردود

  • 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/
    10/شعبان/1432 02:23 م
  • 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.

     

    10/شعبان/1432 02:26 م
  • 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/
    10/شعبان/1432 02:29 م
  • Yeah, a simple Hello World program runs no problem. Which makes me think that it has something to do with the 'Use of MFC'?
    10/شعبان/1432 02:33 م
  • 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/
    • تم وضع علامة كإجابة بواسطة submergd 10/شعبان/1432 04:31 م
    10/شعبان/1432 02:42 م
  • I believe this has solved my problem. Thanks a ton for the help!
    10/شعبان/1432 04:31 م
  • I solved this by changing $(VCInstallDir)lib to $(VCInstallDir)lib\amd64

    or removing it and adding $LibraryPath)

    05/رمضان/1433 02:49 ص
  • @Crescen2k I am facing same problem. 

    I have a VC project. When i build it with v100 and V80 (configuration win32 ) all goes well. But when i build it with v80 and V100 (configuration x64) there occurs link error "LNK 1112" when project is build for x64.

    I have "Target Machine" set to x64 in linker->advanced settings. I have chosen x64 as Active solution plateform. Cant figure out why this error occurs?

     i created new win32 console project. In configuration manager properties there are only two configuration available win32 and Empty.

    Now what does this point out? I need your help

    I am using Visual Studio 2012 Ultimate. 

    Best Regards


    • تم التحرير بواسطة AliKazmi 01/محرم/1435 10:15 ص
    01/محرم/1435 09:47 ص