How do I set LD_LIBRARY_PATH using gradle?

290 Views Asked by At

I want to use a library with a C++ project and I need to set the LD_LIBRARY_PATH to get it to compile and execute fine. The code compilation is done using gradle. I am trying to set the LD_LIBRARY_PATH in build.gradle as below but it doesn't seem to work:

task exportLDLibPath() {
    exec {
        environment 'LD_LIBRARY_PATH', '/path/to/lib'
    }
    project.check.dependsOn it
}

What am I missing here? I need to path to be set so that the unit tests can run.

1

There are 1 best solutions below

0
On

After some digging and discussions, found out that the below code does the trick:

tasks {
        afterEach(org.gradle.nativeplatform.test.boosttest.tasks.CreateTestScript) {
            environment LD_LIBRARY_PATH: "/path/"
        }
        withType(org.gradle.nativeplatform.test.tasks.RunTestExecutable)
      }