How do you link a native shared library with a relative path?

I need use the C++ plugin and link with a library that will be at a different location at runtime than it is at build time. How can I do this in the most portable way?

I have looked at the pre-built library example code, but it assumes I’m linking with a library that will be at a known path that is the same from build time to run time and across different installations.

On Windows I suppose it won’t matter as the fullpath to the shared library isn’t embedded, on Linux however this will be an issue.

1 Like

Okay, it’s been two months with no reply. Could someone from the Gradle team at least confirm that “we can’t do this yet” or not?

Thanks!

@swpalmer,

I think you are right that we can’t do this yet. I’d suggest following this issue.

Just to make sure I have the requirements right. You want to be able to “dynamically link” with a shared library at build time and have the resulting binary work correctly even if the library against which it linked is at some other path on the filesystem at runtime. I assume, you expect the runtime resolution of the location of the shared library to be resolved using whatever the OS-specifc custom is. (e.g. LD_LIBRARY_PATH, or /etc/ld.so.conf, etc.)

Thanks,
Pepper

You’ve got it right.