[llvm-dev] Building a program with LLVM on Unix

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 23 09:55:26 PDT 2016


On 23 Mar 2016, at 16:48, Russell Wallace via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Building LLVM itself involves Cmake, but what's the best way to build a C++ program that needs to link with the LLVM libraries?
> 
> If you're trying to optimise for making life as easy as possible for users and people creating binary packages, in the normal course of events, autotools is recommended. But the tutorial mentions running llvm-config to get things like library paths - does autotools know how to do this?
> 
> (I mostly use Windows, not as familiar with Unix, so please let me know if the question I'm asking is not quite the same as the question I should be asking.)

I think that you’re answering your own question, almost.  There are basically two approaches:

If you’re using CMake, then you can use the CMake LLVM modules to find the things that you need to link to.  I’ve found this to be fairly fragile.

If you’re using any build system, then you can use llvm-config to find the LLVM version, CXXFLAGS, and LDFLAGS that are needed for your particular use.  This is quite easy to do from any build system (from simple Makefiles to complex build system generators such as auto* and CMake).

David



More information about the llvm-dev mailing list