# Native cpp library includes

**URL:** <https://discuss.gradle.org/t/native-cpp-library-includes/20154>\
**Category:** Help/Discuss\
**Created:** [October 25, 2016, 9:49am UTC](https://discuss.gradle.org/t/native-cpp-library-includes/20154 "2016-10-25T09:49:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpren](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cpren](https://discuss.gradle.org/u/cpren)\
**Post date:** [October 25, 2016, 9:49am UTC](https://discuss.gradle.org/t/native-cpp-library-includes/20154/1 "2016-10-25T09:49:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Daniel\_L](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daniel_l/32/6420_2.png) [@Daniel\_L](https://discuss.gradle.org/u/Daniel_L)\
**Post date:** [October 25, 2016, 1:32pm UTC](https://discuss.gradle.org/t/native-cpp-library-includes/20154/2 "2016-10-25T13:32:01Z")

</div>

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](https://docs.gradle.org/current/userguide/native_software.html#sec:running_cunit_tests). 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](https://docs.gradle.org/current/userguide/dependency_management.html) for more information on how to manually use this feature.

Don’t hesitate to ask more questions,

Daniel

---

<div class="post-metadata">

**Author:** ![cpren](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cpren](https://discuss.gradle.org/u/cpren)\
**Post date:** [October 26, 2016, 11:31am UTC](https://discuss.gradle.org/t/native-cpp-library-includes/20154/3 "2016-10-26T11:31:19Z")

</div>

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

Conall
