How to enable Apple frameworks on Eclipse CDT

As an additional answer to another question , I recently asked, I understand that my problem is that I do not know how to include the Apple infrastructure in the Eclipse CDT project properties so that they are assembled and linked at compile time.

This leads to the fact that this form is not allowed:

#include <OpenCL/cl.h> 

If the actual path would be something like this:

 /System/Library/Frameworks/OpenCL.framework/Versions/A/Headers 

And the cmd line option would be (if I manually compiled):

 -framework OpenCL 

In short: How can I get Eclipse to view the frameworks I want from the project properties?

Any help is much appreciated!

+3
c ++ eclipse-cdt macos
source share
4 answers

An alternative answer to JohnIdol's question. In particular, an approach that may work if you do not want to change the <OpenCL/cl.h> link to <cl.h>

Firstly, I came to the site with this very question (how to incorporate Apple infrastructure in Eclipse CDT (C / C ++) projects), and I really appreciate the discussion - it gave me a starting point.

John's answer is cool, but it has to do with changing how the called file is called (for example, <OpenCL/cl.h> becomes <cl.h> in the code). He then makes a link to the direct path in the eclipse properties for each Header directory that he needs.

In my case, I checked the GNU Backgammon to play around with the source code. This code compiles (with some mods in LDFLAGS and CPPFLAGS before executing autogen.sh ) in the OS X CLI using the standard Apple I-guess approach of the -framework standard and with file links included, such as #include <CoreAudio/CoreAudioTypes.h>

I may never do anything, but I didn’t want to start hacking #includes in code that already compiles just fine using the standard approach. So I did the following:

  • Created a new directory in my gnubg workspace called "Frameworks".
  • Inside this directory, create soft links for the header directories.

     ln -s /System/Library/Frameworks/CoreAudio.framework/Headers CoreAudio 
  • In the project properties gnubg> C / C ++ General> Paths and symbols added /gnubg/Frameworks to Include directories (as the path to the workspace). I only had to do this once, regardless of the number of soft links I made.

Thus, I did not have to change the code at all, Eclipse was happy, the CLI compilation was also happy.

I note that there is a slight wrinkle if you use some directories in Frameworks, such as CoreServices.framework . In these cases, other included files (for example, .. ) have a Frameworks subdirectory and relative path links in some included files. Therefore, in this case, I had to slightly change the procedure. Basically, I had to add an additional subdirectory to Frameworks for CoreServices.framework , and then in this directory I had to add two soft links. One for CoreServices (for headers) and one for the 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 

Then I had to add /gnubg/Frameworks/CoreServices.framework to the inclusion path (step 3 above).
And so it is. No more file problems.

+7
source share

Since current releases of Eclipse CDT do not provide proper subclass header inclusion, you can avoid problems with the substructure (for example, created by CoreServices header files) by creating symbolic links to the include directories of each subframe. I elaborated on this question, which follows from the answer of the dhanhana in the following message:

http://thegreyblog.blogspot.com/2014/02/how-to-include-apple-frameworks-headers.html

To automate this process, I created a Z script shell that automates this process and creates a symbolic link in the specified framework header directory along with links to the include directory of each of its -frameworks routines. The script can be found here: https://github.com/emcrisostomo/link-osx-framework-headers

Hope this helps.

+1
source share

OK, so I had to include the following:

 #include <cl.h> 

Then add include to the folder with the header file in Properties> C / C ++ General> Paths and Symbols, as a result we get the following command for the compiler:

 -I/System/Library/Frameworks/OpenCL.framework/Versions/A/Headers 

And, most importantly, I had to add the following parameters to the library path and enable the framework in the section "Properties"> "C / C ++"> "Settings":

 -L/System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries -framework OpenCL 

The above trick.

0
source share

go to your project> Properties> Macro X C ++ Linker> Command Where "g ++" add "-framework OpenCL"

0
source share

All Articles