如何在Eclipse CDT上包含Apple的框架 [英] How to include Apple 'frameworks' on Eclipse CDT
问题描述
作为其他问题的后续动作我最近问,我意识到我的问题是,我不知道如何包括苹果的框架在Eclipse CDT项目属性,以便他们被拾起和链接在编译时。
As a follow up to another question I recently asked, I realize my issue is that I don't know how to include Apple 'frameworks' in the Eclipse CDT project properties so that they're picked up and linked at compile time.
这会导致此形式的包含无法解决:
This results in includes in this form not to be resolved:
#include <OpenCL/cl.h>
实际路径如下:
/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers
并且cmd行选项将是(如果我是手动编译):
And the cmd line option would be (if I was manually compiling):
-framework OpenCL
总之:我如何让Eclipse看到我想要的框架项目属性?
任何帮助非常感激!
推荐答案
p> JohnIdol的回答的另一个答案。特别是,一种方法可以在您不想将< OpenCL / cl.h>
引用更改为 ; cl.h>
An alternative answer to JohnIdol's answer. In particular, an approach that can work in the case that you don't want to change the <OpenCL/cl.h>
reference to <cl.h>
首先,我通过完全包括在Eclipse CDT(C / C ++)项目中的Apple框架),我非常感谢讨论 - 它给了我一个起点。
First, I came to the site with exactly this question in mind (how to include Apple 'frameworks' in Eclipse CDT (C/C++) projects) and I really appreciate the discussion - it gave me a starting point.
John的回答很酷,确实涉及改变包含文件的调用(例如,< OpenCL / cl.h>
变为< cl.h>
在代码中)。然后他在eclipse属性中为他需要的每个Header目录做一个直接的include-path引用。
John's answer is cool but it does involve changing how the include file is called (e.g., <OpenCL/cl.h>
becomes <cl.h>
in the code). Then he does a direct include-path reference in the eclipse properties for each Header directory he needs.
在我的例子中,我已经签出GNU西洋双陆棋源代码。这个代码在OS X CLI环境中使用I-guess标准的apple方法( autogen.sh
)编译(使用一些mods到LDFLAGS和CPPFLAGS) c $ c> -framework 选项和包含文件引用如
#include< CoreAudio / CoreAudioTypes.h>
In my case, I had checked-out GNU Backgammon to play around with the source code. This code compiles (with some mods to LDFLAGS and CPPFLAGS before doing the autogen.sh
) on the OS X CLI environment using the I-guess-standard apple approach of the -framework
option and with include files references like
#include <CoreAudio/CoreAudioTypes.h>
我可能永远不会提交任何东西,但是我不想开始使用标准方法来编译代码中的#include。所以我做了以下:
I may never actually commit anything but I didn't want to start hacking the #includes in code that is already compiling just fine using the standard approach. So I did the following:
- 在我的工作区gnubg中创建了一个名为Frameworks的新目录。
- Made a new directory in my workspace gnubg called "Frameworks".
Inside that directory, make soft-links to the header directories.
ln -s /System/Library/Frameworks/CoreAudio.framework/Headers CoreAudio
gnubg项目属性> C / C ++常规>路径和符号,将 / gnubg / Frameworks
添加到Include目录(作为工作空间路径)。
In the gnubg project properties > C/C++ General> Paths and Symbols, added /gnubg/Frameworks
to the Include directories (as a workspace path). I only had to do this once, regardless of the number of soft links I made.
这种方式我没有必须更改代码,Eclipse很高兴,CLI编译也很高兴。
This way I did not have to change the code at all, Eclipse was happy, CLI compilation was happy as well.
我注意到,如果在Frameworks中使用一些目录, CoreServices.framework
。在这些情况下,在一些包含文件(例如 ..
)中有一个Frameworks子目录和相对路径引用到其他包含文件。所以在这种情况下,我不得不修改程序一点。基本上,我不得不在框架 CoreServices.framework
中添加一个子目录,然后在该目录中添加两个软链接。一个用于CoreServices(用于标题),另一个用于Framework子目录。
I note that there is a slight wrinkle if using some directories in Frameworks such as the CoreServices.framework
. In those cases there is a Frameworks subdirectory and relative path references in some of the include files (e.g., ..
) to other include files. So in this case I had to modify the procedure a bit. Basically, I had to add an additional sub-directory in Frameworks for CoreServices.framework
and then in that directory I had to add two soft links. One for the CoreServices (for the Headers) and one for Framework subdirectory.
lrwxr-xr-x 1 dhansen staff 57B Jul 27 02:06 CoreServices -> /System/Library/Frameworks/CoreServices.framework/Headers
lrwxr-xr-x 1 dhansen staff 60B Jul 27 02:05 Frameworks -> /System/Library/Frameworks/CoreServices.framework/Frameworks
然后我不得不添加 /gnubg/Frameworks/CoreServices.framework
到包含路径(上面的步骤3)。
就是这样。没有更多的文件问题。
Then I had to add /gnubg/Frameworks/CoreServices.framework
to the include path (step 3 above).
And that's it. No more include file problems.
这篇关于如何在Eclipse CDT上包含Apple的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!