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

在VS2022通过WSL运行Linux项目时无法打开共享对象文件

Windows 10下VS2022通过WSL Ubuntu 20.04运行C++项目动态库加载失败的解决

问题场景

  • 环境:Windows 10 + Visual Studio 2022 + WSL Ubuntu 20.04
  • 已完成配置:将动态库路径添加到项目Additional Library Search Path,并把所有.so文件加入Library Dependecies,项目构建成功
  • 运行错误:
    error while loading shared libraries: xxx.so: cannot open shared object file: No such file or directory
    
  • 库文件实际路径:/home/myuser/my_ws/install/lib
  • 无效尝试:
    • 将库路径添加到Configuration Properties -> Debugging -> Additional Symbol Search Paths,无效果
    • 手动复制.so文件到/usr/lib/x86_64-linux-gnu可临时解决,但属于非规范操作

解决方法

在项目的Configuration Properties -> Debugging -> Pre-Launch Command中添加以下命令:

export LD_LIBRARY_PATH=/home/myuser/my_ws/install/lib

添加完成后重新运行项目,动态库加载问题即可解决。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 19:32:46