0

I know this question been answered like a million time, and I have followed with each suggestion to no avail. I am trying to set up Eigen in my c++ code using VS code while running commands on Ubuntu 20.04 on windows. I was following with this specific post: Post

This is my c_cpp_properties.cpp file:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/cygwin64/usr/include/**",
                "C:/Program Files/LLVM/bin/**",
                "C:/Users/J/Documents/eigen-3.4.0/eigen-3.4.0",
                "C:/Users/J/Documents/eigen-3.4.0/eigen-3.4.0/Eigen/**",
                "C:/Users/J/Documents/eigen-3.4.0/eigen-3.4.0/Eigen/src/**",
                "C:/Users/J/Documents/eigen-3.4.0/eigen-3.4.0/test",
                "C:/Users/J/Documents/eigen-3.4.0/eigen-3.4.0/test/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.18362.0",
            "compilerPath":  "\"C:/Program Files/LLVM/bin/clang++.exe\"",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

And following the suggestion from other posts, this is my tasks.json:

{
    "version": "2.0.0",
    "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",
                "C:\\Users\\J\\Documents\\eigen-3.4.0\\eigen-3.4.0\\Eigen\\",
                
            ],
            "options": {
                "cwd": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: \"C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe\""
        }
    ]
}

Still getting the error:

Test.cpp:21:9: fatal error: Eigen/Dense: No such file or directory
   21 | #include<Eigen/Dense>
      |         ^~~~~~~~~~~~~
compilation terminated.

I installed Eigen from: LINK

Any help is appreciated, thanks.

Jamie
  • 365
  • 2
  • 5
  • 13
  • "C:\\Users\\J\\Documents\\eigen-3.4.0\\eigen-3.4.0\\Eigen\\": if you want it to find Eigen/Dense, you should not include Eigen in the include path. – Marc Glisse Jun 12 '22 at 20:19
  • I tried ""C:\\Users\\J\\Documents\\eigen-3.4.0\\eigen-3.4.0\\"," instead and it still gives the same error :/ – Jamie Jun 12 '22 at 20:28

2 Answers2

0

Although it seems unlikely, can you try adding a space between #include and <Eigen/Dense> and see if that works? The code probably doesn't compile when there's no space there, although in your case the compiler does recognise that you are trying to include something. Worth a shot.

Jib Ran
  • 11
  • 2
0

what helped me is compiling my program with the following command line: g++ -I /path/to/eigen/ my_program.cpp -o my_program

It's not efficient but there is a way around it I believe.

Jamie
  • 365
  • 2
  • 5
  • 13
  • I don't know if eigen has binary dependencies or if its header only but you may want to show them how to link any dependencies as well if necessary – The Floating Brain Jun 13 '22 at 20:27