# file GET\_RUNTIME\_DEPENDENCIES - cannot access variables

**URL:** https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278
**Category:** Code
**Created:** [November 28, 2019, 8:42am UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278 "2019-11-28T08:42:09Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![tgq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/87869e/32.png) [@tgq](https://discourse.cmake.org/u/tgq)
#### Post date: [November 28, 2019, 8:42am UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/1 "2019-11-28T08:42:09Z")

</div>

Hello. I am checking out this new feature but it seems like I cannot print out the dependencies. The part of my cmake script is

```auto
install(CODE
        "file(GET_RUNTIME_DEPENDENCIES
                RESOLVED_DEPENDENCIES_VAR resolved_deps
                UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
                EXECUTABLES boost_timer_example just_a_thread
                )
        MESSAGE(\"Contents of variables: ${resolved_deps} ${unresolved_deps}\")"
)

```

Calling `cmake .. && make install` results in such log:

```auto
[100%] Built target boost_timer_example
Install the project...
-- Install configuration: ""
Contents of variables:

```

Variables are not printed out. I have noticed that just after calling `cmake ..` alone (without `make`), `cmake_install.cmake` is created with contents like that:

```auto
if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)
  file(GET_RUNTIME_DEPENDENCIES
                RESOLVED_DEPENDENCIES_VAR resolved_deps
                UNRESOLVED_DEPENDENCIES_VAR unresolved_deps
                EXECUTABLES boost_timer_example just_a_thread
                )
        MESSAGE("Contents of variables: ")
endif()

```

Which clearly indicates the variables are substituted for nothing at configuration time.  
What am I doing wrong?

---

<div class="post-metadata">

### Author: ![Florian\_Chevassu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/florian_chevassu/32/99_2.png) [@Florian\_Chevassu](https://discourse.cmake.org/u/Florian_Chevassu)
#### Post date: [November 28, 2019, 8:47am UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/2 "2019-11-28T08:47:42Z")

</div>

Hi @tgq,

You need to escape the `$` signs in the `install` command. Right now, the `${resolved_deps}` and `${unresolved_deps}` will be expanded at configure time, and hence be empty.

Florian

---

<div class="post-metadata">

### Author: ![tgq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/87869e/32.png) [@tgq](https://discourse.cmake.org/u/tgq)
#### Post date: [November 28, 2019, 8:52am UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/3 "2019-11-28T08:52:59Z")

</div>

`MESSAGE(\"Contents of variables: \${resolved_deps} \${unresolved_deps}\")`  
Works, thanks you 😃

---

<div class="post-metadata">

### Author: ![tgq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/87869e/32.png) [@tgq](https://discourse.cmake.org/u/tgq)
#### Post date: [November 28, 2019, 9:10am UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/4 "2019-11-28T09:10:07Z")

</div>

The paths seem to be wrong tho. This is the output of `RESOLVED_DEPENDENCIES_VAR`:

```auto
Resolved deps just_a_thread: /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1;/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2;/lib/aarch64-linux-gnu/libc.so.6;/lib/aarch64-linux-gnu/libgcc_s.so.1;/lib/aarch64-linux-gnu/libm.so.6;/lib/aarch64-linux-gnu/libpthread.so.0;/lib/x86_64-linux-gnu/libstdc++.so.6

```

Calling `ldd` to find out dependencies:

```auto
tgq@qq:~/qqprojectboost/build$ ldd just_a_thread
        linux-vdso.so.1 (0x00007ffc371f6000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc282b5e000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc282985000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc28296b000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc2827ab000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc282b8c000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc282666000)

```

I have a crosscompiler installed (aarch64-linux-gnu) somewhere on the system but i never use it. Why did CMake fill the resolved deps with the crosscompiler’s libs? Isn’t that some bug? My arch is x86\_64.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 28, 2019, 12:56pm UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/5 "2019-11-28T12:56:17Z")

</div>

@kyle.edwards Seems we’re getting system paths from the wrong place somehow?

---

<div class="post-metadata">

### Author: ![tgq](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/87869e/32.png) [@tgq](https://discourse.cmake.org/u/tgq)
#### Post date: [November 28, 2019, 8:13pm UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/6 "2019-11-28T20:13:28Z")

</div>

I found 15 minutes to reproduce the issue and ran it on ubuntu and debian machines. On ubuntu every crosscompiler pointed me to `aarch64` directory, on debian to `x86_64`. In every case the paths should point to the one associated with the compiler.  
Here’s the example I’m talking about:

> **[kpyrkosz/cmake\_crosscompile](https://github.com/kpyrkosz/cmake_crosscompile)**
>
> Contribute to kpyrkosz/cmake\_crosscompile development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [December 2, 2019, 3:04pm UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/7 "2019-12-02T15:04:04Z")

</div>

I just tried it on Ubuntu 16.04 and was not able to reproduce - it got the correct paths. I’m going to try on 18.04 next.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [December 2, 2019, 3:15pm UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-cannot-access-variables/278/8 "2019-12-02T15:15:48Z")

</div>

Could not reproduce with 18.04 or the `debian:latest` Docker image. Please open an [issue](https://gitlab.kitware.com/cmake/cmake/issues) with a Dockerfile (or some other script) with the exact environment needed to reproduce this.
