2013-07-15 52 views
0

我试图建立通过使用本机MVN-插件的Maven CPP库。然而,该连接部分中,我遇到一个错误说“的命令行是太长”本机Maven的插件错误“命令行太长。”

至于配置,即时通讯有这样的:

<envFactoryName>org.codehaus.mojo.natives.msvc.MSVC2008x86EnvFactory</envFactoryName> 
<compilerProvider>msvc</compilerProvider> 
<compilerStartOptions> 
    <compilerStartOption> /GL /EHsc </compilerStartOption> 
</compilerStartOptions> 

而对于linkerStartOptions,我有这个:

<linkerStartOptions> 
    <linkerStartOption>-g -Fo -lstdc</linkerStartOption> 
</linkerStartOptions> 

如果有人能帮助我会很高兴。

+0

顺便说一下,同样如果使用im不同克++编译器 – xtrycatchx

回答

1

我真的不鼓励使用Maven插件原生的,我有很多的麻烦配置它,我不知道,如果它保持为主页说,这是最后一次公布了2011-03-09 。我所做的处理使用maven构建C++库的问题是使用maven-exec插件。在命令行

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" 

:我通过调用加载的MSBuild工具。之后,msbuild将在您的范围内提供。

这些都是我的POM文件的内容:

<plugin> 
    <artifactId>exec-maven-plugin</artifactId> 
    <configuration> 
     <executable>msbuild</executable> 
     <sourceRoot>${basedir}/Library/</sourceRoot> 
    </configuration> 
    <executions> 
     <execution> 
      <id>clean</id> 
      <phase>clean</phase> 
      <configuration> 
       <arguments> 
        <argument>${basedir}/Library/Library.vcxproj</argument> 
        <argument>/p:Configuration=Release</argument> 
        <argument>/p:Platform=x64</argument> 
        <argument>/t:Clean</argument> 
       </arguments> 
      </configuration> 
      <goals> 
       <goal>exec</goal> 
       </goals> 
      </execution> 
     <execution> 
      <id>build</id> 
      <phase>compile</phase> 
      <configuration> 
       <arguments> 
        <argument>${basedir}/Library/Library.vcxproj</argument> 
        <argument>/p:Configuration=Release</argument> 
        <argument>/p:Platform=x64</argument> 
        <argument>/t:Build</argument> 
       </arguments> 
      </configuration> 
      <goals> 
       <goal>exec</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

这样的配置将使得该项目既响应清洁和编译的目标。你可以更进一步,并使用装配插件来收拾你的库中,并使其安装库中的本地资源库,因此它可以被添加为其他项目的依赖。

+0

非常感谢阿默里发生。这真的有帮助,它确实解决了我的问题;) – xtrycatchx