2
我正在編寫gradle腳本,我試圖編譯C++代碼,我的結構如下。我試圖在下面的機器上編譯我的代碼,它顯示了C++編譯器失敗,而我沒有得到與Maven的問題可以somel使用CPP插件編譯gradle中的C++代碼
的Linux 2.6.32-431.el6.x86_64#1 SMP太陽11月10日22時19分54秒美國東部時間2013 x86_64的x86_64的x86_64的GNU/Linux的
└───src
└───main
├───c++
│ ├───headers (headres is having **.h files)
│ └───native (native contains **.cpp files)
└───resources
└───DSresources
└───DSLib
apply plugin: 'cpp'
//-- set the group for publishing
group = 'com.rohit.singh'
/**
* Initializing GAVC settings
*/
def buildProperties = new Properties()
file("version.properties").withInputStream {
stream -> buildProperties.load(stream)
}
//add the jenkins build version to the version
def env = System.getenv()
if (env["BUILD_NUMBER"]) buildProperties.engineBuildVersion += "_${env["BUILD_NUMBER"]}"
version = buildProperties.engineBuildVersion
println "${version}"
//name is set in the 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"
}
}
}
}
}
}
以下是maven代碼片段
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>
什麼是錯誤? –
正如我所說的錯誤是說C++編譯器failed.I粘貼我的POM文件片段,因爲在我的問題。 – Sushant
看來你的'srcDir'不包含'headers'目錄。你可以檢查是否添加'srcDir「src/main/C++/headers」'解決你的問題? –