在项目中使用两个静态库时,由于两个静态库中编译的同名类而发生冲突

发布于 2024-12-21 16:54:22 字数 840 浏览 1 评论 0原文

我已经实现了两个具有以下结构的静态库:

FirstStaticLibrary.a

BaseClass.h

@interface BaseClass

-some methods

@end

FirstDerivedClass.h

@interface FirstDerivcedClass:BaseClass
{
}

-some methods

@end

SecondStaticLibrary.a

BaseClass.h

@interface BaseClass

-some methods;

@end

SecondDerivedClass.h

@interface SecondDerivedClass:BaseClass
{
}

-someMethods;

@end

上面两个静态库具有公共文件 BaseClass.h 和 BaseClass.m

这些静态库是添加的进入测试应用程序项目。

但在运行应用程序时,它会抛出错误:

在 /User/Library/Developer/Xcode/..E./FirstStaticLibrary.a (BaseClass.o) 和 /User/Library/Developer/Xcode/..E./SecondStaticLibrary.a (BaseClass.o) 中发现重复符号o) 对于 i386 架构

请建议一种消除此错误的方法。

I have implemented two static library having the following structure:

FirstStaticLibrary.a

BaseClass.h

@interface BaseClass

-some methods

@end

FirstDerivedClass.h

@interface FirstDerivcedClass:BaseClass
{
}

-some methods

@end

SecondStaticLibrary.a

BaseClass.h

@interface BaseClass

-some methods;

@end

SecondDerivedClass.h

@interface SecondDerivedClass:BaseClass
{
}

-someMethods;

@end

Above two static library is having the common file BaseClass.h and BaseClass.m

These static libraries are added into TestApplication Project.

But while running the application, it's throwing an error:

Duplicate symbols found in /User/Library/Developer/Xcode/..E./FirstStaticLibrary.a (BaseClass.o) and /User/Library/Developer/Xcode/..E./SecondStaticLibrary.a (BaseClass.o) for architecture i386

Please suggest a way to remove this error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莫言歌 2024-12-28 16:54:22

答案是您可能不想听到的,但您必须在其中一个库中更改名称。假设您可以访问这两个库。

The answer is one you probably don't want to hear, but you will have to change the name in one of your libraries. Assuming you have access to both libraries that is.

扛起拖把扫天下 2024-12-28 16:54:22

这个答案可能是您想听到的!我设法找到了一个有效的解决方案!希望其他人能够了解到,即使他们将其他 API 包含到他们的框架中,他们仍然需要在类上放置前缀。
看这里。

This answer is probably one you will want to hear! I managed to find a solution that works! Hopefully others will learn that even when they include other APIs into their frameworks, they still always need to place their prefix on the classes.
Look here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文