When I try to build my app, which depends on openssl3, with conan, I get the following error while conan is trying to build openssl3:
> conan install . --build=missing --profile:build=default_windows_x64_release --profile=default_windows_x64_debug
...
openssl/3.0.8: Generating aggregated env files
openssl/3.0.8: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
openssl/3.0.8: Calling build()
openssl/3.0.8: RUN: C:/Users/username/.conan2/p/straw898fb56546adc/p/bin/perl.exe ./Configure "VC-conan-Debug-Windows-x86_64-msvc-191" no-shared --prefix=/ --libdir=lib --openssldir="C:Usersusername.conan2pbopens4a3ff4f862506pres" no-unit-test threads PERL=C:/Users/username/.conan2/p/straw898fb56546adc/p/bin/perl.exe no-tests --debug enable-fips no-md2 zlib --with-zlib-include="C:/Users/username/.conan2/p/b/zlib69dc6f0d4df93/p/include" --with-zlib-lib="C:/Users/username/.conan2/p/b/zlib69dc6f0d4df93/p/lib/zlib.lib"
conanvcvars.bat: Activating environment Visual Studio 15 - amd64 - winsdk_version=None - vcvars_ver=14.1
[vcvarsall.bat] Environment initialized for: 'x64'
Configuring OpenSSL version 3.0.8 for target VC-conan-Debug-Windows-x86_64-msvc-191
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created makefile.in
Created makefile
Created includeopensslconfiguration.h
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL.md file first) ***
*** ***
**********************************************************************
openssl/3.0.8: RUN: nmake
conanvcvars.bat: Activating environment Visual Studio 15 - amd64 - winsdk_version=None - vcvars_ver=14.1
[vcvarsall.bat] Environment initialized for: 'x64'
Microsoft (R) Program Maintenance Utility Version 14.16.27051.0
Copyright (C) Microsoft Corporation. All rights reserved.
"C:/Users/username/.conan2/p/straw898fb56546adc/p/bin/perl.exe" "-I." -Mconfigdata "utildofile.pl" "-omakefile" "includecryptobn_conf.h.in" > includecryptobn_conf.h
...
"C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023binHostX64x64nmake.exe" / depend
Microsoft (R) Program Maintenance Utility Version 14.16.27051.0
Copyright (C) Microsoft Corporation. All rights reserved.
"C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023binHostX64x64nmake.exe" / _build_sw
Microsoft (R) Program Maintenance Utility Version 14.16.27051.0
Copyright (C) Microsoft Corporation. All rights reserved.
"cl" /Zi /Fdossl_static.pdb /MTd /Zl /Gs0 /GF /Gy -MTd -Zi -Ob0 -Od -FS -MTd -Zi -Ob0 -Od -FS -I"." -I"include" -I"appsinclude" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSLDIR="C:\Users\username\.conan2\p\b\opens4a3ff4f862506\p\res"" -D"ENGINESDIR="\lib\engines-3"" -D"MODULESDIR="\lib\ossl-modules"" -D"OPENSSL_BUILDING_OPENSSL" -D"ZLIB" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/Users/username/.conan2/p/b/zlib69dc6f0d4df93/p/include" -c /Foappsliblibapps-lib-app_libctx.obj "appslibapp_libctx.c"
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27051 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
app_libctx.c
C:Usersusername.conan2pbopens4a3ff4f862506bsrcincludeopenssl/crypto.h(25): fatal error C1083: Cannot open include file: 'stdlib.h': No such file or directory
NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023binHostX64x64cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023binHostX64x64nmake.exe"' : return code '0x2'
Stop.
openssl/3.0.8: ERROR:
Package 'df45d737e7817e09557f98b927968632469772f8' build failed
openssl/3.0.8: WARN: Build folder C:Usersusername.conan2pbopens4a3ff4f862506bbuild-debug
ERROR: openssl/3.0.8: Error in build() method, line 520
self._make()
while calling '_make', line 513
self._run_make()
while calling '_run_make', line 490
self.run(" ".join(command), env="conanbuild")
ConanException: Error 2 while executing
I suspect this happens because MSVS doesn’t set all of the includes and paths correctly. I think so, because when I execute “set INCLUDE” in Developer Command Prompt for VS 2017, I get this:
>set include
INCLUDE=C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023ATLMFCinclude;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023include;C:PROGRA~1IBMSQLLIBINCLUDE;C:PROGRA~1IBMSQLLIBLIB
On the other hand, when I manually add missing includes in my Developer Command Prompt, like this:
set INCLUDE=%INCLUDE%;C:Program Files (x86)Windows Kits10Include10.0.16299.0winrt;C:Program Files (x86)Windows Kits10Include10.0.16299.0shared;C:Program Files (x86)Windows Kits10Include10.0.16299.0um;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCAuxiliaryVSUnitTestinclude;C:Program Files (x86)Windows Kits10Include10.0.16299.0ucrt;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCAuxiliaryVSinclude;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023atlmfcinclude;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023include;C:3coreservercommlib2aopensslwindowsvs2012include;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCPlatformSDKinclude;C:Program Files (x86)Windows Kits10Source10.0.16299.0ucrt;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCAuxiliaryVSsrc;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023crtsrc;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023atlmfcsrcatl;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023atlmfcsrcmfcm;C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023atlmfcsrcmfc;
I get different error:
legacyprov.c
cmd /C ""cl" /Zs /showIncludes /Zi /Fddso.pdb /Gs0 /GF /Gy -MTd -Zi -Ob0 -Od -FS -MTd -Zi -Ob0 -Od -FS -I"include" -I"providersimplementationsinclude" -I"providerscommoninclude" -D"OPENSSL_BUILDING_OPENSSL" -D"ZLIB" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/Users/username/.conan2/p/b/zlib69dc6f0d4df93/p/include" "providerslegacyprov.c" > providerslegacy-dso-legacyprov.d 2>&1"
"C:/Users/username/.conan2/p/straw898fb56546adc/p/bin/perl.exe" "utilmkrc.pl" legacy > providerslegacy.rc
"rc" /foproviderslegacy-dso-legacy.res "providerslegacy.rc"
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation. All rights reserved.
"C:/Users/username/.conan2/p/straw898fb56546adc/p/bin/perl.exe" "utilmkdef.pl" --type dso --ordinals utilproviders.num --name legacy --OS windows > providerslegacy.def
IF EXIST providerslegacy.dll.manifest DEL /F /Q providerslegacy.dll.manifest
cmd /C ""link" -debug /dll -debug -debug @C:UsersusernameAppDataLocalTemp2nm17C5.tmp || (DEL /Q legacy.* providerslegacy.* & EXIT 1)"
Microsoft (R) Incremental Linker Version 14.16.27051.0
Copyright (C) Microsoft Corporation. All rights reserved.
providerslegacy-dso-legacyprov.obj
/out:providerslegacy.dll
providersliblegacy.lib
providerslibcommon.lib
libcrypto.lib
C:/Users/username/.conan2/p/b/zlib69dc6f0d4df93/p/lib/zlib.lib ws2_32.lib gdi32.lib advapi32.lib crypt32.lib user32.lib
/def:providerslegacy.def providerslegacy-dso-legacy.res
LINK : fatal error LNK1104: cannot open file 'ws2_32.lib'
Could Not Find C:Usersusername.conan2pbopensdbeefee112c1fbsrclegacy.*
NMAKE : fatal error U1077: 'cmd' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2017ProfessionalVCToolsMSVC14.16.27023binHostX64x64nmake.exe"' : return code '0x2'
Stop.
I have Microsoft SDK (10.0.16299.0) installed for VS 2017 but its include and libs paths are not set by default.
I don’t understand how do I fix this, please help.