prosyslab-classroom / is893-2020-fall

6 stars 7 forks source link

Error while building #47

Closed luxroot closed 3 years ago

luxroot commented 3 years ago

After running

cd llvm
mkdir build && cd build && cmake .. && make

When I run make at the base of repository, I encountered such error.

In file included from dummy_irreader_ocaml.c:15:
../llvm/include/llvm-c/IRReader.h:17:10: fatal error: llvm-c/Types.h: No such file or directory
   17 | #include "llvm-c/Types.h"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.

It seems like there's no Types.h at llvm/include/llvm-c, am I missing something?

KihongHeo commented 3 years ago

Can you change the line to #include "llvm-c-9/llvm-c/Types.h"?

luxroot commented 3 years ago

It solved that error but gave me another one..

In file included from ../llvm/include/llvm-c/IRReader.h:17,
                 from dummy_irreader_ocaml.c:15:
/usr/include/llvm-c-9/llvm-c/Types.h:17:10: fatal error: llvm-c/DataTypes.h: No such file or directory
   17 | #include "llvm-c/DataTypes.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Done: 27/30 (jobs: 1)make: *** [Makefile:8: all] Error 1

It seems like I should update some include paths. FYI, my machine has llvm9 and llvm10 too.

> ls /usr/include | grep llvm
llvm-10
llvm-9
llvm-c-10
llvm-c-9
KihongHeo commented 3 years ago

OK. I see. Ideally, the directory structure should be like this (according to my system):

$ ls -al /usr/include | grep "llvm"
llvm -> llvm-9/llvm
llvm-9
llvm-c -> llvm-c-9/llvm-c
llvm-c-9

-> means symbolic link.

luxroot commented 3 years ago

It also solved by editing src/dunefile

diff --git a/src/dune b/src/dune
index b2ea9c3..ec3e7ea 100644
--- a/src/dune
+++ b/src/dune
@@ -4,7 +4,7 @@
  (libraries llvm)
  (foreign_stubs
   (language c)
-  (include_dirs ../llvm/include/llvm-c)
+  (include_dirs ../llvm/include/llvm-c /usr/include/llvm-c-9)
   (names dummy_irreader_ocaml))
  (foreign_archives ../llvm/build/lib/DummyLLVMIRReader
    ../llvm/build/lib/DummyLLVMAsmParser))

Thanks for kind advice though! 👍🏻 :)