# Can't link shared library in cmake due to image not found

**URL:** https://discourse.cmake.org/t/cant-link-shared-library-in-cmake-due-to-image-not-found/4648
**Category:** Usage
**Tags:** os:macos
**Created:** [December 13, 2021, 6:01am UTC](https://discourse.cmake.org/t/cant-link-shared-library-in-cmake-due-to-image-not-found/4648 "2021-12-13T06:01:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![GatCode](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gatcode/32/2028_2.png) [@GatCode](https://discourse.cmake.org/u/GatCode)
#### Post date: [December 13, 2021, 6:01am UTC](https://discourse.cmake.org/t/cant-link-shared-library-in-cmake-due-to-image-not-found/4648/1 "2021-12-13T06:01:53Z")

</div>

Hello,  
I’ve already posted my question on [stackoverflow](https://stackoverflow.com/questions/70300987/cant-link-shared-library-in-cmake-due-to-image-not-found) but it seems that it’s not getting a lot of attention. Nevertheless, I am trying to include a bazel built shared library in my cmake project. I was able to find the library, as you can see in the terminal output, but as soon as I want to link it, I get the image not found error. I know that it should be related to a rpath and OSX in general, but I can’t figure out my problem. I hope someone can help me out! Thanks!

 ![sc](https://discourse.cmake.org/uploads/default/original/2X/0/0dcf044851f1ecac63ce9538750ca25cd1d96fa9.png)

---

<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: [December 13, 2021, 1:23pm UTC](https://discourse.cmake.org/t/cant-link-shared-library-in-cmake-due-to-image-not-found/4648/2 "2021-12-13T13:23:50Z")

</div>

The library ID of `liblyra_encoder.so` needs updated to use `@rpath/` or some other `@loader_path/`-like prefix. As it is, the library is expected to be in that path relative to…something (the loader docs aren’t very clear on this front IIRC, but it may be `DYLD_LIBRARY_PATH` entries or `getcwd()`). I don’t know how to convince Bazel to make such IDs (and add rpath entries if necessary), but there’s probably some way (it may require an install of some kind).
