0

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.

ghanashyam
  • 85
  • 1
  • 3
  • 13
  • [`exec {}`](https://docs.gradle.org/7.6/javadoc/org/gradle/api/Project.html#exec-groovy.lang.Closure-) will launch a new, _independent_, process (which in your instance, does nothing, except it has an env var set). What is the specific task you want to add the env var to? What is its type? – aSemy Dec 31 '22 at 09:15
  • I want to export the environment variable, ie the equivalent of the bash command export LD_LIBRARY_PATH=path. Path is a string – ghanashyam Dec 31 '22 at 10:24

0 Answers0