Visual Studio - Finding which modules are causing C1905 (processor incompatibility)

∥☆過路亽.° 提交于 2020-06-11 16:53:46

问题


I'm attempting to make an x64 build of a project with Visual Studio 2005. It's currently failing with linker error C1905, 'Front end and back end not compatible (must target same processor).'

From what I gather, this is essentially saying that my x64 build is attempting to link with x86 modules. Unfortunately, this project links with a lot of different libraries. I'm not sure which is the one causing the problem.

Is there any way to get more information out of Visual Studio?


回答1:


First, check Configuration Manager (Build > Configuration Manager...) to ensure that you're building all of your projects for the same platform.

If that doesn't help, then from the Visual Studio Command Prompt (available from the Start menu), you can use dumpbin to determine the architecture of your .lib and .obj files by doing the following:

C:\Foo> dumpbin /headers Foo.lib | more
Microsoft (R) COFF/PE Dumper Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file Foo.lib

File Type: LIBRARY

FILE HEADER VALUES
             14C machine (x86)
               3 number of sections
        4C6CB9B6 time date stamp Wed Aug 18 21:57:26 2010
             113 file pointer to symbol table
               8 number of symbols
               0 size of optional header
             100 characteristics
                   32 bit word machine

The first line under the header values tells you which architecture the .lib/.obj was compiled for (in this case, x86).

If you have a lot of linked intermediates, you could automate this a bit by just looking for x86 (or x64) files:

for /R %f in (*.obj *.lib) do @echo %f && dumpbin /headers %f | findstr /c:"machine (x86)"




回答2:


Another reason is the compilation flags. If some are not set for whole program optimization and others are not, then you will also get this error. There are two such settings in VS - one at the General level and one at C++/Optimization. Libraries produced by older versions of VS did not have this set. The ones produced by the newer versions of VS have it set.

The only way to find out offending libraries is to take them off one at a time until the error disappears.



来源:https://stackoverflow.com/questions/3528182/visual-studio-finding-which-modules-are-causing-c1905-processor-incompatibili

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!