我第一次使用 maven nar 插件在 C++ 中编译一系列 corba IDL 文件。我已经通过使用 exec 插件和omniidl 成功生成了存根和骨架,现在我在 src/ 下拥有所有 *.C 和 *.H 文件。
我们正在使用内部 Nexus 存储库来检索 NAR 依赖项,到目前为止,我设法编译了所有 *.o 文件。但是,链接器失败并显示以下消息:
[INFO] 21 files were compiled.
[INFO] 21 files were compiled.
[INFO] Linking...
[INFO] Linking...
[INFO] Starting link {4.8 -shared -L/home/dev/repos/idl/cpp-idl/bin/nar/omniORB4-4.2.0-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lomniORB4-4.2.0-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/omnithread-4.2.0-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lomnithread-4.2.0-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/c-2.19-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lc-2.19-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/m-2.19-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lm-2.19-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/stdc__plus__plus-4.8.3+r212056-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lstdc__plus__plus-4.8.3+r212056-R1 -fexceptions -lstdc++}
[INFO] Starting link {4.8 -shared -L/home/dev/repos/idl/cpp-idl/bin/nar/omniORB4-4.2.0-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lomniORB4-4.2.0-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/omnithread-4.2.0-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lomnithread-4.2.0-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/c-2.19-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lc-2.19-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/m-2.19-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lm-2.19-R1 -L/home/dev/repos/idl/cpp-idl/bin/nar/stdc__plus__plus-4.8.3+r212056-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared -lstdc__plus__plus-4.8.3+r212056-R1 -fexceptions -lstdc++}
[ERROR] /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lomniORB4-4.2.0-R1
[ERROR] /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lomnithread-4.2.0-R1
[ERROR] /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lc-2.19-R1
[ERROR] /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lm-2.19-R1
[ERROR] /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lstdc__plus__plus-4.8.3+r212056-R1
[ERROR] collect2: error: ld returned 1 exit status
问题是,例如文件夹
/home/dev/repos/idl/cpp-idl/bin/nar/omniORB4-4.2.0-R1-amd64-Linux-gpp-shared/lib/amd64-Linux-gpp/shared
包含以下共享对象:
libomniORB4.so libomniORB4.so.2 libomniORB4.so.2.0
并且链接器尝试链接包含完整版本(依赖版本)的库名称
-lomniORB4-4.2.0-R1
我的问题如下:
- 我可以假设包含共享对象的 Nexus 存储库中提供的 omniORB4 NAR 依赖项包含错误的 .so 名称吗?
- 有没有办法通过在链接器部分告诉 NAR 插件使用不同的库名称来链接来解决它?
这是配置 NAR 插件的 pom 部分:
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<configuration>
<libraries>
<library>
<type>shared</type>
</library>
</libraries>
<cpp>
<name>g++</name>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<options>
<option>-g</option>
</options>
<includes>
<include>**/*.C</include>
</includes>
<includePaths>
<includePath>${project.basedir}/src</includePath>
</includePaths>
</cpp>
</configuration>
</plugin>
....
谢谢。