Header file not found when try to build c++ project link to a static library with gradle -


i want build c++ project gradle since think universal build tool multiple language.i try add static library project. here directory structure.

. ├── build.gradle ├── gradle │   └── wrapper │       ├── gradle-wrapper.jar │       └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs │   └── addlib │       ├── add.hpp │       └── libadd.a └── src     ├── greeter     │   ├── cpp     │   │   └── greeter.cpp     │   └── headers     │       └── greeter.hpp     └── main         └── cpp             └── greeting.cpp 

and here build.gradle

apply plugin: 'cpp'   model {     repositories {         libs(prebuiltlibraries) {             add {                 headers.srcdir "libs/addlib"                 binaries.withtype(staticlibrarybinary) {                     staticlibraryfile =                         file("libs/addlib/libadd.a")                 }             }         }     }      components {         greeter(nativelibraryspec) {          }          // let's try using library         main(nativeexecutablespec) {              sources {                 cpp.lib library: "greeter"              }         }     }      binaries {         withtype(sharedlibrarybinaryspec) {             if (toolchain in visualcpp) {                 cppcompiler.define "dll_export"              }         }     } } 

when execute ./gradlew clean mainexecutable got error

> task :compilemainexecutablemaincpp /users/renkai/renkai-lab/building-cpp-libraries/src/main/cpp/greeting.cpp:2:10: fatal error: 'add.hpp' file not found #include "add.hpp"          ^ 1 error generated.    failure: build failed exception.  * went wrong: execution failed task ':compilemainexecutablemaincpp'. > build operation failed.       c++ compiler failed while compiling greeting.cpp.   see complete log at: file:///users/renkai/renkai-lab/building-cpp-libraries/build/tmp/compilemainexecutablemaincpp/output.txt  * try: run --stacktrace option stack trace. run --info or --debug option more log output.  build failed in 1s 2 actionable tasks: 2 executed 

i change build.gradle

apply plugin: 'cpp'  model {     repositories {         libs(prebuiltlibraries) {             myadd {                 headers.srcdir "libs/addlib"                 binaries.withtype(staticlibrarybinary) {                     staticlibraryfile =                         file("libs/addlib/libadd.a")                 }             }         }     }     components {         greeter(nativelibraryspec) {          }         // let's try using library         main(nativeexecutablespec) {             sources {                 cpp.lib library: "greeter"                 cpp.lib library: "myadd" , linkage: 'static'             }         }     }      binaries {         withtype(sharedlibrarybinaryspec) {             if (toolchain in visualcpp) {                 cppcompiler.define "dll_export"             }         }     } } 

and build passed.i think add might reserved key word gradle doesn't give enough hints.

there sample in gradle github repository:

https://github.com/gradle/gradle/blob/master/subprojects/docs/src/samples/native-binaries/prebuilt/build.gradle


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -