0

I am working with Openh264 library. I worked before with this library in Linux environment. But I haven't found any working documentation to link openh264 library on Xcode.

I have tried other solutions to add .a or .so library files in Xcode like: i) How to import a C++ library into a Xcode Objective C project? ii) How to link or load shared libraries (.so) in Objective C?

But Unfortunately I failed each time. I got OpenH264 from this link: https://github.com/cisco/openh264 . I can execute demo encoder decoder project which is given by Openh264 library but I need help to link this library in my own project. Thanks in advance.

Community
  • 1
  • 1
RajibTheKing
  • 1,234
  • 1
  • 15
  • 35
  • looks like you'll need to familiarize yourself with core concepts such as `make`. – The Paramagnetic Croissant Oct 07 '15 at 05:08
  • I have successfully executed Makefile to build OpenH264 on my Mac OS. – RajibTheKing Oct 07 '15 at 05:10
  • @RajubTheKing then what's the problem? The Makefile seems to specify that there's a static library being built, you can add it to your project just like you would add any other static library. – The Paramagnetic Croissant Oct 07 '15 at 05:12
  • I learned Make command from Openh264 library documentation. Make command is: " sudo make OS=ios ARCH=armv7 install ". I was able to build openh264 successfully and got all the library files(.dylib, .a etc). – RajibTheKing Oct 07 '15 at 05:13
  • I have linked .a file in this procedure: Project Navigator-->Build Phase-->Link Binary with Libraries-->Fetched libopenh264.a by finder and open I have also linked all the header files that were needed. But till I am not able to call library functions that was implemented in .a file. – RajibTheKing Oct 07 '15 at 05:20
  • meaning that you get compiler errors? Obviously you need the header files too, did you include those (and added to whatever the search path of your compiler happens to be)? – The Paramagnetic Croissant Oct 07 '15 at 05:42
  • Finally I have figured out the problem... thanks to @The Paramagnetic Croissant – RajibTheKing Oct 07 '15 at 09:19

1 Answers1

0

Here are the steps to integrate OpenH264 Library to any Xcode Project:

  1. Download or Clone OpenH264 Library from this link: https://github.com/cisco/openh264
  2. Create Xcode project selecting IOS Application, Objective C and other mandatory options.
  3. Place OpenH264 Library with all files and folders in project root directory. For example my IOS application is at directory /user/rajib/HelloApp/HelloApp.xcodeproj, and OpenH264 Library kept in /user/rajib/HelloApp/OpenH264Library .
  4. Now open terminal and enable root mode.
  5. Go to the directory where OpenH264Library was kept and make with following command: ->sudo make OS=ios ARCH=amrv7 install
  6. Now go to Project Build Setting and find Header Search Path attribute. Add following header paths in separate lines to that attribute. $(inherited), "$(SRCROOT)/OpenH264Library/codec/encoder/core/inc", "$(SRCROOT)/OpenH264Library/codec/processing/interface", "$(SRCROOT)/OpenH264Library/codec/common/inc", "$(SRCROOT)/OpenH264Library/codec/api/svc",
  7. Now we have to integrate 3 more Xcode Projects named common.xcodeproj, processing.xcodeproj, welsenc.xcodeproj inside our HelloApp project. All these .xcodeproj files will be found inside OpenH264Library. We have to find these .xcodeproj files with that name inside OpenH264Library and just drag and drop these files inside our HelloApp project.
  8. Now Go to Project Build Phase and find Target Dependencies attribute. Add welsenc, processing, common project from the work place.
  9. Try to build this project, then these 3 project will compile and execute and we will find 3 static library in our work place.
  10. Now go to project Build phase again and find Link Binary with Libraries attribute. Add libwelsenc.a, libprocessing.a, libcommon.a static libraries from the workplace.

That's it... this is the procedure of building and linking openh264 library. Now you can easily call openh264 library functions. Here I am giving a simple working code of Encoder initialization calling OpenH264 library function.

//Adding Header files
#include "codec_api.h"
#include "codec_def.h"

//Calling OpenH264 Library function to initialize Encoder
- (IBAction)EncoderTestBtn:(id)sender {
    NSLog(@"Inside EncoderTestBtn");
    ISVCEncoder *pEncoder = NULL;
    int iRet = -1;
    iRet = WelsCreateSVCEncoder(&pEncoder);
    if(iRet == 0)
    {
        NSLog(@"Rajib_Check: Encoder Initialization SUCCESSFUL");
    }
    else
    {
        NSLog(@"Rajib_Check: ERROR--> iRet returned with = %d", iRet);
    }

}
RajibTheKing
  • 1,234
  • 1
  • 15
  • 35