Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

objective c - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...