You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Windows下用Conan构建OpenSSL3时C1083与LNK1104错误修复

解决Conan构建OpenSSL3时的头文件与链接库缺失问题

问题根源

VS2017开发者命令提示符未正确加载对应Windows SDK(10.0.16299.0)的INCLUDE和LIB环境变量,导致编译时找不到stdlib.h,链接时找不到ws2_32.lib;手动临时添加路径无法被Conan构建流程完整继承。

解决方案

1. 确保VS开发环境正确初始化

  • 直接启动x64 Native Tools Command Prompt for VS 2017,该工具会自动配置VS和对应SDK的环境变量。
  • 如果启动后仍无效,手动执行vcvarsall.bat强制指定SDK版本:
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 10.0.16299.0
    
    (替换为你的VS安装路径,比如Enterprise版需将路径中的Community改为Enterprise)
  • 执行后验证环境变量:
    echo %INCLUDE%  # 应包含Windows SDK的ucrt、um等include路径
    echo %LIB%       # 应包含Windows SDK的um\x64等lib路径
    

2. 配置Conan Profile强制指定SDK

编辑Conan的profile文件(路径通常为%USERPROFILE%\.conan2\profiles\default_windows_x64_debug和default_windows_x64_release),添加SDK相关配置:

[settings]
os=Windows
os.version=10.0.16299.0
compiler=msvc
compiler.version=15  # VS2017对应版本号为15
compiler.cppstd=17
compiler.runtime=dynamic
build_type=Debug  # Release profile中改为Release
arch=x86_64

[conf]
tools.microsoft.msbuild:installation_path="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
tools.microsoft.msbuild:sdk_version=10.0.16299.0

3. 强制OpenSSL构建使用指定SDK

在项目的conanfile.txt或conanfile.py中添加SDK配置:

[requires]
openssl/3.x.x  # 替换为你依赖的OpenSSL版本

[conf]
tools.microsoft.msbuild:sdk_version=10.0.16299.0

4. 清理Conan缓存后重新构建

清理之前错误构建的缓存文件,避免干扰:

conan cache clean "*"
conan install . --build=missing --profile:build=default_windows_x64_release --profile=default_windows_x64_debug

内容的提问来源于stack exchange,提问作者a_girl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 08:57:39