Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Im trying to run sample app from wxFreeChart library. After compilation on linking there is an error:

wxcode_msw28d_freechart.lib(wxfreechart_lib_xydataset.obj) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' 

I tried to switch linker option\advanced\target machine to MachineX64 but it doesnt work.

Im using visual studio 2008, any suggestion ?

thanks for help

like image 657
gruber Avatar asked May 17 '10 13:05

gruber


People also ask

What is module machine type?

Module machine type is the machine on which you are compiling and the target machine type/Visual studio command prompt selected, is the architecture x86 or x64 for which you are building your binaries.

How do I change the target machine type in Visual Studio?

Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > Linker > Advanced property page. Modify the Target Machine property.


1 Answers

The error is explicit, you are trying to link libraries that were compiled with different CPU targets. An executable image can only contain pure x86 (32-bit) or pure x64 (64-bit) code. Mixing is not possible.

You change the target CPU by creating a new configuration for the project, only changing the linker setting isn't enough. Build + Configuration Manager, Active solution platform combo on upper right, choose New and select x64. That creates a new configuration with several modified project settings, most importantly the compiler that will be used.

Beware that prior to VS2010, the 64-bit compilers are not installed by default. If you don't see x64 in the platform combo then you'll need to re-run setup.exe and turn on the option to install the 64-bit compilers. Then also re-run any service pack installer you may have applied.

A possible approach with less pain points is to use the 32-bit version of the library.

like image 196
Hans Passant Avatar answered Sep 23 '22 10:09

Hans Passant