14

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?

4 Answers 4

30

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.

9
  • 2
    This is simply one of the best answers i have seen on SO. Apr 8, 2014 at 13:31
  • 1
    @MrSMAK Thanks. It took a while for me to figure it out :)
    – Raja Rao
    Apr 9, 2014 at 3:28
  • 1
    @RajaRao yeah you right i missed something thanks ;) Jul 5, 2014 at 13:50
  • 3
    Got error :xcodebuild: error: SDK "iphoneos7.0" cannot be located. in terminal when ./build.sh
    – Hector
    Jan 15, 2015 at 14:58
  • 1
    @Hector, hey Hector, Can you explain what thing you changed in ./build.sh please? Sep 11, 2015 at 10:57
6

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.

5

I add relative path to "Header Search Paths", but there is still a error that is "not found".

Then, I add path to "User Header Search Paths", and it works.

May help you.

enter image description here

1
  • Did this also and it worked, then it seemed to remove itself from "User Header Search Paths"...strange. Thanks though for mentioning that.
    – Ser Pounce
    Aug 7, 2013 at 0:00
2

finally, I realized the KEY WORD is relative! I put GPUImage source files in my project root dir: enter image description here

before I solved the problem, I add Header Search Paths is:

$(PROJECT_DIR)/GPUImage/framework

$(PROJECT_DIR)/GPUImage/framework/iOS

and make them Recursive, but error is still there, So I changed Paths to:

GPUImage/framework and make it Recursive, then it works.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.