Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I've a VC++ code (VS2013) which is compiling perfectly fine in 32 bit. But when I try to compile the same code in 64bit, I'm getting the below linker error.

1>LINK : fatal error C1905: Front end and back end not compatible (must target same processor).
1>LINK : fatal error LNK1257: code generation failed

I referred the links :: Stackoverflow-link

Can I please get help to solve this issue and the code compiled for 64 bit. Unable to attach the code snippet here because, it's a very big code base.

What are you specifying for target machine architecture? Make sure you are not mixing up the different 64 bit architecture types for your build. – rrirower Feb 5, 2015 at 15:24

You cannot link 32-bit (x86) code with 64-bit (x64) code in the same executable or DLL. That means using 64-bit only versions of all your static libraries, import libraries, and DLLs. It means ensuring that every project in your solution is building with the x64 configuration.

See this post for a number of articles and presentations on 64-bit native programming.

For x64 build:

Sometimes this will happen with an old project that is converted to a new version (e.g.: VC 2013 -> VC 2015).

Insert this line to all of your *.vcxproj :

<PreferredToolArchitecture>x64</PreferredToolArchitecture>

In the entry :

<PropertyGroup Label="Globals">
</PropertyGroup>

This will fix your problem.

After hours of scouring all my objs, libs, and configurations, I tried turning my MSBuild verbosity setting up to Diagnostic level (under Tools / Options / Projects and Solutions / Build And Run in VS). This listed all the .lib's being used by the linker and I was able to find an x86 lib which was being pulled in by a #pragma comment(lib, "foo.lib").

Not sure why the list of libs is not in one of the .tlog files.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.