Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I do if I can't find the GPUImage.h header for the GPUImage framework?

I have created a sample application to perform bump distortion, using the GPUImage framework. I added this framework to my application, but I'm seeing the following error

Lexical or preprocessor issue 'GPUImage.h' file not found.

I have added the -ObjC flag to the Other Linker Flags, but I'm still seeing this error. How can I solve this problem and get my application to compile?

like image 745
user1365602 Avatar asked Apr 30 '12 10:04

user1365602


2 Answers

Adding GPUImage framework to XCode project could be tricky. So I haved added detailed step-by-step instructions w/ images on how to do it.

Static Compilation Method (detailed solution so we don't mess up)

This is Static compilation method. In this basically we will compile the framework using ./build.sh file. And simply add it to our XCode project, then configure XCode to properly use it.

  1. Download GPUImage from Github and extract it (or just clone it).
  2. Go to the GPUImagefolder in terminal
  3. Run ./build.sh

    Note: This will compile and create ready-to-use binary for all the sdks on your mac.

  4. build.sh creates a folder called build and generates compiled binaries and dumps them to folders like: Release-iPhone, Release-iPhoneOS, Release-iphonesimulator etc folders. enter image description here

  5. For iPhone use Release-iphone (This also works for simulator).
  6. Copy (not drag-drop) Release-iphone to your XCode project's root directory so that we have a local copy of framework.
  7. Now iPhone drag-and-drop Release-iphone onto your XCode project. Make sure to check "Copy to .." option.

    Note:

    • This Release-iphone folder contains two sub-folders: include and lib
    • include folder contains all the header .h files
    • lib folder contains compiled binary version file called libGPUImage.a
    • We now need to simply configure XCode to use .h and .a files.**
  8. Select your project in the project explorer > Project name under Targets > select Build Phases > Expand Link Binary With Libraries

  9. Add the libGPUImage.a to Link Binary With Libraries section. You may want to Right-click on libGPUImage.a then Open in Finder and finally drag-drop it.

  10. While we are at it, also add the following GPUImage's dependent frameworks/ libraries CoreMedia, CoreVideo, OpenGLES, AVFoundation, QuartzCore to Link Binary With Libraries section enter image description here

  11. Now, lets configure .h headers.

  12. Select your project in the project explorer > Project name under Targets > select Build Settings > and type search paths to see search paths section.

  13. Open Headers Search Paths by clicking on the value field.

  14. Drag-and-drop the lib folder to that popup. Note: If it shows absolute path, change it to looks $(SRCROOT)/path/to/lib/. (You should have the framework relative to your xcode project see step 6).

  15. Repeat 11 & 12 for Library Search Paths as well.

enter image description here Additional tips: You can add .h files to Library Search Paths or Headers Search Paths, you can make them Recursive. I have a main root-folder called Dependencies folder where I keep all the dependencies like MySDK-framework including Release-iPhone. And I just have one search-path at the Dependencies (root folder) and made it recursive.

like image 65
Raja Rao Avatar answered Sep 28 '22 19:09

Raja Rao


Did you follow all of the instructions from the Readme on the project page? From the installation instructions:

You'll also need to find the framework headers, so within your project's build settings set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the GPUImage source directory. Make this header search path recursive.

If you're seeing the above error, it means that you did not point the Header Search Paths at the right directory where you've installed GPUImage relative to your project, and / or did not click the checkbox to the left to make those search paths recursive.

I show some screenshots of where you need to go to set this in this answer, which explains something similar for the Core Plot framework. The same principles apply, only you need to find where you installed the GPUImage framework at.

like image 31
Brad Larson Avatar answered Sep 28 '22 19:09

Brad Larson