Thursday 29 September 2011

Compiling PJSIP


Steps to Compile PJSIP latest version 1.10

STEP 1. Download source code from one of the following link :

http://www.pjsip.org/download.htm

http://trac.pjsip.org/repos/wiki/Getting-Started/Download-Source

STEP 2. Set your config_site.h to the following:

#define PJ_CONFIG_IPHONE 1 
#include <pj/config_site_sample.h>

The pjlib/include/pj/config_site.h contains local customizations to the libraries. The simplest way is just to create an empty file, to use whatever default values set by the libraries. Or copy and paste the config_site_sample.h file and delete all its content and copy above two lines.

This will activate iPhone specific settings in the config_site_sample.h.

Note: When the Makefile based build system is used, this process is taken care by the Makefiles. But when non-Makefile based build system (such as Visual Studio) is used, the config_site.h file must be created manually.
STEP 3. To Build PJSIP
Just run:
$ cd /path/to/your/pjsip/dir
$ ./configure-iphone

Their may be following problems:

  • Permission denied 
       Solution: login as super user using su command and the type following command
       $ su
       Password:
       # chmod 777 configure-iphone
       # exit

The permission to the file configure-iphone will be set as rwx (read-write-execute) for all.

  • Again running the ./configure-iphone may give following error 
        -bash: ./configure-iphone: /bin/bash^M: bad interpreter: No such file or directory

(This error may come because in the configure-iphone file every line may have been appended by a character $ or may be a carriage return symbol)
        To check this do as:
        - Run command
          $ vim configure-iphone
          (It wil open the vim editor)
          To see the last character press escape(ESC:)set list
          To quit vim press Esc:q

        - To Eliminate
           $ tr -d '\r' <configure-iphone >FILE.new
(It will create new file with name FILE. Now after that delete the configure-iphone file and rename FILE to configure-iphone using the following commands:)

         $ rm configure-iphone
         $ mv FILE.new configure-iphone
(Again confirm that new created file has 777 permission if no then assign from su- super user)

        - Again run
        $ ./configure-iphone

  • Again there may be error in ./aconfigure: Permission denied 
        Solution : Assign 777 permission to the whole folder.
       - $ cd .. (Go to the parent folder in which the PJSIP folder lies)
       - $ su (login as super user)
       - # chmod 777 * (It will assign 777 permission to the whole folder and its content)

Again run $ ./configure-iphone command. This time every thing should work fine.


STEP 4. After getting message "Done configuring for iPhoneOS4.1.sdk" run following command
     - $ make dep


STEP 5. If every thing is successfull then run following command

     - $ make

(After executing above 5 steps successfully the C files will produce the object .o files for pjlib,pjmedia,pjnath etc. and there .a liabraries that are included into the project and used.)

23 comments:

Anonymous said...

thanks. nice post. very very informative :)

Anonymous said...

The Post was very very useful...Thanks a lot buddy

Anonymous said...

Thank you very much. This helped a lot!

Anonymous said...

Love You Man, for the nice guide.
Thanks
Shahid Aslam
Pakistan

Unknown said...

One Question i am unable to build taht for armv7 or armv 6, i folowed this thread also [http://trac.pjsip.org/repos/wiki/Getting-Started/iPhone] but i didn't get this thread, can you explain this or resolve this problem

Thanks

Abhilash Reddy Kallepu said...

hii i have tried all the process which u have said still am getting the error access denied. please help me

Gaurav Kasliwal said...

On terminal login as super user using SUDO command and then give permission to you folder using chmod and then try again..It will help.

Anonymous said...

One stop shop to resolve all the chain of errors. Thanks for documenting this.

Anonymous said...

Thanks buddy...
Very very help full...

Лиза Сорвин said...

thank you
it saved me the time

Unknown said...

The most and very useful information thank u http://rfid4u.com/

Unknown said...

iPhone Tit Bits relted information thanku more information our site http://rfid4u.com/

Anonymous said...

Great job man, thanks a lot!

Unknown said...

Thanku so much... this is very helpful post.

But I will stuck on third step. I am facing this error after running ./configure-iphone:
./aconfigure: Permission denied
I tried the above steps you specified but it doesnt help me.

Please look into this :
./configure-iphone: line 147: ./aconfigure: Permission denied
WifiMacBook:pjproject-2.3 apple$ su
Password:
sh-3.2# chmod 777 configure-iphone
sh-3.2# exit
exit
WifiMacBook:pjproject-2.3 apple$ ./configure-iphone
configure-iphone: DEVPATH is not specified, using /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
configure-iphone: IPHONESDK is not specified, choosing iPhoneOS7.0.sdk
configure-iphone: CC is not specified, choosing /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/../../../Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
configure-iphone: ARCH is not specified, choosing -arch armv7
configure-iphone: CXX is not specified, using /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/../../../Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
configure-iphone: calling ./aconfigure with env vars:
CC = /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/../../../Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CXX = /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/../../../Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
SDKPATH = /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
CFLAGS = -O2 -Wno-unused-label -DPJ_SDK_NAME="\"iPhoneOS7.0.sdk\"" -arch armv7 -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk
LDFLAGS = -O2 -arch armv7 -isysroot /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -framework AudioToolbox -framework Foundation
AR = /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/../../../Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -o
RANLIB = echo ranlib
./configure-iphone: line 147: ./aconfigure: Permission denied


Thanks

Gaurav Kasliwal said...

To assign the permission you need to go to parent directory and need to write following command:

sh-3.2# chmod -R 777

-R is used to assign the recursive permission to all files and folders of that directory. (Please try with -r if -R do not works)

Unknown said...

Hey.. Gaurav i am able to build the necessary libraries. Can you please help me with the video streams in pjsip

Unknown said...

thank it save my life

Dhiren Shah said...
This comment has been removed by the author.
Dhiren Shah said...

First of all Thanks a lot Gaurav for sharing such a helpful post.

One question I have is after step 5, where will the libraries be residing to be used directly for iOS? Or is there any additional steps after that?

Thanks & Regards,

Gaurav@iPhone said...

Hi Dhiren,

Thanks for accessing the Post. All the libs reside in corresponding folder's lib folder. e.g. After compiling open pjsip folder and then click lib folder you will get libs for pjsip. Similarly for pjnath, pjmedia, third-party and so on. Get all libs together and all corresponding headers to use in ios app.

Dhiren Shah said...

Thanks a lot for prompt reply Gaurav.

Anonymous said...

Hi Gaurav,

i have download the pjsip project from https://www.pjsip.org/download.htm

And set-up all thing as per your instructions and create config_site.h

but when i hit the command ./configure-iphone, give error bash: ./configure-iphone: Permission denied

commands which i have run:-

Dharmender-pc:~ imark_ios$ cd /Users/imark_ios/Downloads/pjproject-2.8
Dharmender-pc:pjproject-2.8 imark_ios$ ./configure-iphone
-bash: ./configure-iphone: Permission denied
Dharmender-pc:pjproject-2.8 imark_ios$ su iMARK_IOS
Password:
bash-3.2$ # chmod 777 *
bash-3.2$ ./configure-iphone
bash: ./configure-iphone: Permission denied
bash-3.2$

Not understand what's going on, please suggest where i am wrong and what i should correct for resolve the issue.


Regards
Dharmendra

Anonymous said...

Hi Gourav,

Thank you for very informative post.

I have setup the environment and also able to run the make command.

After all these stuff I got some linker issue.


Showing All Issues
"_pjsip_register_method", referenced from:

Could you please help me to resolve all these issues. I'll be very appreciate for this.

Regards
Rohit