Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve the module machine type 'X86' conflicts with target machine type 'x64' Visual Studio

I am compiling Openssl library that I need to use in python script. I am using Visual Studio 2015 Developer Command Prompt. My machine is Windows 7 64-bit.

When I type the command: nmake -f ms\ntdll.mak

I get this error:

tmp32dll\uplink.obj : fatal error LNK1112: module machine type 'X86' conflicts w
ith target machine type 'x64'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0
\VC\BIN\amd64_arm\link.EXE"' : return code '0x458'
Stop.

I searched and several solutions for similar problem suggest changing the project platform from the project settings. I do not have VS project. I am running all these commands just to compile the OpenSSL library. I am using the VS command.

like image 606
user2192774 Avatar asked Jul 23 '15 18:07

user2192774


People also ask

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.

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.


3 Answers

I ran into the same issue - just with VS2013.

There are 2 approaches which I came across which may or may not be helpful in your case:

THE FIRST APPROACH

(May only be relevant for versions VS2013 and above)

Open the 'VS2015 x64 Native Tools Command Prompt' and execute the command there.

 Note:
 If you get the opposite message:
 module machine type 'x64' conflicts with target machine type 'x86' 
 then you should open the 'VS2015 x86 Native Tools Command Prompt' 

Both tools can be found under the folder:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\Shortcuts

THE SECOND APPROACH

(May only be relevant for versions prior to VS2013)

In the Developer Command Prompt for VS2015 you can change the compiler target platform by running the following command

"C:\Program Files (x86)\Microsoft Visual Studio 15.0\VC\vcvarsall.bat x64"

"C:\Program Files (x86)\Microsoft Visual Studio [VS Version]\VC\vcvarsall.bat [Target Platform]"

For VS 2017

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat [Target Platform]"

Note:
VS Version: 10.0|11.0|12.0|15.0|... 
Target Platform: x86|amd64|x64|arm|x86_arm|x86_amd64|amd64_x86|amd64_arm|amd64_x86
*leaving the target platform empty will default to x86
like image 113
Merav Kochavi Avatar answered Oct 24 '22 04:10

Merav Kochavi


This error means that tmp32dll\uplink.obj is a 32-bit binary whereas the linker expected it to be 64-bit as it's targeting 64-bit.

Looks like you need to re-compile it as 64-bit, or just perform a rebuild-all (or delete all *.obj or even the whole binary output directory)

This can happen if the build process is interrupted, then you change the target platform, and then you repeat the build process in an incremental manner. 32-bits don't mix with 64-bits, so it's either completely one way or the other.

like image 7
V-R Avatar answered Oct 24 '22 04:10

V-R


This error comes up because a specific component in the build is being compiled as an x86 binary instead of x64 (the target machine's architecture) - basically you're giving the linker a square puzzle piece and telling it to fit into a circular hole.

In your case:

tmp32dll\uplink.obj : fatal error LNK1112: module machine type 'X86' conflicts w
ith target machine type 'x64'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0
\VC\BIN\amd64_arm\link.EXE"' : return code '0x458'
Stop.

You look at the name of the obj file that is causing the error: uplink.obj, so you look at uplink.cpp (or uplink.asm or uplink.whatever) and inspect how it's being compiled. Usually all that stuff is automated in VS but sometimes there are special build steps that were added in by the developer. Inspect the custom, pre- and post- build events to see if a x86 tool is being used to assemble it.

In my case, I was trying to compile 7zip in x64 using visual studio 8 and everything was compiling except for the assembly macros (asm), which were compiling in x86 and breaking the build process. I found that VS was trying to use ml.exe to compile them instead of ml64.exe by looking at the asm's property sheet. In my case changed the call to ml64.exe to get rid of this error (I also had to modify the asm files to be 64bit only by getting rid of all the x86 code but that's another story).

like image 1
thebunnyrules Avatar answered Oct 24 '22 02:10

thebunnyrules