Compile C++ code in gradle using CPP plugin -


i working on gradle script trying complie c++ code , structure below.i trying compile code on below machine , showing c++ compiler failed whereas not getting issue maven can somel

linux 2.6.32-431.el6.x86_64 #1 smp sun nov 10 22:19:54 est 2013 x86_64 x86_64 x86_64 gnu/linux

└───src     └───main         ├───c++         │   ├───headers   (headres having **.h files)         │   └───native    (native contains  **.cpp files)         └───resources             └───dsresources                 └───dslib  apply plugin: 'cpp' //-- set group publishing group = 'com.rohit.singh' /**  * initializing gavc settings  */ def buildproperties = new properties() file("version.properties").withinputstream {      stream -> buildproperties.load(stream)  }  //add jenkins build version version def env = system.getenv() if (env["build_number"]) buildproperties.enginebuildversion += "_${env["build_number"]}" version = buildproperties.enginebuildversion println "${version}"  //name set in settings.gradle file group = "com.rohit.singh" version = buildproperties.enginebuildversion println "building ${project.group}:${project.name}:${project.version}"  model {   components {     main(nativeexecutablespec) {       targetplatform "x86"       targetplatform "x64"       sources {         cpp {           source {             srcdir "src/main/c++/native"           }         }       }     }   } } 

below maven code snippet

profile>             <id>linux</id>             <activation>                 <os>                     <family>linux</family>                 </os>             </activation>             <properties>                 <packaging.type>so</packaging.type>             </properties>             <build>                 <plugins>                     <plugin>                         <groupid>org.codehaus.mojo</groupid>                         <artifactid>native-maven-plugin</artifactid>                         <version>1.0-alpha-8</version>                         <extensions>true</extensions>                         <configuration>                              <javahos>linux</javahos>                              <compilerprovider>generic-classic</compilerprovider>                             <compilerexecutable>g++</compilerexecutable>                             <linkerexecutable>g++</linkerexecutable>                             <sources>                                 <source>                                     <directory>nativejni/../src/main/c++/native</directory>                                     <filenames>                                         <filename>jnisupport.cpp</filename>                                         <filename>diseasestagingjni.cpp</filename>                                     </filenames>                                 </source>                             </sources>                             <compilerstartoptions>                                 <compilerstartoption>-fpic</compilerstartoption>                             </compilerstartoptions>                             <linkerfinalname>nativejni</linkerfinalname>                             <linkerstartoptions>                                 <linkerstartoption>-shared -l${basedir}/src/main/resources/dsresources/dslib -lds64 -wl,-rpath,${basedir}/src/main/resources/dsresources/dslib</linkerstartoption>                             </linkerstartoptions>                          </configuration>                         <executions>                             <execution>                                 <id>javah</id>                                 <phase>generate-sources</phase>                                 <configuration>                                     <finalname>linuxnativejni</finalname>                                     <javahos>linux</javahos>                                     <javahprovider>default</javahprovider>                                     <javahoutputdirectory>${project.build.directory}/custom-javah</javahoutputdirectory>                                     <workingdirectory>${basedir}</workingdirectory>                                     <javahoutputfilename>diseasestagingjniwrapper.h</javahoutputfilename>                                     <javahclassnames>                                         <javahclassname>com.truvenwealth.analyticsengine.common.diseasestaging.diseasestagingjniwrapper</javahclassname>                                     </javahclassnames>                                 </configuration>                                 <goals>                                     <goal>javah</goal>                                 </goals>                             </execution>                         </executions>                     </plugin>                     <plugin> 

i used javah function in below manner.

apply plugin: 'cpp' apply plugin: 'java' //-- set group publishing group = 'com.rohit.singh'  /**  * initializing gavc settings  */ def buildproperties = new properties() file("version.properties").withinputstream {         stream -> buildproperties.load(stream) } //add jenkins build version version def env = system.getenv() if (env["build_number"]) buildproperties.ncdefbuildversion += "_${env["build_number"]}" version = buildproperties.anal println "${version}"  //name set in settings.gradle file group = "com.rohit.singh" version = buildproperties.anal println "building ${project.group}:${project.name}:${project.version}"  repositories {     maven {       url "http://xxx.tsh.xxon.com:x/factory/libslocal"     }      maven {       url "http://xxx.tsh.xxon.com:x/factory/libs-release"     } }     dependencies {    compile ([     "com.rohit.singh:engine-common:4.+"       ]) }    model {   repositories {     libs(prebuiltlibraries) {       jdk {         headers.srcdirs "${system.properties['java.home']}/../include",         "${system.properties['java.home']}/../include/win32",         "${system.properties['java.home']}/../include/darwin",         "${system.properties['java.home']}/../include/linux"       }     }   } }  model {   platforms {     x64 { architecture "x86_64" }     x86 { architecture "x86" }   } }  model {   components {     main(nativelibraryspec) {       sources {         cpp {           source {             lib library: 'main', linkage: 'static'             lib library: 'jdk', linkage: 'api'             srcdir "src/main/c++/native"             include "**/jnisupport.cpp"             include "**/diseasestagingjni.cpp"           }         }       }     }   } }  def nativeheadersdir = file("$builddir/nativeheaders") //def compilepath = configurations.compile.resolve().collect {it.absolutepath}.join(";") binaries.all {     // define toolchain-specific compiler , linker options     if (toolchain in gcc) {         cppcompiler.args "-i${nativeheadersdir}"         cppcompiler.args "-g"         linker.args '-xlinker', '-shared -lnativejni/src/main/resources/dsresources/dslib -lds64 -wl' } }  **//def nativeheadersdir = file("$builddir/nativeheaders") task nativeheaders {     // def nativeheadersdir = file("$builddir/nativeheaders")      def outputfile = file("$nativeheadersdir/diseasestagingjniwrapper.h")      def classes = [              'com.abcedefgh.nice.common.diseasestaging.diseasestagingjniwrapper'                   ]      inputs.files sourcesets.main.output      inputs.property('classes', classes)      outputs.file outputfile      dolast {          outputfile.parentfile.mkdirs()          def compilepath = configurations.compile.resolve().collect {it.absolutepath}.join(":")          println "using compile path: ${compilepath}"          exec {              executable org.gradle.internal.jvm.jvm.current().getexecutable('javah')              args '-o', outputfile              args '-classpath', compilepath              args classes          }      }  }               tasks.withtype(cppcompile) { task ->                  task.dependson nativeheaders              }** //def filechange = file("nativejni-${project.version}.so") //println filechange task fixartifactname (type: copy) {        //def filechange = "nativejni-${project.version}.so"        //println filechange        'build/binaries/mainsharedlibrary'        'build/libs' def filechange = file("nativejni-${project.version}.so") println filechange include('libmain.so') rename ('libmain.so', '${filechange}') } //println fixartifactname build.dependson fixartifactname