方法在静态 Linux 库中既已定义又未定义

Method is both defined and undefined in a static Linux library

我正在使用 visual studio 2019 并针对 ARM android 进行编译。 我的解决方案中的十二个库之一无法正确 link。

它显示了大量 class 已定义和未定义的方法。

这是一个使用命令行的例子:
nm -C -g Services_Droid.a 1>Services_Droid_All.txt

我得到一个清单,示例构造方法显示::

E:\code\Services_Droid_All.txt(5 次点击)

Line 834:           U hCitem::hCitem(int)
Line 1073:          U hCitem::hCitem(int)
Line 1197: 0000006c T hCitem::hCitem(int)   // there is only one definition in this file
Line 1199: 0000006c T hCitem::hCitem(int)
Line 5747:          U hCitem::hCitem(int)

将这个库链接到我的主程序中会生成三个库的副本 link.

失败的未定义项目

此库中有大量方法存在相同问题。

任何关于导致此问题的原因以及如何解决它的想法将不胜感激。

It is showing a sizable number of class methods that are both defined and undefined.

那是完全正常:一个档案库不过是.o个文件的集合。这些文件之一定义了 hCitem::hCitem(int)。其他一些文件引用了它。

你可以观察到,使用 nm -AC Services_Droid.a.

实际上就是这种情况

One of the twelve libraries in my solution is failing to link properly.

你应该问一个单独的问题,解释你的实际问题。