Version 11 (modified by bennylp, 15 years ago) (diff) |
---|
Building Application using PJSIP with GNU Tools
TracNav
Getting Started- Moved to: https://docs.pjsip.org/en/latest/index.html#get-started
Preparation
Build for Desktop
Build for Mobile
- iOS: Apple iPhone, iPad, and iPod Touch
- Android
- BlackBerry 10 (BB10)
- Windows Mobile
- Windows Phone 8.x and UWP
Symbian...
- Build for Other
Next: Using the libraries
See Also
- Requirements
- Steps for Building Your Application that Uses PJSIP/PJMEDIA
- Having Any Problems?
- Credits
Requirements
- GNU tools (GNU make, binutils, gcc, and the likes).
Steps for Building Your Application that Uses PJSIP/PJMEDIA
- First, build pjproject libraries as described in building for GNU systems. This normally is accomplished by executing these commands: $ ./configure && make dep && make
- Create a directory outside the PJSIP sources for your project and place your source files there.
- Create a file named Makefile in your source directory:
- If you have PJ version 1.6 or later, and you run make install, and you have pkg-config tool, you can use this template for your Makefile:
# If your application is in a file named myapp.cpp or myapp.c # this is the line you will need to build the binary. all: myapp myapp: myapp.cpp $(CC) -o $@ $< `pkg-config --cflags --libs libpjproject` clean: rm -f myapp.o myapp
- Otherwise if you have PJ version 0.5.10.2 or later, you can use this template for your Makefile:
#Modify this to point to the PJSIP location. PJBASE=/home/myself/pjproject-0.5.10.2 include $(PJBASE)/build.mak CC = $(PJ_CC) LDFLAGS = $(PJ_LDFLAGS) LDLIBS = $(PJ_LDLIBS) CFLAGS = $(PJ_CFLAGS) CPPFLAGS= ${CFLAGS} # If your application is in a file named myapp.cpp or myapp.c # this is the line you will need to build the binary. all: myapp myapp: myapp.cpp $(CC) -o $@ $< $(CPPFLAGS) $(LDFLAGS) $(LDLIBS) clean: rm -f myapp.o myapp
- Otherwise if you have PJ version 0.5.10.1 or older, you can use this template for your Makefile:
# Modify this to point to the PJSIP location. PJBASE=/home/myself/pjproject-0.5.10.1 include $(PJBASE)/build/mak CC=$(CROSS_COMPILE)$(CC_NAME) # Remove components that you don't need from the following definitions. LDFLAGS=-L${PJBASE}/pjlib/lib\ -L${PJBASE}/pjlib-util/lib\ -L${PJBASE}/pjmedia/lib\ -L${PJBASE}/pjsip/lib LDLIBS=-lpjsua-${TARGET_NAME}\ -lpjsip-ua-${TARGET_NAME}\ -lpjsip-simple-${TARGET_NAME}\ -lpjsip-${TARGET_NAME}\ -lpjmedia-codec-${TARGET_NAME}\ -lpjmedia-${TARGET_NAME}\ -lpjmedia-codec-${TARGET_NAME}\ -lpjlib-util-${TARGET_NAME}\ -lpj-${TARGET_NAME}\ -lm\ -lpthread\ -lasound\ -lssl CFLAGS=-I${PJBASE}/pjlib/include\ -I${PJBASE}/pjlib-util/include\ -I${PJBASE}/pjmedia/include\ -I${PJBASE}/pjsip/include\ -DPJ_AUTOCONF=1 CPPFLAGS=${CFLAGS} # If your application is in a file named myapp.cpp or myapp.c # this is the line you will need to build the binary. all: myapp myapp: myapp.cpp $(CC) -o $@ $< $(CPPFLAGS) $(LDFLAGS) $(LDLIBS) clean: rm -f myapp.o myapp
- If you have PJ version 1.6 or later, and you run make install, and you have pkg-config tool, you can use this template for your Makefile:
- There few things to note when making the Makefile above:
- First, make sure that you replace PJBASE with the location of PJSIP sources in your computer.
- If you notice there are spaces towards the bottom of the file (before $(CC) and rm, these are a single tab, not spaces. This is important, or otherwise make command will fail with "missing separator" error.
- Change myapp.cpp to your source filename.
- If you're using version 0.5.10.1 or older, then you may encounter link error with -lasound or -lssl. You may remove this from your Makefile (this is the limitation of 0.5.10.1 build system, which has been fixed in 0.5.10.2).
- Create myapp.cpp in the same directory as your Makefile. At minimum, it may look like this:
#include <pjlib.h> #include <pjlib-util.h> #include <pjmedia.h> #include <pjmedia-codec.h> #include <pjsip.h> #include <pjsip_simple.h> #include <pjsip_ua.h> #include <pjsua-lib/pjsua.h> int main() { return 0; }
- Last, run make in your source directory.
Having Any Problems?
If you're having any problems or encounter some errors with above instructions, first please watch carefully the error messages that are printed to the screen. The error messages printed by the gcc or make normally should contain useful information about the error and how to fix it.
If you like more help, you can report the error to PJSIP mailing list. Don't forget to include the details of the error (such as copy/paste the compiler command and error output), because without this we simply wouldn't know how to help!
Credits
Thanks Binu KS <binuks -at- gmail dot com> for the initial tutorial in the PJSIP mailing list.