Cannot generate a safe runtime path


during generating I get multiple warnings “Cannot generate a safe runtime search path”, but I don’t quite understand it.

CMake Warning at build-analyze/_deps/cpr-src/cpr/CMakeLists.txt:3 (add_library):
  Cannot generate a safe runtime search path for target cpr because files in
  some directories may conflict with libraries in implicit directories:

    runtime library [] in /usr/lib may be hidden by files in:

  Some of these libraries may not be found correctly.

The library is using curl, which might lead to conflicts? I would appreciate some help!

You have something linking to /usr/lib/ (with soname, but other libraries it is linking to live in a directory (that build-analyze/lib one) which also has CMake is saying that it cannot construct an rpath that will guarantee that /usr/lib/ is picked up (that is, build-analyze/lib/ will actually be used at runtime).

So cpr is linking against /usr/lib/ and it’s also linking against library X in /some/path and /some/path happens to have also a
So cpr is confused here what it should take? (Or rather it will use the /some/path/ instead of the usr/lib/

Is that correct?

My next question: Does this mean I or the libraries I use have done something wrong? How can this happend and how to fix it?

For, it’s probably fine since the library has a stable ABI. However, I would recommend that your build be configured to agree on the same libraries to decrease the likelihood of odd linker-related issues at runtime.

The reason I (in general) got the problem in the first place is my cmake code:


To put all libs and binaries in one folder to make the whole handling easier. Is this bad practise?

Apart from this I also figured out the library that built zlib

That block of code you have seems quite normal to me. In fact, I usually force it because the projects I work on are not intended to be vendored, so the only way to change the build tree locations is to update the install tree locations too.