0

已经使用一些 c / c++ 代码很长一段时间了,它在项目中运行良好。现在尝试从代码中创建一个 .a ,除了一个项目之外一切都很好。

有交流套路,叫它吧

void init(sometype *)

这在 XCODE 中被标记为 c++ 文件,并且它有一个 .h 文件

在那里我们有

#if defined(__cplusplus)
extern "C"
{
#endif

void init(sometype *);

#if defined(__cplusplus)
}
#endif

在将所有链接作为一个应用程序链接时,从目标 C 调用时会找到所有这些链接

当此代码包含在 .a 中,然后尝试从一个单独的项目链接时,我们得到....

Undefined symbols for architecture armv6:
  "__Znam", referenced from:
      _init in libMy.a(Objectfile.o)
ld: symbol(s) not found for architecture armv6
clang: error: linker command failed with exit code 1 (use -v to see invocation)

看起来我们正在获得一些 C++ 初始化例程?链接 find 时的 .o 看起来与我们为 .a 编译时相同(__Znam 在那里)。

那么缺少什么库???

将进行更多挖掘以尝试找出幕后未包含的内容。

- - - - - 新的信息 - - - - - -

看起来问题是“new”关键字在这个例程中不起作用,这可能是例程没有正确链接。

所以像这样的一行...

var->output = new Int32*[10];

不能正常工作。......

4

0 回答 0