在编写CodeRunner文档时如何包含非框架库? [英] How can I include non-framework libraries when writing CodeRunner documents?

查看:152
本文介绍了在编写CodeRunner文档时如何包含非框架库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 CodeRunner 收集开发过程中经常使用的一小段代码, t必须属于项目的代码库。这是一个伟大的工具,总结在Objective-C和Cocoa,因为我可以包括安装在我的机器上的框架。

I've been using CodeRunner to collect little chunks of code that are frequently used while developing but don't necessarily belong in the codebase for a project. It's a great tool for summarizing in Objective-C and Cocoa because I can include frameworks that are installed on my machine.

然而,有时我想包括外部源的功能它们不是框架,例如ASIHTTPRequest。如果我把ASIHTTPRequest文件放在附近的一个文件夹和 #include 他们,我得到关于的错误未定义的符号架构x86_64:_OBJC_CLASS _ $ _ ASIHTTPRequest这是我假设意味着ASI文件根本没有被编译和链接与CodeRunner doc - 这是一个单一的文件正在编译,而不是一个项目。在Xcode中,我会将ASIHTTPRequest文件添加到项目中,并且它们将被自动编译并与其他代码链接,当我不使用Xcode时,什么是等价的?

However, sometimes I want to include functionality from external sources that aren't frameworks, such as ASIHTTPRequest. If I place the ASIHTTPRequest files in a folder nearby and #include them, I get errors about "Undefined symbols for architecture x86_64: _OBJC_CLASS_$_ASIHTTPRequest" which I'm assuming means that the ASI files simply aren't being compiled and linked with the CodeRunner doc - this is a single file being compiled, not a project. In Xcode I would add the ASIHTTPRequest files to the project and they would automatically be compiled and linked with the rest of the code, what is the equivalent when I'm not using Xcode?

我可以包括自定义参数和编译标志(后者包含 -std = c99 -framework Foundation 默认),我怀疑我必须调整这些不知何故,但我避风港已经能够找到如何。

I can include custom arguments and compilation flags (the latter contains -std=c99 -framework Foundation by default) and I suspect I have to tweak these somehow but I haven't been able to find out how.

推荐答案

我得到它的工作。 gcc需要一些额外的参数链接到ASIHTTP模块,当然。这是我结束了:

I got it to work. gcc requires some additional parameters to link to the ASIHTTP modules, of course. Here's what I ended up with:

-std=c99 -framework SystemConfiguration -framework CoreServices -framework Foundation -lz -I/path/to/asi-header-files -filelist /path/to/list-of-asi-compiled-modules

我想你的代码只是包括ASIHTTPRequest.h等头文件的路径...如果你使用显式路径,你不需要上面的-I开关。 gcc确实需要有一个编译版本的代码从ASIHTTPRequest.m和朋友链接它。一种方法是编译库中的Mac项目。这将产生.x文件在其中一个深埋DerivedData目录Xcode喜欢做。它为我创造的是:

I imagine your code was just including paths to the ASIHTTPRequest.h, etc. header files... if you're using explicit paths there, you don't need the -I switch above. gcc does need to have a compiled version of the code from ASIHTTPRequest.m and friends to link with it. One way to do that is to compile the "Mac" project that comes with the library. That will produce .o files in one of those deeply-buried "DerivedData" directories Xcode likes to make. The one it made for me is:

~/Library/Developer/Xcode/DerivedData/Mac-flsjygxmngizhzfwnfgcakejmwkx/Build/Intermediates/Mac.build/Debug/Mac.build/Objects-normal/x86_64

(Mac-flsjygxmngizhzfwnfgcakejmwkx 位将不同,我想象。)在该目录中,有一堆.o文件和一个'Mac.LinkFileList'文件。这个文件是你给gcc的-filelist参数。您需要删除对main.o,AppDelegate.o和ASIWebPageRequest.o文件的引用,以便在链接步骤期间不会出现重复的符号错误。

(The "Mac-flsjygxmngizhzfwnfgcakejmwkx" bit will differ for you, I imagine.) In that directory, there are a bunch of .o files and a 'Mac.LinkFileList' file. This file is the one you'd give for the -filelist parameter to gcc. You'll need to remove references to the main.o, AppDelegate.o and ASIWebPageRequest.o files so you don't get duplicate symbol errors during the link step.

除了ASIHTTPRequest标头和.o文件,gcc将期望与SystemConfiguration,CoreServices框架和zlib库链接,因为ASIHTTPRequest具有这些依赖关系。

In addition to the ASIHTTPRequest header and .o files, gcc will expect to link with the SystemConfiguration, CoreServices frameworks and the zlib library, since ASIHTTPRequest has those dependencies.

如果你使用这个库进行大量测试,我建议将Objective-C语言定义(在首选项下)复制为带有ASIHTTPRequest的Objective-C或其他东西。然后你可以自定义编译标志来运行ASIHTTPRequest,而不是为你运行的所有Objective-C代码。

If you're doing lots of tests with this library, I would recommend duplicating the "Objective-C" language definition (under Preferences) as "Objective-C with ASIHTTPRequest" or something. Then you can customize the compilation flags for running against ASIHTTPRequest without making it do that for all Objective-C code you run.

您可能还想复制.o文件和LinkFileList文件到一个更永久的地方,只是为了防止Xcode清除该构建树或某事。

You may also want to copy the .o files and the "LinkFileList" file to a more permanent place, just in case Xcode cleans that build tree away or something.

这篇关于在编写CodeRunner文档时如何包含非框架库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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