Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link error when compile for target VC-WIN64 #5366

Closed
xyuan240 opened this issue Feb 14, 2018 · 5 comments
Closed

Link error when compile for target VC-WIN64 #5366

xyuan240 opened this issue Feb 14, 2018 · 5 comments

Comments

@xyuan240
Copy link

xyuan240 commented Feb 14, 2018

Hi,

I am trying to compile openssl-1.1.1-pre1 and set the target as VC-WIN64A, The compiling process ended with the error below, I tried with VC-WIN32 as well, and it failed with a similar error, Could you please help? Thanks

        "C:\Perl64\bin\perl.exe" "crypto\x86cpuid.pl" "win32n" "-W3 -wd4090 -Gs0 -GF -Gy -nologo /MD /O2 -WX" "/Zi /Fdossl_static" "-DDSO_WIN32 -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_
CRT_SECURE_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DUNICODE -D_UNICODE -DOPENSSL_USE_APPLINK -DNDEBUG -DOPENSSL_NO_STATIC_ENGINE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_BN_ASM_PART_WORDS -
DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DRC4_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM -DVPAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_AS
M -DPADLOCK_ASM -DPOLY1305_ASM" ""-DOPENSSLDIR=\"C:\\Program Files (x86)\\Common Files\\SSL\"" "-DENGINESDIR=\"C:\\Program Files (x86)\\OpenSSL\\lib\\engines-1_1\""" "" crypto\x86cpuid.asm
        nasm -f win32 -ocrypto\x86cpuid.obj "crypto\x86cpuid.asm"
        IF EXIST libcrypto-1_1.dll.manifest DEL /F /Q libcrypto-1_1.dll.manifest
        link /nologo /debug /dll  /implib:libcrypto.lib /out:libcrypto-1_1.dll /def:libcrypto.def @C:\Users\X_Yuan\AppData\Local\Temp\nmDB88.tmp || (DEL /Q libcrypto.* libcrypto-1_1.* && EXIT 1)
crypto\aes\aes-586.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
NMAKE : fatal error U1077: 'link' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

Regards

@mattcaswell
Copy link
Member

module machine type 'X86' conflicts with target machine type 'x64'

This error usually means you are attempting to compile a 64-bit version of OpenSSL using the 32-bit VC toolchain (or possibly the other way around). Make sure you are using the correct Developer Command Prompt for the build you are attempting:

https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs

If you want to do a VC-WIN32 build use the 32-bit developer command prompt. For VC-WIN64A build using the 64-bit developer command prompt.

@dot-asm
Copy link
Contributor

dot-asm commented Feb 16, 2018

Reference to Developer Command Prompt can be misleading, because there is "Developer Command Prompt" icon on start menu, but it's wrong one. In the essence Developer Command Prompt targets rather .NET developers, and .NET programming is platform-neutral in sense that there are no 32- or 64-bit .NET binaries, no x86 or ARM either... Advising on what to look for for OpenSSL purposes is problematic, because they, Microsoft that is, change it all the time. And they also make it confusing with references to "native" and "cross" tools. The best we can do is to say that it's user's responsibility to ensure that current toolchain matches the target. In more practical terms it means that for VC-WIN64A target cl command [executed with no arguments] should print "compiler version x.y.z for x64", and for VC-WIN32 target - "compiler version x.y.z for x86".

@dot-asm dot-asm closed this as completed Feb 16, 2018
@dot-asm
Copy link
Contributor

dot-asm commented Feb 16, 2018

The best we can do is to say that it's user's responsibility

Well, one can wonder if it would be appropriate to check for cl output at configuration time and tell the user that a wrong compiler is about to be used... I mean to tell that it's users' responsibility is still the best we can do, but it might be appropriate to tell it as early as possible...

@chohan
Copy link

chohan commented Nov 22, 2019

Using x64 version cl on x64 command prompt, but still get same error "fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'
NMAKE : fatal error U1077: 'link' : return code '0x1'"

@shadowfoxish
Copy link

I had a similar experience as @chohan (where I used the generic "Developer Command Prompt for VS2019" first) but after the first time it "failed" to compile, I closed that command prompt and opened the "x64 Native Tools Command Prompt for VS 2019" and I ran nmake clean, and then reissued nmake command, and that worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants