# Linking LLVM fails with target\_link\_libraries()

**URL:** https://discourse.cmake.org/t/linking-llvm-fails-with-target-link-libraries/15852
**Category:** Code
**Tags:** os:linux
**Created:** [September 24, 2026, 8:23am UTC](https://discourse.cmake.org/t/linking-llvm-fails-with-target-link-libraries/15852 "2026-09-24T08:23:46Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![TheShiningBoots](https://discourse.cmake.org/user_avatar/discourse.cmake.org/theshiningboots/32/6256_2.png) [@TheShiningBoots](https://discourse.cmake.org/u/TheShiningBoots)
#### Post date: [September 24, 2026, 8:23am UTC](https://discourse.cmake.org/t/linking-llvm-fails-with-target-link-libraries/15852/1 "2026-09-24T08:23:46Z")

</div>

```cmake
find_package(LLVM REQUIRED CONFIG)

llvm_map_components_to_libnames(llvm_libs
  core
  support
  target
  irreader
)

target_include_directories(catguy PRIVATE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(catguy PRIVATE ${LLVM_DEFINITIONS})
target_link_libraries(catguy PRIVATE ${llvm_libs})

```

The above fails with:

```bash
[50%] Linking CXX executable catguy
/usr/bin/ld: cannot find -lLLVMCore: No such file or directory
/usr/bin/ld: cannot find -lLLVMTarget: No such file or directory
/usr/bin/ld: cannot find -lLLVMIRReader: No such file or directory
collect2: error: ld returned 1 exit status

```

But if I change the `target_link_libraries` to just `link_libraries` it builds successfully. Can somebody please explain why this happens? and how to fix it?  
The above code is mostly from the llvm docs: [Building LLVM with CMake - LLVM](https://llvm.org/docs/CMake.html)
