# CMAKE\_RANLIB vs CMAKE\_CXX\_COMPILER\_RANLIB

**URL:** https://discourse.cmake.org/t/cmake-ranlib-vs-cmake-cxx-compiler-ranlib/1017
**Category:** Code
**Tags:** comp:clang
**Created:** [April 14, 2020, 12:37pm UTC](https://discourse.cmake.org/t/cmake-ranlib-vs-cmake-cxx-compiler-ranlib/1017 "2020-04-14T12:37:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rnyberg](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rnyberg/32/210_2.png) [@rnyberg](https://discourse.cmake.org/u/rnyberg)
#### Post date: [April 14, 2020, 12:37pm UTC](https://discourse.cmake.org/t/cmake-ranlib-vs-cmake-cxx-compiler-ranlib/1017/1 "2020-04-14T12:37:33Z")

</div>

Hi! I’m not certain how these variables are to be used. In my case building with clang 7 and -flto I need to run the cxx compiler specific ranlib but CMAKE\_RANLIB is the one actually run.

Am I supposed to to something like the snippet below, or is there some other way CMAKE\_CXX\_COMPILER\_RANLIB is supposed to be used?

```
project( Blarg C CXX )
if ( CMAKE_CXX_COMPILER_RANLIB )
  set( CMAKE_RANLIB ${CMAKE_CXX_COMPILER_RANLIB} )
endif()
```

---

<div class="post-metadata">

### Author: ![rnyberg](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rnyberg/32/210_2.png) [@rnyberg](https://discourse.cmake.org/u/rnyberg)
#### Post date: [April 14, 2020, 2:03pm UTC](https://discourse.cmake.org/t/cmake-ranlib-vs-cmake-cxx-compiler-ranlib/1017/2 "2020-04-14T14:03:02Z")

</div>

Or maybe the question is this: is there a way to tell cmake to use the compiler binutils instead of the system binutils?

In my case, clang+±7 on ubunutu 18.04 they are in /usr/lib/llvm-7/bin and the CMAKE\_CXX\_COMPILER\_RANLIB is set to /usr/lib/llvm-7/bin/llvm-ranlib. I just don’t know how to inform cmake to actually use that and the other binutils there.
