# How to include headers from C++ library?

**URL:** <https://discuss.gradle.org/t/how-to-include-headers-from-c-library/9438>\
**Category:** Help/Discuss\
**Created:** [May 1, 2015, 9:49pm UTC](https://discuss.gradle.org/t/how-to-include-headers-from-c-library/9438 "2015-05-01T21:49:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jvff](https://avatars.discourse-cdn.com/v4/letter/j/8491ac/32.png) [@jvff](https://discuss.gradle.org/u/jvff)\
**Post date:** [May 1, 2015, 9:49pm UTC](https://discuss.gradle.org/t/how-to-include-headers-from-c-library/9438/1 "2015-05-01T21:49:32Z")

</div>

Hello,

I’m trying to use a 3rd party library (FakeIt) that only has headers (ie. there’s no library to link against). How would I include it as a dependency for my C++ project? For now I’m doing something that could be summarised as:

```
model {
    components {
        test(NativeExecutableSpec) {
            binaries.all {
                cppCompiler.args "-I/path/to/lib/include"
            }
        }
    }
}

```

But I would rather use something similar to the syntax

```
...
        test(NativeExecutableSpec) {
            sources.cpp {
                lib library: 'fakeit'
            }
        }
...

```

Is there a way to do this? If not, would it be to useful to extend `PrebuiltLibraries` to have libraries without binaries, or create a `HeaderOnlyLibraries`?

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [May 1, 2015, 11:25pm UTC](https://discuss.gradle.org/t/how-to-include-headers-from-c-library/9438/2 "2015-05-01T23:25:16Z")

</div>

You can use PrebuiltLibraries for this:

> <https://github.com/gradle/gradle/blob/master/subprojects/docs/src/samples/native-binaries/prebuilt/build.gradle#L9-L11>

Look at the boost prebuilt library. You add a library requirement with it using the ‘api’ linkage.

```
lib library: 'fakeit', linkage: 'api'
```

---

<div class="post-metadata">

**Author:** ![jvff](https://avatars.discourse-cdn.com/v4/letter/j/8491ac/32.png) [@jvff](https://discuss.gradle.org/u/jvff)\
**Post date:** [May 2, 2015, 2:41am UTC](https://discuss.gradle.org/t/how-to-include-headers-from-c-library/9438/3 "2015-05-02T02:41:27Z")

</div>

Excellent. What I needed was the `linkage: 'api'` part. I only knew about `static` and `shared` linkage. Thank you very much! =)
