Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build C/C++ projects using maven-nar plugin

I'm trying to setup a simple project with an empty function (.c and .h file) on windows 7, using maven, cygwin and gcc. Following are details about my environment:

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

When I try to build using the maven-nar plugin, I get the following error:

$ 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

I have google'd and it seems to be related to maven not finding the gcc compiler.

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

The output from the mvn command also suggests that maven is trying to build my project with msvc which is not available on my machine.

[INFO] Using AOL: x86-Windows-msvc

I have the gcc compiler in my path etc and I have tried to follow some of the steps suggested in this very old thread.

Does anyone know how to overcome this problem? If I'm in the wrong forum, could someone please point me to the right one?

like image 406
Code Poet Avatar asked Mar 23 '23 18:03

Code Poet


1 Answers

Yes, that error is caused by a command line tool being unavailable on the path. However, in this case, since your AOL is x86-Windows-msvc, the relevant command line tool is link, not gcc. (You can see this in the source code.)

Of course, you aren't trying to use the MSVC compiler at all, so you shouldn't need link in your path anyway. To use gcc instead, you need to configure that in your POM in the maven-nar-plugin configuration. Here is a sample configuration (from this project, which you will of course need to tweak to your needs):

<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>
like image 200
ctrueden Avatar answered Mar 26 '23 07:03

ctrueden