无法使用maven-nar插件构建C / C ++项目

时间:2013-05-30 09:09:02

标签: maven maven-nar-plugin

我正在尝试使用maven,cygwin和gcc在Windows 7上设置一个带有空函数(.c和.h文件)的简单项目。以下是有关我的环境的详细信息:

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

我已经谷歌了,似乎与maven没有找到gcc编译器有关。

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

mvn命令的输出还表明maven正在尝试使用我的计算机上没有的msvc来构建我的项目。

[INFO] Using AOL: x86-Windows-msvc

我的路径中有gcc编译器等,我试图遵循this very old thread中建议的一些步骤。

有谁知道如何克服这个问题?如果我在错误的论坛,请有人请我指出正确的论坛吗?

1 个答案:

答案 0 :(得分: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>