我正在尝试使用 Maven 和 NAR 插件构建和测试 DLL。我正在构建的 DLL 依赖于另一个我也使用 NAR 插件构建的 DLL。这是我的 POM:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>myproject</artifactId>
<packaging>nar</packaging>
<name>My Project</name>
<version>1.0.0-SNAPSHOT</version>
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>org.codeswarm</groupId>
<artifactId>maven-nar-plugin</artifactId>
<version>20121119</version>
<extensions>true</extensions>
<configuration>
<cpp>
<defines>
<define>DLLEXPORT</define>
</defines>
</cpp>
<libraries>
<library>
<type>shared</type>
</library>
</libraries>
<tests>
<test>
<name>ProjectTest</name>
<link>shared</link>
</test>
</tests>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>shared-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>nar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
如果我删除对 com.mycompany:shared-library
的依赖 - 同时删除想要调用它的代码 - 那么它就可以正常工作。 ProjectTest
正常运行并执行预期的操作。但是由于存在依赖关系,maven 无法运行测试,因为它找不到 shared-library
。它因错误 0xc0000135
而崩溃。
当我在 Debug模式下运行 Maven 时,我可以看到当它编译测试时,它正确地将两个 DLL 的头文件的包含路径添加到编译器命令中。当它链接测试时,它正确地将两个 DLL 的导出库添加到链接器命令中。 Maven 执行测试时出现问题:Maven 想将 DLL 的路径添加到系统路径,它这样做了——但它只添加了 myproject
DLL 的路径。它不会将路径添加到 shared-library
DLL。因此崩溃。
这是 maven-nar-plugin 中的已知问题吗?我还听说有一些 NAR 插件的分支在流传;这个问题可能会在我使用的插件版本以外的某个插件版本中得到解决吗?或者是否有一些可以推荐的解决方法?
最佳答案
发现这是一个已知问题:https://issues.sonatype.org/browse/NAR-189
关于c++ - Maven NAR 插件 : DLL dependency not found on path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13920728/