在项目中使用两个静态库时,由于在两个静态库中编译的具有相同名称的类而引起冲突 [英] While using two static library in project, conflict due to class with same name compiled in both static libraries

查看:563
本文介绍了在项目中使用两个静态库时,由于在两个静态库中编译的具有相同名称的类而引起冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have implemented two static library having the following structure:

BaseClass.h

BaseClass.h

@interface BaseClass

-some methods

@end

FirstDerivedClass.h

FirstDerivedClass.h

@interface FirstDerivcedClass:BaseClass
{
}

-some methods

@end

SecondStaticLibrary.a

BaseClass.h

SecondStaticLibrary.a

BaseClass.h

@interface BaseClass

-some methods;

@end

SecondDerivedClass.h

SecondDerivedClass.h

@interface SecondDerivedClass:BaseClass
{
}

-someMethods;

@end

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

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

这些静态库已添加到TestApplication Project中.

These static libraries are added into TestApplication Project.

但是在运行应用程序时,它会引发错误:

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

在/User/Library/Developer/Xcode/..E./FirstStaticLibrary.a(BaseClass.o)和/User/Library/Developer/Xcode/..E./SecondStaticLibrary.a(BaseClass. o)适用于架构i386

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.

推荐答案

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

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.

这篇关于在项目中使用两个静态库时,由于在两个静态库中编译的具有相同名称的类而引起冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