[llvm-dev] Correctly linking against libLLVM (single shared library build)

Jiri Slaby via llvm-dev llvm-dev at lists.llvm.org
Wed Nov 15 23:34:50 PST 2017

On 11/14/2017, 01:26 AM, Chris Bieneman wrote:
> Sorry for the delayed response. I've been out of town a lot lately.
> The documentation you referenced is unfortunately out of date (you might notice it still references autoconf). I'll see if I can find time to update it, but the guidance should be to use the `llvm_config` CMake function instead. The proper usage of that in the example there would be to replace the call to `llvm_map_components_to_libnames` with `llvm_config(simple-tool support core irreader)`.
> `llvm_config` should properly handle the LLVM shared library.

Actually it does not work at all. It behaves exactly the same as
map_components with this CMakeLists.txt:
cmake_minimum_required(VERSION 3.4.3)


message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

llvm_map_components_to_libnames(llvm_libs support core irreader)
message(STATUS "Components mapped to libnames: ${llvm_libs}")

add_executable(bubak a.c)

llvm_config(bubak support core irreader)
get_target_property(LL bubak LINK_LIBRARIES)
message(STATUS "Components mapped by llvm_config: ${LL}")

It results in:
-- Found LLVM 4.0.1
-- Using LLVMConfig.cmake in: /usr/lib64/cmake/llvm
-- Components mapped to libnames: LLVMSupport;LLVMCore;LLVMIRReader
-- Components mapped by llvm_config: LLVMSupport;LLVMCore;LLVMIRReader

And in turn we get linking errors:
 [ 50%] Linking C executable bubak
cannot find -lLLVMSupport
cannot find -lLLVMCore
cannot find -lLLVMIRReader

So this does not work either :/.

suse labs

More information about the llvm-dev mailing list