[LLVMdev] include's are not being located

Dan Liew dan at su-root.co.uk
Wed Jun 11 14:58:25 PDT 2014


Hi Joseph,

It's not entirely clear from your e-mail which part you are struggling
with. You say you're having problems building the Kaleidoscope
tutorial but your steps look like you're struggling building
LLVM/Clang.

On 11 June 2014 20:44, Joseph Morgan <its.jojo.77 at gmail.com> wrote:
> I’m new to llvm so I’m hoping someone can shed some light on this. I am
> trying to use the Kaleidoscope tutorial and cannot get past the 3rd part.
> All the llvm includes are not in their expected places. Eg…
> “llvm/IR/Verifier.h” is actually in “llvm/include/llvm/IR”. I am running mac
> osx 10.9.

Are you trying to build this [1]? I.e. When you do

```
$ clang++ -g -O3 toy.cpp `llvm-config --cppflags --ldflags --libs core` -o toy
```

If so you should make sure that the llvm-config command being executed
here is the one you built (assuming that's what you want) rather than
you system's one. Take a look at what llvm-config actually outputs.
E.g. on my system I get

```
$ llvm-config --cppflags --ldflags --libs core
-I/home/dan/dev/llvm/src/include -I/home/dan/dev/llvm/bin/include
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS
-L/home/dan/dev/llvm/bin/lib
-lLLVMCore -lLLVMSupport
```

What you've described below sounds like you're struggling to build
LLVM/Clang which is not what you said you were trying to do earlier
(build the Kaleidoscope tutorial). Please clarify.

Assuming this is an attempt to build LLVM/Clang I can see a few mistakes here.

> Here’s what I’ve tried:
> 1. checkout the svn of llvm, clang & compiler rt
> 2. created a “build” directory & cd build
> 3. …/llvm/configure --prefix=/HomeDir/build --enable-targets=x86,x86_64

I assume you mean ``..`` not ``...``

--prefix= is used to instruct the build system where to install
LLVM/Clang. I might be misreading this because you have not said where
you created the ``build`` directory but it looks like you've set
--prefix to where you are building LLVM. I highly recommend you do not
do that (it will make a mess if you ever run ``make install``). In
your case if you are trying to build the Kaleidoscope tutorial you
shouldn't even need to install LLVM/Clang.

> 4. make -I/HomeDir/llvm/include <—- I thought this would fix my problem but

I can see what you're trying to do but that's not how you pass flags
to the C++ compiler for LLVM's build system (or for any other make
file based build system for that matter).

It would be

$ make CXXFLAGS=" -I/HomeDir/llvm/include"

Even this not quite right because it will overwrite CXXFLAGS and does
not append so it is likely this will break the build in some way. So I
don't recommend doing this.


[1] http://llvm.org/docs/tutorial/LangImpl3.html#full-code-listing

-- 
Dan Liew
PhD Student - Imperial College London




More information about the llvm-dev mailing list