简体   繁体   English

设置包括mac os中的eclipse CDT中的路径(来自框架的头文件)

[英]setup include path in eclipse CDT in mac os (headers from framework)

for example I need to include a header 例如,我需要包含一个标题

#include <OpenGL/glext.h>

while it is actually a header file glext.h under OpenGL.framework/Headers/. 虽然它实际上是OpenGL.framework / Headers /下的头文件glext.h。 Therefore it is no way to give eclipse a physical path about "OpenGL/glext.h", and I always get unresolved inclusion warning. 因此,没有办法给eclipse一个关于“OpenGL / glext.h”的物理路径,而且我总是得到未解决的包含警告。

I can still build and run them (with managed makefile project) but it is impossible to browse the functions or definitions from those "resolved" header files. 我仍然可以构建和运行它们(使用托管的makefile项目)但是不可能从那些“已解析”的头文件中浏览函数或定义。

is there any solution? 有什么办法吗?

While not ideal, my solution to this has been to create a folder "/Developer/Framework Headers" (though the name isn't important), and link from eg "/System/Library/Frameworks/Foo.framework/Headers" to "Foo" under said folder. 虽然不理想,但我的解决方案是创建一个文件夹“/ Developer / Framework Headers”(尽管名称并不重要),并从例如“/System/Library/Frameworks/Foo.framework/Headers”链接到所述文件夹下的“Foo”。 Then in Eclipse I add "/Developer/Framework Headers" to a project's includes. 然后在Eclipse中,我将“/ Developer / Framework Headers”添加到项目的includes中。

I say not ideal because apart from having to create links for the frameworks you need and add an include to each project, Eclipse seems to have trouble in certain cases such as nested frameworks (eg CoreGraphics beneath ApplicationServices), but YMMV. 我说不理想,因为除了必须为你需要的框架创建链接并为每个项目添加一个包,Eclipse似乎在某些情况下遇到麻烦,例如嵌套框架(例如ApplicationServices下的CoreGraphics),但是YMMV。

Yes there is one. 是的,有一个。 Right click on the project in "Project Explore" window and click on the "property". 在“Project Explore”窗口中右键单击项目,然后单击“属性”。 In there Open "C/C++ General" column and choose "Path and symbols". 在那里打开“C / C ++ General”列并选择“Path and symbols”。 Now you see all of the include library path for this project. 现在,您将看到此项目的所有包含库路径。 If your using C then add the OpenGL library into GNU C, or if you use C++ then add it into GNU C++. 如果您使用C然后将OpenGL库添加到GNU C中,或者如果您使用C ++,则将其添加到GNU C ++中。 Unfortunately you have to do this for every new project. 不幸的是,你必须为每个新项目执行此操作。 I have been searching for a while how to do this by default but nothing really useful. 我一直在寻找一段时间如何默认这样做,但没有什么真正有用。 Hope this help you get rid of those annoying yellow wave lines. 希望这可以帮助你摆脱那些恼人的黄色波浪线。

Since current Eclipse CDT releases don't perform sub-framework header inclusion correctly, you can avoid sub-framework problems (like those generated by the CoreServices header files) by creating symbolic links to the include directories of each sub-framework. 由于当前的Eclipse CDT版本没有正确执行子框架头部包含,因此可以通过创建指向每个子框架的include目录的符号链接来避免子框架问题(如CoreServices头文件生成的问题)。 I elaborated on this subject, which stems from danhan answer on this question , in this blog post. 我在这篇博客文章中详细阐述了这个问题, 这个问题源于danhan对这个问题的回答。

In order to automate this process, I've created a Z shell script which automates this process and creates the symlink to the specified frameworks' header directory, together with the links to the include directory of each one of their sub-frameworks. 为了自动完成这个过程,我创建了一个Z shell脚本,它自动执行这个过程,并创建指定框架的头目录的符号链接,以及指向每个子框架的include目录的链接。 The script can be found in this GitHub repository . 该脚本可以在此GitHub存储库中找到。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM