[LLVMdev] Linking to LLVM with CMake

Joshua Warner joshuawarner32 at gmail.com
Thu Dec 23 11:36:31 PST 2010


Hi,

I'm having problems linking my project (outside of the llvm source tree) to
the LLVM jit.  My CMake file contains:
------------
find_package(LLVM REQUIRED)

include_directories(${LLVM_INCLUDE_DIR})

link_directories(${LLVM_LINK_DIR})

add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)

add_executable(nvm main.cpp)

llvm_config(nvm engine)
------------
cmake succeeds in generating the makefile - so it is correctly finding the
installed LLVM (2.8, r122491), which compiled fine.

The build fails, complaining of:

CMakeFiles/nvm.dir/main.cpp.o: In function `global constructors keyed to
main':
main.cpp:(.text+0x41): undefined reference to `LLVMLinkInJIT'
CMakeFiles/nvm.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x55): undefined reference to `LLVMInitializeX86TargetInfo'
main.cpp:(.text+0x5a): undefined reference to `LLVMInitializeX86Target'
...

When I try "jit" in place of "engine" in llvm_config, it complains that
"jit" is not an llvm component.  Is there a straight-forward tutorial on how
to use CMake with LLVM?  (I noticed llvm.org/docs/CMake.html, which appears
to be fairly old)

I'm on Ubuntu 10.10, GCC version 4.4.5, LLVM 2.8 r122491 (from last night).


Thanks,

Joshua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101223/7680c5b9/attachment.html>


More information about the llvm-dev mailing list