2013-05-30 138 views
2

我試圖在Windows 7上使用maven,cygwin和gcc設置一個帶有空函數(.c和.h文件)的簡單項目。下面是我的環境信息:無法使用maven-nar插件構建C/C++項目

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 22:51:28+0900) 
Maven home: C:\Program Files\apache-maven-3.0.5 
Java version: 1.6.0_37, vendor: Sun Microsystems Inc. 
Java home: C:\Progra~1\Java\jdk1.6.0_37\jre 
Default locale: ko_KR, platform encoding: MS949 
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows" 
gcc (GCC) 4.5.3 

當我嘗試使用的maven-NAR插件來構建,我得到以下錯誤:

$ mvn clean package 
[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building test-maven 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ test-maven --- 
[INFO] 
[INFO] --- maven-nar-plugin:2.1-SNAPSHOT:nar-validate (default-nar-validate) @ test-maven --- 
[INFO] Using AOL: x86-Windows-msvc 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1.600s 
[INFO] Finished at: Thu May 30 18:03:18 KST 2013 
[INFO] Final Memory: 5M/15M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-nar-plugin:2.1-SNAPSHOT:nar-validate (default-nar-validate) on project test-maven: Cannot deduce version number from: -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

我已經google'd,它似乎是相關的找不到gcc編譯器。

Cannot deduce version number from: -> [Help 1] 

mvn命令的輸出還表明,Maven是試圖建立我的項目,msvc這是不可用我的機器上。

[INFO] Using AOL: x86-Windows-msvc 

我在我的道路等的gcc編譯器和我試圖遵循一些在this very old thread建議的步驟。

有誰知道如何解決這個問題?如果我在錯誤的論壇中,有人可以請我指出正確的一個嗎?

回答

5

是的,該錯誤是由命令行工具在路徑上不可用造成的。但是,在這種情況下,由於您的AOL爲x86-Windows-msvc,因此相關的命令行工具是link,而不是gcc。 (你可以在the source code中看到這個。)

當然,你根本沒有嘗試使用MSVC編譯器,所以你不應該在你的路徑中需要link。要改爲使用gcc,則需要在maven-nar-plugin配置中的POM中進行配置。下面是一個示例配置(從this project,您當然需要根據您的需要調整):

<configuration> 
    <c> 
     <name>gcc</name> 
     <includes> 
      <include>**/*.c</include> 
     </includes> 
     <options> 
      <option>-I${JAVA_HOME}/include</option> 
      <option>${java.os.include}</option> 
      <option>${stack.protector.option}</option> 
      <option>${architecture.option}</option> 
      <option>${subsystem.option}</option> 
      <option>${debug.option}</option> 
     </options> 
    </c> 
    <linker> 
     <name>gcc</name> 
     <options> 
      <option>${architecture.option}</option> 
      <option>${subsystem.option}</option> 
     </options> 
     <sysLibs> 
      <sysLib> 
       <name>${libdl.name}</name> 
      </sysLib> 
     </sysLibs> 
    </linker> 
    <libraries> 
     <library> 
      <type>executable</type> 
      <!-- <run>true</run> --> 
      <subSystem>gui</subSystem> 
     </library> 
    </libraries> 
</configuration> 
+0

非常感謝。你真的幫助我。我已經堅持了這幾天。 –

+0

我在https://github.com/jjYBdx4IL/example-maven-project-setups上放了一個實例。 – user1050755

+0

謝謝,我把它從NAR維基鏈接起來! https://github.com/maven-nar/nar-maven-plugin/wiki/Working-examples – ctrueden