1

I'm trying to use Eigen in my C++ program but this error appears (paths are simplified).

Starting build...
"C:\Program Files\(...)\g++.exe" -g D:\(...)\main.cpp -o D:\(...)\main.exe
D:\(...)\main.cpp:2:10: fatal error: Eigen/Dense: No such file or directory
 #include <Eigen/Dense>
      ^~~~~~~~~~~~~

I included Eigen directory in .vscode/c_cpp_properties.json.

The Eigen folder with Dense file - and others - inside is listed in my Explorer sidebar, under the project I want to use it in.

This is my c_cpp_properties.json:

{
"configurations": [
    {
        "name": "Win32",
        "includePath": [
            "${default}",
            "D:\\programming\\_lib\\cpp\\eigen-3.3.9\\"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "windowsSdkVersion": "10.0.18362.0",
        "compilerPath": "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe",
        "cStandard": "c17",
        "cppStandard": "c++17",
        "intelliSenseMode": "linux-gcc-x64"
    }
],
"version": 4
}

It seems that Eigen include is not used in the compiler command. Is that right? If so do I include it manually via "Compiler arguments" or "Compile commands" setting or do something else?

Alan
  • 1,322
  • 1
  • 21
  • 36

1 Answers1

3

Following @ThomasSablik suggestion I used -I argument to add the Eigen path in .vscode/tasks.json file inside my project folder. It worked. Contents of the file:

{
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "-I",
            "D:\\programming\\_lib\\cpp\\eigen-3.3.9\\",
        ],
        "options": {
            "cwd": "${workspaceFolder}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "Task generated by Debugger."
    }
],
"version": "2.0.0"
}
Alan
  • 1,322
  • 1
  • 21
  • 36