# How do I add an include path with spaces for a cpp project?

**URL:** <https://discuss.gradle.org/t/how-do-i-add-an-include-path-with-spaces-for-a-cpp-project/6186>\
**Category:** Old Forum Archive\
**Created:** [August 29, 2013, 12:04pm UTC](https://discuss.gradle.org/t/how-do-i-add-an-include-path-with-spaces-for-a-cpp-project/6186 "2013-08-29T12:04:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christo\_Zietsman](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@Christo\_Zietsman](https://discuss.gradle.org/u/Christo_Zietsman)\
**Post date:** [August 29, 2013, 12:04pm UTC](https://discuss.gradle.org/t/how-do-i-add-an-include-path-with-spaces-for-a-cpp-project/6186/1 "2013-08-29T12:04:00Z")

</div>

I’m trying to create a JNI project on Windows. My JDK is in the usual place “C”\Program Files\Java". The following seems to work if I use a path to the JDK without spaces in it.

```gradle
apply plugin: 'cpp-lib'
  libraries {
    main {
        binaries.all {
            if (toolChain == toolChains.visualCpp) {
                compilerArgs '/I"C:\jdk1.7.0_21\include"'
                compilerArgs '/I"C:\jdk1.7.0_21\include\win32"'
            }
        }
    }
}

```

How should I specify the compilerArgs when the path contains spaces in it?

---

<div class="post-metadata">

**Author:** ![Christo\_Zietsman](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@Christo\_Zietsman](https://discuss.gradle.org/u/Christo_Zietsman)\
**Post date:** [October 10, 2013, 2:49pm UTC](https://discuss.gradle.org/t/how-do-i-add-an-include-path-with-spaces-for-a-cpp-project/6186/2 "2013-10-10T14:49:00Z")

</div>

I’ve was able to find a way to do this, but it feels like a hack:

```gradle
apply plugin: 'cpp-lib'
libraries {
 main {
  binaries.withType(SharedLibraryBinary) {
   if (toolChain in VisualCpp) {
    tasks.withType(CppCompile) {
     includes.from("C:\Program Files\Java\jdk1.8.0\include")
     includes.from("C:\Program Files\Java\jdk1.8.0\include\win32")
    }
   }
  }
 }
}

```

---

<div class="post-metadata">

**Author:** ![Minal\_Lamture](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@Minal\_Lamture](https://discuss.gradle.org/u/Minal_Lamture)\
**Post date:** [December 8, 2014, 11:44am UTC](https://discuss.gradle.org/t/how-do-i-add-an-include-path-with-spaces-for-a-cpp-project/6186/3 "2014-12-08T11:44:00Z")

</div>

Hi Christo,

When I am trying to add include paths in a way you have specified I am getting below error. Can you please provide any pointers?

- Where: Build file ‘H:\Work\CSF Onboarding\ClassifyCodeBase\CopiedCode\CopiedSourceCode\build.gradle’ line: 207

- What went wrong: Could not compile build file ‘H:\Work\CopiedCode\CopiedSourceCode\build.gradle’. \> startup failed:

build file ‘H:\Work\CopiedCode\CopiedSourceCode\build.gradle’: 207: unexpected char: ‘’ @ line 207, column 37.

includes.from("$project.buildDir…")

^

1 error

- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

---

<div class="post-metadata">

**Author:** ![Christo\_Zietsman](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@Christo\_Zietsman](https://discuss.gradle.org/u/Christo_Zietsman)\
**Post date:** [December 8, 2014, 2:02pm UTC](https://discuss.gradle.org/t/how-do-i-add-an-include-path-with-spaces-for-a-cpp-project/6186/4 "2014-12-08T14:02:00Z")

</div>

Hi Minal

We’ve since moved on to use Gradle 2.0. To add the include path I’m using the following snippet, but I expect “org.gradle.internal.jvm.Jvm.current()” to break in a future version of Gradle.

```gradle
binaries.withType(NativeBinary) {
  // Define toolchain-specific compiler and linker options
  if (toolChain in VisualCpp) {
    def javaHome = org.gradle.internal.jvm.Jvm.current().javaHome.absolutePath
    cppCompiler.args "-I${javaHome}/include"
    cppCompiler.args "-I${javaHome}/include/win32"
  }
}

```

---

<div class="post-metadata">

**Author:** ![Minal\_Lamture](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@Minal\_Lamture](https://discuss.gradle.org/u/Minal_Lamture)\
**Post date:** [December 10, 2014, 4:35pm UTC](https://discuss.gradle.org/t/how-do-i-add-an-include-path-with-spaces-for-a-cpp-project/6186/5 "2014-12-10T16:35:00Z")

</div>

Thanks for reply Christo…

I figured out my mistake in above snippet. It expects \ instead of . after changing \ to \ it worked fine.

But now I am stuck with library include path.

Can you please help me if you have any idea how to specify library include path in windows?

I have tried to add it like below but it doesn’t seem to be working

binaries.all { if (toolChain in VisualCpp) {

linker.args “/LIBPATH:${SYBASE\_DIR}\lib” } }
