sip-4.16.2 makefile error

2019-08-30 08:43发布

问题:

I'm trying to install PyQt4 on a Windows 8 machine. I know almost nothing about makefiles, only enough to run make, make install, and make clean. I am stuck on the installation process for SIP.

When running nmake from a VisualStudio command prompt, I get the error as follows:

python27.lib(python27.dll) : fatal error LNK1112: module machine type 'x64 conflicts with target machine type 'x86'

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\link.EXE?' : ? return code '0x458'

Stop.

NMAKE : fatal error U107: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'

Stop.

Any idea what the problem is?

回答1:

I had similar problem and solved it.

I guess it was caused by command line configuration of vcvarsall.bat in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC, I don't know if you used command 'vcvarsall' before 'qmake' and 'nmake', but for me, the project(for me, it's QScintilla) even couldn't be built when I did't use 'vcvarsall'.

But, the make process still not succeed due to " fatal error LNK1112: module machine type 'x64 conflicts with target machine type 'x86' ", I try to think how to change the target machine configuration in command line(because those hot questions,similar to this, all were solved with Visual Studio).

Luckily, I eventually found it has the relationship with the parameter configuration of 'vcvarsall', because 'vcvarsall' works for the make of target 32-bit by default.When I change the 'vcvarsall' to 'vcvarsall amd64' , it worked!

More details in here:https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019#developer_command_file_locations



回答2:

The error you are getting:

XXXX.lib(XXXX.dll) : fatal error LNK1112: module machine type 'x64 conflicts with target machine type 'x86'

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\link.EXE?' : ? return code '0x458'

States that the makefile you are trying to build is targeted for platform type x86 but you are using a compiler which is x64.

There are 2 approaches which I came across:

THE FIRST APPROACH

(May only be relevant for versions VS2013 and above)

Open the VS2013 x86 Native Tools Command Prompt and execute the command there.

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

Both tools can be found under the folder:

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

THE SECOND APPROACH

(May only be relevant for versions prior to VS2013)

Since you are running the command from the Visual Studio developer command prompt you can see what compiler is running by executing the command

cl

This command will return the following line

Microsoft (R) C/C++ Optimizing Compiler Version [Compiler Version] for [target platform]

 Compiler Version: XX.XX.XXXXX
 Target Platform: x64|x86

This will provide information regarding the version of the VS Compiler and the target platform.

You can change the target platform by running the following command:

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

 VS Version: 10.0|11.0|12.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

In your case you would run the following command:

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



标签: makefile sip