iPhone——在项目中嵌套库而没有链接器错误?

发布于 2024-11-30 20:40:36 字数 627 浏览 0 评论 0原文

这让我发疯。

我有库 A,它又包含库 B。这对嵌套的库用于 5 个不同的项目。我希望将 A 和 B 的源放在一个位置,并将所有 5 个项目链接到它们。

无论我做什么,我都会遇到两种错误之一:

1)库 B 的 A 类与其自身发生冲突。链接器在库 A 和库 B 中看到所述类

。2) 某些类丢失,因为链接器找不到它们。

我应该提到库 A 包含类别。我正在通过在每个类别文件中使用一个虚拟类并在外部项目中使用 ObjC 链接器标志来处理类别错误。

这是我尝试使用的设置。如下所述,我得到了重复的符号。

我有目录 Documents/LibraryA、Documents/LibraryA/LibraryB 和 Documents/Project1 到 Documents/Project5。

目录 Documents/Project1 有一个符号链接 LibraryA,它指向 ../LibraryA。对于项目 2 到 5 也是如此。

包含项目中的标头搜索路径为 ./LibraryA ./LibraryA/Classes/** 和 ./LibraryA/LibraryB/**

LibraryA 中的标头搜索路径为 ./LibraryB/**

库搜索路径始终为空。

This is driving me crazy.

I have library A which in turn includes library B. The nested pair of libraries are used in 5 different projects. I want to have the source for A and B in a single place and link all 5 projects to them.

No matter what I do, I get one of two kinds of errors:

1) A class of library B colliding with itself. The linker sees said class in library A and also in library B.

2) Some classes missing, because the linker can't find them.

I should mention that library A includes categories. I am dealing with the category bug by having a dummy class in each category file and using the ObjC linker flag in the outer project.

Here is the setup I am trying to use. As described below, I get the duplicate symbols.

I have directories Documents/LibraryA, Documents/LibraryA/LibraryB, and Documents/Project1 through Documents/Project5.

The directory Documents/Project1 has a symlink LibraryA which points to ../LibraryA. The same holds true for projects 2 through 5.

Header search paths in the containing project are ./LibraryA ./LibraryA/Classes/** and ./LibraryA/LibraryB/**

Header search paths in LibraryA are ./LibraryB/**

Library search paths are always empty.

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

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

发布评论

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

评论(2

清风夜微凉 2024-12-07 20:40:36

随着复杂性/共享的增加,您意识到当库被大量重用时静态链接(同时保持理智)的方法是将链接过程(公开重用的图像)保存到最终可执行文件的链接阶段。

因此,静态库仅链接到私有内部库(通常在较小的代码库中找不到),而最终的可执行文件链接到每个公开可见的库(及其依赖项)。

这当然会在链接最终可执行文件时暴露依赖关系。

如果这些库可以分组,您还可以将它们合并到一个库中以创建元库,假设您确保元库的子库永远不会在它链接到的所有可执行文件的其他阶段中链接。

as complexity/sharing increases, you realize the way to link statically (while maintaining your sanity) when libraries are heavily reused is to save the link process (of the publicly reused images) for the final executable's link stage.

therefore, a static library links only to private internal libraries (not typically found in smaller codebases) while the final executable links to every publicly visible library (and their dependencies).

this will of course expose dependencies when linking the final executable.

if the libraries may be grouped, you may also merge them into one library to create a meta library, assuming you ensure the meta library's sub-libraries are never linked in other stages of all executables it links to.

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