= Building Application using PJSIP with GNU Tools = This article is a continuation of the '''Getting Started''' article as described in http://www.pjsip.org/using.htm. == Requirements == * GNU tools (GNU make, binutils, gcc, and the likes). == Steps for Building Your Application that Uses PJSIP/PJMEDIA == 1. First, build {{{pjproject}}} libraries as described in http://www.pjsip.org/using.htm. This normally is accomplished by executing these commands: {{{$ ./configure && make dep && make}}} 1. Create a directory outside the PJSIP sources for your project and place your source files there. 1. Create a file named '''Makefile''' in your source directory. 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 include $(PJBASE)/build.mak CC = $(APP_CC) LDFLAGS = $(APP_LDFLAGS) LDLIBS = $(APP_LDLIBS) CFLAGS = $(APP_CFLAGS) CPPFLAGS= ${APP_CXXFLAGS} # 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 }}} 1. 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/tarani/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 }}} 1. There few things to note when making the '''Makefile''' above: 1. First, make sure that you replace '''PJBASE''' with the location of PJSIP sources in your computer. 1. 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. 1. Change {{{myapp.cpp}}} to your source filename. 1. 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). 1. Create {{{myapp.cpp}}} in the same directory as your {{{Makefile}}}. At minimum, it may look like this: {{{ #include #include #include #include #include #include #include #include int main() { return 0; } }}} 1. 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 for the initial tutorial in the PJSIP mailing list.