berthubert / hello-dl

https://berthub.eu/tmp/hello-dl
MIT License
71 stars 9 forks source link

build does not find eigen3 when not in compiler default search path #3

Open gdt opened 1 year ago

gdt commented 1 year ago

Given your call for portability testing, I tried to build this on NetBSD. After cmake failing because of eigen3 not being present (fair enough - I didn't read the build instructions :-) I installed version 3.3.9 via pkgsrc which put it in /usr/pkg. Then, cmake found it (likely via pkg-config, which has /usr/pkg/lib/pkgconfig in the default path), but apparently did not add the --cflags to the build, resulting in

[  2%] Building CXX object CMakeFiles/common.dir/mnistreader.cc.o
In file included from /home/gdt/SOFTWARE/AI/hello-dl/mnistreader.hh:8:0,
                 from /home/gdt/SOFTWARE/AI/hello-dl/mnistreader.cc:1:
/home/gdt/SOFTWARE/AI/hello-dl/tensor2.hh:10:10: fatal error: Eigen/Dense: No such file or directory
 #include <Eigen/Dense>
          ^~~~~~~~~~~~~
compilation terminated.
*** Error code 1

pkg-config seems ok:

$ pkg-config --cflags eigen3
-I/usr/pkg/include/eigen3

Perhaps this is an issue in eigen3's cmake support.

berthubert commented 1 year ago

Hi Greg! Currently busy with writing, so can't immediately solve this. If you read CMakeList.txt you'll see that some binaries explicitly mention Eigen:: something. Could you try adding that Eigen::Eigen term to the thing that doesn't compile? Will likely help. If you confirm this works I'll work it in.

gdt commented 1 year ago

Adding that didn't help. But forcing

CXX_INCLUDES = -I/usr/pkg/include/eigen3

make things a lot better. The build needs to pull this out of pkg-config automatically, I think.

ChariseWalraven commented 1 year ago

Hi guys, I also have this issue on macos, but I installed eigen via homebrew. This is the error I'm getting:

❯ make -j4
[  4%] Building CXX object CMakeFiles/common.dir/textsupport.cc.o
[  4%] Building CXX object CMakeFiles/common.dir/mnistreader.cc.o
clang: clang: warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
warning: argument unused during compilation: '-msse2' [-Wunused-command-line-argument]
clang: clang: warning: warning: argument unused during compilation: '-mavx' [-Wunused-command-line-argument]
argument unused during compilation: '-mavx' [-Wunused-command-line-argument]clang:
warning: clang: argument unused during compilation: '-mavx2' [-Wunused-command-line-argument]warning:
clang: argument unused during compilation: '-mavx2' [-Wunused-command-line-argument]warning:
argument unused during compilation: '-mfma' [-Wunused-command-line-argument]clang:
warning: argument unused during compilation: '-mfma' [-Wunused-command-line-argument]
In file included from /Users/charise/code/hello-deep-learning/hello-dl/mnistreader.cc:1:
In file included from /Users/charise/code/hello-deep-learning/hello-dl/mnistreader.hh:8:
/Users/charise/code/hello-deep-learning/hello-dl/tensor2.hh:10:10: fatal error: 'Eigen/Dense' file not found
#include <Eigen/Dense>
         ^~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/common.dir/mnistreader.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/common.dir/all] Error 2
make: *** [all] Error 2

I'm honestly not sure what I'm supposed to change in the import file and am also not sure how to do the equivalent of this:

Adding that didn't help. But forcing

CXX_INCLUDES = -I/usr/pkg/include/eigen3

make things a lot better. The build needs to pull this out of pkg-config automatically, I think.

@gdt could you maybe explain in a little more detail what you did to fix this?