Native cpp library includes


(Conall Prendergast) #1

Hi,
I am trying to add a (3rd party) library to include when compiling my native project, namely ‘netfilter_queue’.
My build.gradle is as follows:
apply plugin: ‘cpp’

model {
    components {
       main(NativeExecutableSpec) {
            sources {
               cpp.lib library: "netfilter_queue"
            }
        }
    }
}

However, I keep getting a:

 Could not locate library 'netfilter_queue'.

I can compile manually by providing a “-lnetfilter_queue” argument to g++, how can I make gradle include this library?

Also, is there any way to pull in the dependency from a repository (like mavencentral for a java project)?
Thanks,
Conall


(Daniel Lacasse) #2

Hi Conall,

Thanks for your input on the native side of Gradle.

At the present moment, the dependency syntax you are using for netfilter_queue is only valid for library managed by Gradle (inside your current project or as multi-project configuration). Managed library are either component built by Gradle or configured through prebuilt library. Anything other dependency on 3rd party library needs to be specified through compiler flag.

To pull in dependency from a repository, you will need to manually configure the configurations and dependencies dsl and have custom task to resolve those. I suggest you have a look at the Depedency Management section of the user guide for more information on how to manually use this feature.

Don’t hesitate to ask more questions,

Daniel


(Conall Prendergast) #3

Hi Daniel,
Many thanks for the explanation.
It is working fine now.

Conall