How to build OpenSSL 1.1 - windows

When OpenSSL1.1 is built by the command line on Windows 10 (x64), an error occurred.
The x86 build was successful.
What is the cause of x64 build error?
When LNK1112 occurs, it is guided how to change the target computer from the properties of the solution, but can this setting be changed by the command line?
■ Phenomenon
An error occurs in nmake after generating a makefile with perl.
Error message
cl /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD /W3 /wd4090 /nologo /O2 /I "." /I "crypto\include" /I "include" /I "crypto" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSLDIR=\"C:\\Program Files\\Common Files\\SSL\"" -D"ENGINESDIR=\"C:\\openssl\\build\\win\\x64\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"OPENSSL_USE_APPLINK" -D"NDEBUG" /Zs /showIncludes "crypto\cversion.c" 2>&1 > crypto\cversion.d
IF EXIST .manifest DEL /F /Q .manifest
IF EXIST libcrypto-1_1-x64.dll DEL /F /Q libcrypto-1_1-x64.dll
link /nologo /debug /dll /nologo /debug /implib:libcrypto.lib /out:libcrypto-1_1-x64.dll /def:libcrypto.def #C:\Users\XXXXXXXXX\AppData\Local\Temp\nm5483.tmp || (DEL /Q libcrypto-1_1-x64.* libcrypto.lib && EXIT 1)
crypto\cversion.obj : fatal error LNK1112: module machine type 'X64' conflicts with target machine type 'x86'
■ Environment
VC2019
Perl v5.28.1
Build target OpenSSL 1.1.1d
■ Build command(.bat)
The same error occurs in "vcvars64.bat".
set PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build;%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsx86_amd64.bat"
perl Configure no-asm --prefix=C:/openssl/build/win/x64 VC-WIN64A
nmake install

Was self resolved.
An error occurred when linking an x86 object because it was built with a garbage file remaining after x86 build.
The build succeeded after decompressing tgz of OpenSSL again.

I had the same issue with building QCustomPlot2 for python. The fix was to delete the qcustomplot2 folder then decompress the tar.gz again.... The left over garbage was screwing me over no matter how I tried to build it.. I tried every developer tool for visual studio there was, even the cross compilers.. But deleting everything and then decompressing the downloader archieve was the best fix.
I have x64 windows... I used x64 native tools cmd prompt for visual studio 2019. It built perfectly first try after that.

Related

Visual Studio 2022: error MSB3721: The command "ml.exe ... " exited with code 1

I am using Microsoft Visual Studio Community 2022 (ARM 64-bit) Version 17.3.0 Preview 6.0 to build a Win32 (Intel x86 32-bit) application. I get the following error:
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\BuildCustomizations\masm.targets(70,5): error MSB3721: The command "ml.exe /c /nologo /Sg /Zi /Fo"Debug\byteasm.obj" /D"_DEBUG" /Fl"Debug\byteasm.lst" /W3 /errorReport:prompt /TaC:\Users\James\Documents\Dolphin\Core\DolphinVM\VMLib..\byteasm.asm" exited with code 1.
But when I open a command prompt I can successfully execute the following:
"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.33.31629\bin\Hostx86\x86\ml.exe" /c /nologo /Sg /Zi /Fo"Debug\byteasm.obj" /D"_DEBUG" /Fl"Debug\byteasm.lst" /W3 /errorReport:prompt /TaC:\Users\James\Documents\Dolphin\Core\DolphinVM\VMLib..\byteasm.asm
Assembling: C:\Users\James\Documents\Dolphin\Core\DolphinVM\VMLib..\byteasm.asm
Since I can execute the same thing (?) from the command line I don't understand why VisualStudio is reporting an error. Any advice? Once I've done the assembly manually, can I tell VisualStudio to skip it?
The suggestion from #njuffa to increase the verbosity of the build was helpful and showed the error that it could not find ml.exe. I believe this is a bug in Version 17.3.0 Preview 6.0 since it is able to find the C++ compiler for x86. My workaround was to add the x86 tools directory to the path (which would break attempts to build for any other environment). Thanks to all for the helpful responses and advice!

How to build SLN file from the command line using MSVC build tools

