X code自定义生成配置导致"库/找不到文件"对于静态库 [英] Xcode custom build configuration causes "library/file not found" for static libraries

查看:207
本文介绍了X code自定义生成配置导致"库/找不到文件"对于静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有其与在另一项目中的静态库(这也是在工作区)链接的一个项目的工作空间。它在 Kobold2D 一个问题,我一直没能解决的,尽管我理解的原因,我想这是<一个href=\"http://stackoverflow.com/questions/8152573/x$c$c-4-build-static-library-dependency-with-different-configuration-setting\">similar对这个问题。

I have a workspace with a project which links with the static libraries in another project (which is also in the workspace). It's a problem in Kobold2D I haven't been able to resolve, even though I understand the cause, and I suppose it's similar to this question.

该项目的目标和静态库的目标都在调试发布生成配置。一切都很好。

The project targets and the static library targets all have the Debug and Release build configurations. All is well.

现在有人在项目和名称添加一个新的构建配置它的特设作为例子。目前该项目的目标建立在特设的配置,但是静态库有没有这样的配置。显然,他们则默认为构建在发布配置。

Now someone adds a new build configuration in the project and names it Ad-Hoc for example. Now the project's target builds the Ad-Hoc configuration, however the static libraries have no such configuration. Apparently they then default to building the Release configuration.

最后,当链接应该把一切融合在一起,它失败:

At the end, when the linker is supposed to bring everything together, it fails:

ld: library not found for -lbox2d-ios
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ failed with exit code 1

对于通过 -force_load $强行加载库(BUILT_PRODUCTS_DIR)/libSomeLib.a 错误的是类似的,但说找不到文件。我要指出,该库libbox2d-ios.a是在链接二进制与图书馆建设阶段名单。

For forcibly loaded libraries via -force_load $(BUILT_PRODUCTS_DIR)/libSomeLib.a the error is similar but says "file not found". I should note that the library "libbox2d-ios.a" is in the "link binary with libraries" build phase list.

显然的问题是,链接器假定库在特设-的iPhoneOS 文件夹中的BUILT_PRODUCTS_DIR,而他们实际上是在发布-的iPhoneOS 文件夹,因为他们没有的特设构建配置。

Obviously the problem is that the linker is assuming that the libraries are in the Ad-Hoc-iphoneos folder in the BUILT_PRODUCTS_DIR while they are actually in the Release-iphoneos folder because they have no Ad-Hoc build configuration.

我怎样才能耳光连接器,并告诉他让他们在哪里库? preferably我正在寻找这两种情况下有效的解决方案,即库补充说,需要一个额外的-force_load工作的标准方式(链接二进制与图书馆建设阶段)和库。

How can I slap the linker in the face and tell him to get the libraries where they are? Preferably I'm looking for a solution that works for both cases, ie libraries added the standard way (link binary with libraries build phase) and libraries that need an additional -force_load to work.

我希望有一些方法为:


  • 力库放置在应用程序的目标生成配置文件夹

  • 运行后的编译和放大器; pre-链接脚本,每个副本库生成配置文件夹

  • 指定到库的相对路径

  • 使用超过$ BUILT_PRODUCTS_DIR其他不同的宏-force_load

  • 链接器标志一样-WTFmake-所有问题-GO-离开

对不起,但我不得不说这... 哎呀:!)

Excuse me, but I have to say this … ARGH! :)

推荐答案

我还没有找到一个办法做到这一点,很遗憾。我能找到最好的解决方法是添加新的目标,而不是新的构建配置。因此,例如在我的项目之一,我只有发布和调试配置,但我有一个名为额外的目标MyProject的 - 应用程序商店和MyProject的 - 特设。这只会是可能的,如果你有项目文件的控制,当然。

I have not found a way to do this, unfortunately. The best workaround I can find is to add new targets rather than new build configurations. So for example in one of my projects I have only Release and Debug configurations, but I have extra targets called "MyProject - app store" and "MyProject - ad hoc". This will only be possible if you have control of the project file, of course.

已经复制目标围坐在极端讨厌的,因为你可以将文件添加到一个目标,而忘记将它们添加到别人,你不会知道,直到你尝试构建它。但它确实建立,这是一个双赢(其中x code无论如何)。

Having duplicated targets sitting around is annoying in the extreme because you can add files to one target and forget to add them to the others, and you won't know until you try and build it. But it does build, which is a win (with xcode anyhow).

有一个类似的问题,我问前一阵子:<一href=\"http://stackoverflow.com/questions/5958379/what-is-the-correct-way-to-set-build-configurations-in-an-ios-project-using-stat/\">What是设置生成使用静态库在IOS项目配置创建以x code存档的正确方法4?

A similar question I asked a while ago: What is the correct way to set build configurations in an ios project using static libraries for creating an archive in xcode 4?

这篇关于X code自定义生成配置导致&QUOT;库/找不到文件&QUOT;对于静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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