| 1 | = Building Application using PJSIP with GNU Tools = |
| 2 | |
| 3 | This article is a continuation of the '''Getting Started''' article as described in http://www.pjsip.org/using.htm. |
| 4 | |
| 5 | == Requirements == |
| 6 | |
| 7 | * This article is only valid with '''version 0.5.10.2''' release or later of the libraries. |
| 8 | * GNU tools (GNU make, binutils, gcc, and the likes). |
| 9 | |
| 10 | == Steps for Building Your Application that Uses PJSIP/PJMEDIA == |
| 11 | |
| 12 | 1. First, build {{{pjproject}}} libraries as described in http://www.pjsip.org/using.htm. This normally is accomplished by executing these commands: |
| 13 | {{{$ ./configure && make dep && make}}} |
| 14 | 1. Create a directory outside the PJSIP sources for your project and place your source files there. |
| 15 | 1. Create a file named '''Makefile''' in your source directory with the following content: |
| 16 | {{{ |
| 17 | #Modify this to point to the PJSIP location. |
| 18 | PJBASE=/home/myself/pjproject |
| 19 | |
| 20 | include $(PJBASE)/build.mak |
| 21 | |
| 22 | CC = $(APP_CC) |
| 23 | LDFLAGS = $(APP_LDFLAGS) |
| 24 | LDLIBS = $(APP_LDLIBS) |
| 25 | CFLAGS = $(APP_CFLAGS) |
| 26 | CPPFLAGS= ${APP_CXXFLAGS} |
| 27 | |
| 28 | # If your application is in a file named myapp.cpp or myapp.c |
| 29 | # this is the line you will need to build the binary. |
| 30 | all: myapp |
| 31 | |
| 32 | myapp: myapp.cpp |
| 33 | $(CC) -o $@ $(CPPFLAGS) $(LDFLAGS) $(LDLIBS) $< |
| 34 | |
| 35 | clean: |
| 36 | rm -f myapp.o myapp |
| 37 | }}} |
| 38 | 1. There few things to note when making the '''Makefile''' above: |
| 39 | 1. First, make sure that you replace '''PJBASE''' with the location of PJSIP sources in your computer, and |
| 40 | 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. |
| 41 | 1. Change {{{myapp.cpp}}} to your source filename. |
| 42 | 1. Create {{{myapp.cpp}}} in the same directory as your {{{Makefile}}}. At minimum, it may look like this: |
| 43 | {{{ |
| 44 | #include <pjlib.h> |
| 45 | #include <pjlib-util.h> |
| 46 | #include <pjmedia.h> |
| 47 | #include <pjmedia-codec.h> |
| 48 | #include <pjsip.h> |
| 49 | #include <pjsip_simple.h> |
| 50 | #include <pjsip_ua.h> |
| 51 | #include <pjsua-lib/pjsua.h> |
| 52 | |
| 53 | int main() |
| 54 | { |
| 55 | return 0; |
| 56 | } |
| 57 | }}} |
| 58 | 1. Last, run '''make''' in your source directory. |