How to add include and linker paths in VisualCpp toolchain

Hi,

This is very basic question but I am facing issues while adding include directories to compiler in visualCpp toolchain.

The way I have added is

binaries.all {

if (toolChain in VisualCpp) {

cppCompiler.args “/II:\sybase\OCS-12_0\include”

etc

linker.args “/LI:\sybase\OCS-12_0\lib”

etc

} }

wont this work in visual studio build?

can you please provide some pointers on how to specify compiler and linker paths nin visualCpp toolchain

Hi Minal,

Please try this code if it works for your requirement: To include different Header directory, you can specify those in “exportHeaders” section.

sources {
    "${project.name}" {
        cpp {
   source {
    srcDirs "."
    include "**/*.cpp"
           }
              exportedHeaders {
                srcDirs "I:\sybase\OCS-120\include", "../"
                include "*.h"
                }
             }
    }
}

To link the libraries you can do this way ( I tried this below way, I am also new to gradle. you may find better way )

Giving one example of ZLIB library, you can specify multiple libs and there path.

model {
    repositories {
        libs(PrebuiltLibraries) {
            zlib {
                headers.srcDir "common/inc"
    binaries.withType(StaticLibraryBinary) {
     if(buildType == buildTypes.debug) {
      staticLibraryFile = file("${gls_home}/common/libs/zlib/debug/zlib.lib")
     }
     if(buildType == buildTypes.release) {
      staticLibraryFile = file("${gls_home}/common/libs/zlib/release/zlib.lib")
     }
                }
                            }
  }
  -----------------------
//Specify the libraries to link in sources in your build.gradle file.
sources {
    "${project.name}" {
    cpp {
      lib library: 'zlib', linkage: 'static'
}

Hi Mandar.

thanks for your reply.

Can you please let me know if you are aware of any method which can be used to provide just path to library locations? and gradle will automatically search those locations in order to find a particular library… like we specify LIBPATH in windows or ld library path in linux?

The reason I want this is because I have huge set of dependencies for each of subproject… and ideally it will be redundant code as well to release same individual library dependencies in each subproject