如何链接".a"带有Apportable的fat-static-libs吗? [英] How to link ".a" fat-static-libs with Apportable?

查看:66
本文介绍了如何链接".a"带有Apportable的fat-static-libs吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将".a" fat-static-libs与Apportable链接?

一开始我确实得到了警告

警告:找不到库名的库名.尝试将其添加到 configuration.json的'add_params'部分中的'deps'数组 文件.检查〜/.apportable/SDK/System,以获取以下目录名称: 对应于"deps"条目.

我确实将其添加到 JSON 的"deps"中,其内容如下:

//依赖关系列表.通常,这些对应于xcode项目中的框架.

我的图书馆不是一个框架.它只是一个.a静态库,其中包含armv7,armv7s和i386部件,这些部件是我使用lipo从两个由此Boost框架.

将其添加到deps下可抑制该警告消息,但apportable链接器仍提供未定义的引用,因此仍未正确链接此文件.

现在,我知道Apportable必须重新抖动,由于Android不知道如何处理Mac可执行格式,因此它可能必须拆开我的库,并可能将其转换为解决方案

由于您得到未找到库",这意味着Apportable根本找不到该文件.因此,问题仅在于文件的位置(或存在),而不是库中的内容或构建方式.

与依赖目标有关的最常见问题,尤其是分别放置到其他Xcode项目和具有多个项目的工作区中的Xcode项目,是每个目标/项目的结果输出进入不同的文件夹.然后,Apportable(在某些情况下以及xcodebuild)都找不到结果库.

您应该尝试的第一步是确保设置了目标依赖关系.选择应用程序目标,转到 Build Phases 窗格,然后在 Target Dependencies 下添加列表中出现的,项目所依赖的所有框架和库.这应该确保确实构建了依赖的框架/库-因为据我所知,Xcode的内置自动依赖关系解析不适用于命令行工具.因此,您需要显式指定相关项目或它们的输出.

如果这没有帮助,则可以强制所有目标将其输出写入同一文件夹.在每个目标构建设置下,将构建产品路径(符号名称:SYMROOT)更改为同一文件夹,例如~/myprojectsbuildoutput

这样,即使依赖的其他项目也可以将其输出放置在同一文件夹中,并且xcodebuild和Apportable(取决于xcodebuild)也可以找到库文件.

提示:确保在命令行上成功构建项目.打开终端cd到.xcodeproj捆绑包所在的文件夹中,然后输入xcodebuild.如果xcodebuild仅由于验证而失败,请在应用程序目标的 Build Settings 下禁用 Validate Built Product .如果xcodebuild失败,则Apportable可能也不起作用,因为它取决于xcodebuild.因此,作为前提条件,请确保xcodebuild可在您的项目上使用.

如果xcodebuild还为您提供找不到库",请尝试使用特定的SYMROOT调用它:

xcodebuild SYMROOT=~/myprojectsbuildoutput

如果那行得通,您知道您必须更新每个目标的Build Projects Path.据我了解,目前尚无法(或未记录)通过Apportable传递自定义xcodebuild参数,因此需要在.xcodeproj本身中进行设置.

How do I link ".a" fat-static-libs with Apportable?

In the beginning, I did get a warning,

Warning: Library not found for lib-name. Try adding this to the 'deps' array in the 'add_params' section of your configuration.json file. Check ~/.apportable/SDK/System for the directory names that correspond to 'deps' entries.

I did add it to "deps" in the JSON right where it says this:

// A list of dependencies. Typically these correspond to frameworks in the xcode project.

My library isn't a framework, though. It's just a .a static library that has armv7, armv7s, and i386 parts which I assembled using lipo from two libraries (an armv7 and armv7s .a and a i386 .a) built with Xcode. They both use a single framework which is this Boost framework.

Adding it under deps squelched that warning message, but the apportable linker is still giving undefined references, so it is still not properly linking this file.

Now I know that Apportable has to re-jitter all this stuff, since Android won't know what to do with a Mac-executable format, so it's probably got to go pick apart my library and possibly turn it into an ELF-library before final linking. I'm not sure how to go about debugging this at this point, but is this supported at all?

解决方案

Since you get "library not found" that means Apportable simply can't find the file. Hence the problem is merely with the file's location (or existence) and not what's in the library or how it is built.

The most common issue with dependent targets, especially Xcode projects dropped into other Xcode projects respectively workspaces with multiple projects, is that the resulting output of each target/project goes to different folders. Then Apportable (as well as xcodebuild under some circumstances) can't find the resulting libraries.

First step you should try is to make sure that the target dependencies are set. Select the app target, go to the Build Phases pane and under Target Dependencies add all frameworks and libraries that appear in the list and that your project depends on. This should ensure that the dependent frameworks/libraries do get built - because Xcode's built-in automatic dependency resolution isn't available to command line tools from what I understand. So you need to explicitly specify the dependent projects respectively their output.

If that doesn't help, you can force all targets to write their output to the same folder. Under Build Settings for every target change the Build Products Path (symbolic name: SYMROOT) to the same folder, for example ~/myprojectsbuildoutput

That way even dependent other projects will place their output in the same folder and xcodebuild as well as Apportable (it depends on xcodebuild) will be able to find the library files.

Tip: make sure your project builds successfully on the command line. Open Terminal, cd into the folder where the .xcodeproj bundle is and enter xcodebuild. If xcodebuild fails merely due to validation, disable Validate Built Product under Build Settings of the app target. If xcodebuild fails, Apportable likely isn't going to work either because it depends on xcodebuild. So as a prerequisite make sure that xcodebuild works on your project.

If xcodebuild also gives you "library not found" try calling it with a specific SYMROOT:

xcodebuild SYMROOT=~/myprojectsbuildoutput

If that then works you know you have to update each target's Build Projects Path. From what I know it's not currently possible (or not documented) to pass custom xcodebuild parameters via Apportable, so it needs to be set up in the .xcodeproj itself.

这篇关于如何链接".a"带有Apportable的fat-static-libs吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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