【发布时间】:2023-09-11 17:29:01
【问题描述】:
我已经构建了一个静态库,可以链接到我的 iPhone 应用程序中。这个库使用了一些全局变量和函数,就像在 C 中一样。我的问题是,当使用例如:
extern
void do_stuff (const int a)
{
return a*a;
}
extern const int a_variable;
extern const int an_array[DEFINED_VALUE];
当我在代码中的任何位置使用此函数或访问这些变量时,编译器会告诉我
“_do_stuff”引用自: -tests.o中的[Object testMethod]
“_a_variable”引用自: -tests.o中的[Object testMethod]
“_an_array”引用自: -tests.o中的[Object testMethod]
找不到符号 Collect2: Id 返回 1 个退出状态
以前有人遇到过这个问题吗?我知道我在做一些愚蠢的事情,我错过了一些关键的 Objective-C 或 C 概念,但我真的看不出是什么。所以我希望有人能帮助我。提前致谢。
【问题讨论】:
标签: c objective-c global-variables static-libraries extern