including llvm headers in the sample project

When building an llvm project, I followed the steps outlined here: http://llvm.org/docs/Projects.html and copied the sample project from /projects/sample.

This compiles just fine. However, when I try to include llvm headers, compilation fails with the error:

In file included from /home/eks/projects/cfg/tools/cfg/main.c:9:
In file included from /home/eks/projects/llvm/llvm-svn/include/llvm/Module.h:18:
In file included from /home/eks/projects/llvm/llvm-svn/include/llvm/Function.h:21:
In file included from /home/eks/projects/llvm/llvm-svn/include/llvm/GlobalValue.h:21:
In file included from /home/eks/projects/llvm/llvm-svn/include/llvm/Constant.h:17:
In file included from /home/eks/projects/llvm/llvm-svn/include/llvm/User.h:22:
In file included from /home/eks/projects/llvm/llvm-svn/include/llvm/Support/ErrorHandling.h:19:
In file included from /home/eks/projects/llvm/llvm-svn/include/llvm/ADT/StringRef.h:13:
/home/eks/projects/llvm/llvm-svn/include/llvm/Support/type_traits.h:21:10: fatal error: ‘cstddef’ file not found
#include

It seems that when trying to include llvm headers, compilation always fails, citing various missing c++ system headers.

How does one include llvm headers in the sample project without running in to this problem?

also, is autoconf really the best way to be building llvm projects? It seems like most projects use cmake instead, but I wasn’t able to find llvm documentation for setting up a sample project with cmake.

thanks!

also, is autoconf really the best way to be building llvm projects? It seems
like most projects use cmake instead, but I wasn't able to find llvm
documentation for setting up a sample project with cmake.

I would say that CMake is a better choice (but I am biased as I have a
strong dislike of autoconf)

Being a CMake user that using CMake is the better choice.

Doing this is documented at [1].

Please note this documents the "old" way of using the LLVM libraries
within CMake and that there is a different way of linking against the
LLVM libraries that is nicer in LLVM3.5. But the old way should still
work at least for now. I actually just posted [3] to llvmdev about
this issue.

Here [2] is a *very* hacky example of the new way of using LLVM
libraries with CMake for LLVM 3.5. But this should give an idea of how
you can link against the LLVM libraries in your own project that uses
CMake as its build system.

[1] http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
[2] https://github.com/delcypher/llvm-hack
[3] http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-July/074829.html

Thanks,
Dan Liew
PhD Student - Imperial College London