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

VS Code中C++编译正常但运行命令报Eigen头文件找不到

VS Code运行Eigen程序报错排查请求

我是VS Code新手,正在尝试用Eigen库编写简单C++程序。手动编译程序无报错,生成的EigenTEST01.exe也能正常运行,但使用VS Code的「运行代码」命令时,却出现「Eigen/Dense: No such file or directory」的编译终止错误。以下是相关配置文件及测试代码,恳请帮忙排查问题:

终端错误信息

PS C:\PATH\Eigen Testing> cd "c:\PATH\Eigen Testing\" ; if ($?) { g++ EigenTEST01.cpp -o EigenTEST01 } ; if ($?) { .\EigenTEST01 }
EigenTEST01.cpp:2:23: fatal error: Eigen/Dense: No such file or directory
 #include <Eigen/Dense>
                       ^
compilation terminated.

tasks.json配置

{    
    "version": "2.0.0",    
    "tasks": [        
        {            
            "type": "cppbuild",            
            "label": "C/C++: g++.exe build active file",            
            "command": "C:\\MinGW\\bin\\g++.exe",            
            "args": [                
                "-fdiagnostics-color=always",                
                "-g",                
                "${file}",                
                "-o",                
                "${fileDirname}\\${fileBasenameNoExtension}.exe",                
                "-IC:/cppTools/eigen-3.4.0/"            
            ],            
            "options": {                
                "cwd": "${fileDirname}"            
            },            
            "problemMatcher": [                
                "$gcc"            
            ],            
            "group": "build",            
            "detail": "compiler: C:\\MinGW\\bin\\g++.exe"        
        }    
    ]
}

c_cpp_properties.json配置

{    
    "configurations": [        
        {            
            "name": "Win32",            
            "includePath": [                
                "${default}",                
                "C:/cppTools/eigen-3.4.0/"            
            ],            
            "defines": [                
                "_DEBUG",                
                "UNICODE",                
                "_UNICODE"            
            ],            
            "cStandard": "c11",            
            "cppStandard": "gnu++14",            
            "intelliSenseMode": "windows-gcc-x86",            
            "compilerPath": "C:/MinGW/bin/g++.exe"        
        }    
    ],    
    "version": 4
}

测试代码

#include <iostream>
#include <Eigen/Dense>

int main(){
    std::cout << "And we go again..." << std::endl;    
    return 0;
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 06:55:10