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

Windows平台Flutter运行报错LNK1104:无法打开指定可执行文件

解决Windows平台Flutter项目LNK1104链接错误

错误信息

LINK : fatal error LNK1104: cannot open file 'C:\myproject\build\windows\runner\Debug\myproject.exe' [C:\myproject\build\windows\runner\myproject.vcxproj]

已尝试的无效方案

  • 执行flutter clean和flutter pub get
  • 重启Windows系统及VS Code
  • 运行taskkill /f /im myproject.exe,但任务管理器中未找到该进程

环境信息

  • 仅安装微软内置杀毒软件,无其他第三方杀毒工具
  • flutter doctor检测无异常:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.10.6, on Microsoft Windows [Version 10.0.22621.2861], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
[√] Android Studio (version 2022.1)
[√] Connected device (3 available)
[√] Network resources

• No issues found!
  • 项目pubspec.yaml配置:
version: 1.0.0+1

environment:
  sdk: '>=3.0.6 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  http: ^1.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0

flutter:

  uses-material-design: true

可行解决方案尝试

1. 检查文件权限与路径

  • 右键C:\myproject\build\windows\runner\Debug目录,选择「属性」-「安全」,确保当前用户拥有完全控制权限
  • 若项目路径包含中文、空格或特殊符号,将整个项目移至纯英文无空格的路径下(如C:\Projects\myproject)

2. 排查微软Defender拦截

  • 打开Windows安全中心,进入「病毒和威胁防护」-「保护历史记录」,查看是否有myproject.exe被误拦截的记录,若有则添加至允许列表
  • 临时关闭实时保护(仅用于测试,测试后立即开启),重新执行flutter run -d windows

3. 清理Visual Studio缓存

  • 关闭VS Code及所有Visual Studio相关进程
  • 删除以下路径的缓存文件:
    • C:\Users\<你的用户名>\AppData\Local\Microsoft\VisualStudio\17.0_*\ComponentModelCache
    • C:\Users\<你的用户名>\AppData\Local\Temp\下的Visual Studio临时文件
  • 重新打开项目编译

4. 手动重建Build目录

  • 直接删除C:\myproject\build整个目录
  • 依次执行flutter pub get和flutter run -d windows

5. 确认Visual Studio组件完整性

  • 打开Visual Studio Installer,检查「桌面开发使用C++」workload是否已安装,且包含MSVC工具集、对应版本的Windows SDK等核心组件
  • 若组件缺失,补充安装后重启系统再编译

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 04:01:15