linking problem: fatal error LNK1112: module machi

2019-01-11 09:48发布

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

13条回答
小情绪 Triste *
2楼-- · 2019-01-11 10:29

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.

查看更多
叼着烟拽天下
3楼-- · 2019-01-11 10:33

Try changing every occurence of .\Release into .\x64\Release in the x64 properties. At least this worked for me...

查看更多
Lonely孤独者°
4楼-- · 2019-01-11 10:35

In my case it appears it was because I had "copied settings" from a 32-bit to a new configuration (64 bit) and it hadn't updated the libraries. Odd.

1>MSVCRTD.lib(ti_inst.obj) : fatal error LNK1112: module machine type ‘X86’ conflicts with target machine type ‘x64’

this meant “your properties -> VC++ Directories -> Library Directories” is pointing to a directory that has 32 bit libs built in it. Fix somehow!

In my case http://social.msdn.microsoft.com/Forums/ar/vcgeneral/thread/c747cd6f-32be-4159-b9d3-d2e33d2bab55

ref: http://betterlogic.com/roger/2012/02/visual-studio-2010-express-64-bit-woe

查看更多
甜甜的少女心
5楼-- · 2019-01-11 10:35

An update to i00g's and Thomas' answers, this time for VS2012 (some names have changed). After copying x86 settings over into an x64 target with the configuration manager, you'll have the problem for the same reason as was the case earlier (lib targets aren't correct in the x64 config). Open your .vcxproj (text editor) and replace MachineX86 with MachineX64 where appropriate. (I still haven't found where this is on the property sheets....) This only seems to be necessary with static libs.

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-01-11 10:35

Recently,I also encountered this problem. That's because I used qt(x64) in vs win32. If you want to use qt application x64, you could choose vs x64--as the above. If you want to use win32 and perhaps you haven't,you need to download qt(32bit),then correctly set your enviroment, such as the lib directory, etc.(note: maybe you are is old set in x64(other version), if you convert your win32 or x64 into another, Additional Dependencies includes the old directory!)

查看更多
Luminary・发光体
7楼-- · 2019-01-11 10:39

before going for the step "compile -DIPLIB=NONE filename.cxx" take the path of VIsual Studio installation upto the vcvarsall batch file and change the configuration as shown below.

*C:\apps\MVS9\VC\vcvarsall.bat x86_amd64*

now next step should be

compile -64bit -DIPLIB=none filename.cxx

this solved the problem for me

查看更多
登录 后发表回答