Skip to content

[develop2] Compile error building OpenSSL 1.1.1w on Windows with Visual Studio #688

Open
@li-dl

Description

@li-dl

conan_provider.cmake: https://github.com/conan-io/cmake-conan/blob/c22bbf0af0b73d5f0def24a9cdf4ce503ae79e5d/conan_provider.cmake

CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(fooproject LANGUAGES C;CXX)
add_executable(foo main.cpp)
find_package(OpenSSL REQUIRED)
target_link_libraries(foo PUBLIC openssl::openssl)

conanfile.py:

from conan import ConanFile

class LiquidReaderConan(ConanFile):
    settings = "os", "compiler", "arch", "build_type"
    generators = "CMakeDeps", "CMakeToolchain"

    def requirements(self):
        self.requires("openssl/1.1.1w#a8f0792d7c5121b954578a7149d23e03")

main.cpp:

int main(int argc, char* argv[])
{
    return 0;
}
$ mkdir build
$ cd build
$ cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake ..
[...]
C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe  /Zi /Fdossl_static.pdb /MDd /Zl /Gs0 /GF /Gy -MDd -Zi -Ob0 -Od -FS -MDd -Zi -Ob0 -Od -FS /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_MONT5" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"KECCAK1600_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"X25519_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"\\res\"" -D"ENGINESDIR=\"\\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"DEBUG" -D"_DEBUG"  -c /Foapps\app_rand.obj "apps\app_rand.c"
[...]
LINK : fatal error LNK1181: cannot open input file 'apps\app_rand.obj'

Full log: 20250325-0954-Log.txt

I found a similar report at conan-io/conan-center-index#4740 which found that the problem was the path to cl.exe.

The difference between that ticket and my problem is that mine seems to be specific to conan_provider.cmake, because OpenSSL is successfully built if I use Conan directly, like:

$ conan install --requires openssl/1.1.1w#a8f0792d7c5121b954578a7149d23e03 --build="openssl/*"

Conan v2.12.1
CMake v3.27.7
Visual Studio 2022 v17.13.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions