How to configure the external library path for cpp-lib or cpp-exe plugin

(66229754) #1

Hi Gradle expert,

I am trying to build a vc++ library project with gradle nightly wrapper, and I already installed vs2012, my build.gradle file is as follow:

apply plugin: 'cpp-lib'
           sources {
     main {
        cpp {
            source {
                srcDir "."
                srcDir "P4API"
                include "**/*.cpp"
      binaries.all {
      // Define a preprocessor macro for every binary
      cppCompiler.define "NDEBUG"
        // Define toolchain-specific compiler and linker options
      if (toolChain in VisualCpp) {
          cppCompiler.args "/Zi", "/EHsc"
          linker.args "/DEBUG"
                          tasks.withType(CppCompile) {
                      tasks.withType(LinkSharedLibrary) {
               //libs+=files('C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86/uuid.lib','C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86/kernel32.lib')
      task wrapper(type: Wrapper) {
      gradleVersion = "1.11-20131217230034+0000"
      defaultTasks "mainSharedLibrary"

Now the problems is I don’t know where to set the external library directories for searching dependent library to link, when running the default task to build the dll, it will have link error: can’t find the uuid.lib, kernel32.lib, these libaries are located in windows sdk. Actually gradle is able to compile the cpp file, just have link errors.

I found it works when I add uuid.lib and kernel32.lib path to libs of LinkSharedLibary task, but I have many external libraries to link, any easy way to use?Link in visual studio, just set the vc++ library directories and add additional dependencies to the linker.