2013-07-15 54 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