I am trying to build the Hunspell project on GitHub with MSVC 2017 build tools:
https://github.com/hunspell/hunspell
The project have a msvc folder containing a Hunspell.sln and libhunspell.vcxproj files (I am interested in the library)
My setup:
Windows 10
MSVC2017 build tools (15.9.3)
Windows 10 Kit: 10.0.17763.0
If I open the "x86 Native Tools Command Prompt for VS 2017" and try to build the solution I get the following error:
>msbuild libhunspell.vcxproj
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2018/12/01 6:01:18 PM.
Project "c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v140_xp\Toolset.targets(36,5): warning MSB8003: Could not find WindowsSdkDir_71A variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj]
InitializeBuildStatus:
Touching "Debug\libhunspell\libhunspell.tlog\unsuccessfulbuild".
PreBuildEvent:
echo N | copy /-Y ..\src\hunspell\hunvisapi.h.in ..\src\hunspell\hunvisapi.h
:VCEnd
Overwrite ..\src\hunspell\hunvisapi.h? (Yes/No/All): N
0 file(s) copied.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /I..\src\hunspell /I. /ZI /nologo /W4 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _WINDOWS /D _USRDLL /D HUNSPELL_STATIC /D _CRT_SECURE_NO_WARNINGS /D _USING_V110_SDK71_ /D_MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\libhunspell\\" /Fd"Debug\libhunspell\libhunspell.pdb" /Gd /TP /wd4706 /wd4251 /wd4267 /analyze- /errorReport:queue ..\src\hunspell\csutil.cxx
csutil.cxx
c:\development\hunspell\hunspell-1.7.0\src\hunspell\csutil.cxx(84): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory [c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj]
Done Building Project "c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj" (default targets) -- FAILED.
Build FAILED.
"c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj" (default target) (1) ->
(CheckWindowsSDK71A target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v140_xp\Toolset.targets(36,5): warning MSB8003: Could not find WindowsSdkDir_71A variable from the registry. TargetFrameworkVersion or PlatformTool set may be set to an invalid version number. [c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj]
"c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj" (default target) (1) ->
(PrepareForBuild target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj]
"c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj" (default target) (1) ->
(ClCompile target) ->
c:\development\hunspell\hunspell-1.7.0\src\hunspell\csutil.cxx(84): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory [c:\Development\Hunspell\hunspell-1.7.0\msvc\libhunspell.vcxproj]
The important part in the above is the following: Cannot open include file: 'windows.h'
It seems like my console is set up correctly when looking at the INCLUDES variable:
echo %INCLUDE%
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt
I have tried many options like running as follow, with no luck:
> msbuild libhunspell.vcxproj /p:AdditionalIncludeDirectories="C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um"
I have also added the full path to the "um" and "shared" (for winapifamily.h) folders to the <AdditionalIncludeDirectories> property manually in the vcxproj file.
This works for the static libs, but I had to add the <AdditionalIncludeDirectories> to the <ResourceCompile> step.
For the dlls (Release_Dll, etc) linking did not work since I don't know how to fix this (yet).
The above feels wrong, I do not think that the solution can be to hack a project file for the compiler to know where its own files are.
Any help in this regard will be appreciated.
Note: I do not have Visual Studio IDE installed, most SO questions around this question involve steps to solve the issue by changing settings in Visual Studio. This does not apply to this question.
PS: I have no experience with msbuild or the build tools. I normally use the Qt Creator IDE for building with MSVC compiler.
How to build SLN file from the command line using MSVC build tools
You should install the Individual components VC++ 2015.3 v14.00 (v140) toolset for desktop via build tools.
According to the error log:
TargetFrameworkVersion or PlatformToolset may be set to an invalid
version number
When we open the libhunspell.vcxproj with notepad, we could to know following properties:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_dll|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
So, to resolve this issue, we need install the toolset v140_xp. To accomplish this, Open the build tool, switch to the Individual components tab and select VC++ 2015.3 v14.00 (v140) toolset for desktop:
After that, I can build the peoject successfully:
Hope this helps.

/bin/sh: cl: command not found usig make within cygwin

I'm working with Intel Pin on a Windows 7 machine. As suggested on Pin user guide, I downloaded Cygwin with the packages I need, such as gcc, g++ and make, but when I try to execute the command "make" in order to build one tool (Insmix in this case, but it is the same with any other Pin tool) I get the following error:
make[1]: Entering directory '/cygdrive/c/Users/IEUser/Downloads/pin-3.2-81205-msvc-windows/source/tools/Insmix'
cl /MT /EHs- /EHa- /wd4530 /DTARGET_WINDOWS /DBIGARRAY_MULTIPLIER=1 /nologo /Gy /Oi- /GR- /GS- /D__PIN__=1 /DPIN_CRT=1 /D_WINDOWS_H_PATH_="" /D__i386__ /DTARGET_IA32 /DHOST_IA32 /I../../../source/include/pin /I../../../source/include/pin/gen -I../../../extras/stlport/include -I../../../extras -I../../../extras/libstdc++/include -I../../../extras/crt/include -I../../../extras/crt -I../../../extras/crt/include/arch-x86 -I../../../extras/crt/include/kernel/uapi -I../../../extras/crt/include/kernel/uapi/asm-x86 /FIinclude/msvc_compat.h /I../../../extras/components/include /I../../../extras/xed-ia32/include/xed /I../../../source/tools/InstLib /O2 /c /Foobj-ia32/insmix.obj insmix.cpp
**/bin/sh: cl: command not found**
make[1]: *** [../../../source/tools/Config/makefile.default.rules:192: obj-ia32/insmix.obj] Error 127
I tried to Google it with no success. Does anyone know how to fix this issue?
Thank you very much for you help
cl is prettymuch a Microsoft tool. Install some Visual Studio version, and you'll have that cl tool somewhere in the bin directory in C:\Program Files\Microsoft Visual Studio\...\bin\ Now you set that directory in the environment Path variable. Voila. That works.

make: cl: Command not found

I'm trying to install Google OR-Tools for Java in Visual Studio 2015. When I run make all in the OR-Tools directory, as required, I get
E:\My_files\VS\BC\or-tools_VisualStudio2015-64bit_v6.4.4495>make all
cl /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo /O2 -DN
DEBUG -DUSE_CBC -DUSE_CLP /D__WIN32__ /Iinclude\\src\\windows
/DGFLAGS_DLL_DECL=
/DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /Iinclude /I. -
DUSE_GLOP -
DUSE_BOP -c examples\\cpp\\costas_array.cc /Foobjs\\costas_array.obj
make: cl: Command not found
make: *** [objs\\costas_array.obj] Error 127
I read somewhere to run vcvarsall.bat to set variables, but there is no such file on this path
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
Plus I'm supposed to run it in Native Tools Command Prompt, but I cannot find this for VS2015, only for VS2017, so I run it in Developer Command Prompt. Might this be the issue?
Apparently, I did not add C++ tools when installing Visual Studio.
File -> New -> Project -> Visual C++ and there's the install option. Maybe it will help someone.

Compile Apache APR on Windows

The end result is I am trying to compile something that requires the APR from Apache on Windows.
Edit: Tried Visual Studio command line tools for VS2013 & VS2014.
Link for SVN checkout shows 404: http://apr.apache.org/anonsvn.txt
so...
From this link http://apr.apache.org/compiling_win32.html I have downloaded the three files. I unzipped them and renames them as the directory structure suggested.
C:\work\apr\
C:\work\apr-iconv\
C:\work\apr-util\
Moved to the apr-util directory and ran the following make command and received the following errors.
Note there is the comment about "Current versions of APR do not need awk..." but the link does not work, does it matter?
Anybody have any luck compiling this, do I need other lib/include/objects?
nmake -f Makefile.win buildall checkall installall clean
Received the following errors:
<clip>
rc.exe /l 0x409 /fo".\Release\libapriconv.res" /i "./include" /i "../apr/include" /d "NDEBUG" /d "API_VERSION_ONLY" .\libapriconv.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17336
Copyright (C) Microsoft Corporation. All rights reserved.
link.exe #C:\Users\JOHNAT~1\AppData\Local\Temp\nm390A.tmp
Creating library .\Release\libapriconv-1.lib and object .\Release\libapriconv-1.exp
if exist .\Release\libapriconv-1.dll.manifest mt.exe -manifest .\Release\libapriconv-1.dll.manifest -outputresource:.\Release\libapriconv-1.dll;2
echo Helper for Post-build step > ".\Release\postbld.dep"
cd ccs
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe" -nologo -f Makefile.win all BUILD_MODE="Win32 Release" BIND_MODE=shared adobe-stdenc.c
Creating library ..\Release\iconv\adobe-stdenc.lib and object ..\Release\iconv\adobe-stdenc.exp
adobe-stdenc.obj : error LNK2011: precompiled object not linked in; image may not run
..\Release\iconv\adobe-stdenc.so : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
It's a little late, but here is how I fixed it.
In the build\modules.mk.win makefile change line 221 from
$(SILENT)link $(ALL_LDFLAGS) $*.obj $(API_LIBS) /out:$# \
To
$(SILENT)link $(ALL_LDFLAGS) $*.obj $(MODRES).obj $(API_LIBS) /out:$# \
The shared library target will now read:
.c{$(OUTPUT_DIR)}.so:
$(SILENT)cl $(ALL_CFLAGS) /Fo$*.obj /Yuiconv.h /c $<
$(SILENT)link $(ALL_LDFLAGS) $*.obj $(MODRES).obj $(API_LIBS) /out:$# \
/base:#"..\build\BaseAddr.ref",$(#F)
$(SILENT)if exist $#.manifest \
$(SILENT)mt -nologo -manifest $#.manifest -outputresource:$#;2 \
& del "$#.manifest"
$(SILENT)del "$*.exp" & del "$*.lib"
Source: https://gist.github.com/mkhon/01a1536b01e0065ae799
From the apache-apr project site under heading:
Developer Studio Workspace/Microsoft Development Environment IDE Build::
Open the apr-util/aprutil.dsw workspace, and choose either aprutil or libaprutil (for static or dynamic libraries) with the Release or Debug build as the Active Project. aprutil.dsw causes all related projects to be built.
Maybe you overlooked this statement : choose either aprutil or libaprutil as the Active Project...
Then build the active project.

Resources