blob: ee4d83cfb083ba6265a3ae417b897b95d99b080e [file] [log] [blame]
Benny Prijono10a20802006-03-02 21:52:18 +00001
Benny Prijonoc3416832006-09-12 18:58:19 +00002
3Getting Started: Building and Using PJSIP and PJMEDIA
4[Last Update: 12/Sept/2006]
5
6 This article describes how to get, build, and use the open source PJSIP and
7 PJMEDIA SIP and media stack. You can get the online (and HTML) version of
8 this file in http://www.pjsip.org/using.htm
Benny Prijonodb419fd2006-03-05 11:54:33 +00009
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000010
Benny Prijonoc3416832006-09-12 18:58:19 +000011If you're so impatient..
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000012
Benny Prijonoc3416832006-09-12 18:58:19 +000013 If you just want to get going quickly (and maybe read this document later),
14 this is what you can do to build the libraries:
15
16 Building with GNU tools
17 Just do:
18
19 $ ./configure
20 $ make dep && make clean && make
21
22 Building with Microsoft Visual Studio
23 Just follow the following steps:
24
25 1. Open pjsip-apps/build/pjsip_apps.dsw workspace,
26 2. Create an empty pjlib/include/pj/config_site.h, and
27 3. build the pjsua application.
28
29 Building for Windows Mobile
30 Just follow the following steps:
31
32 1. Open pjsip-apps/build/wince-evc4/wince_demos.vcw EVC4 workspace,
33 2. Create an empty pjlib/include/pj/config_site.h, and
34 3. build the pjsua_wince application.
35
36 With all the build systems, the output libraries will be put in lib
37 directory under each projects, and the output binaries will be put in bin
38 directory under each projects.
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000039
40
Benny Prijonoc3416832006-09-12 18:58:19 +000041Table of Contents:
42 _________________________________________________________________
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000043
Benny Prijonoc3416832006-09-12 18:58:19 +000044 1. Getting the Source Distribution
45
46 1.1 Getting the Release tarball
47
48 1.2 Getting from Subversion trunk
49
50 1.3 Source Directories Layout
51
52 2. Build Preparation
53
54 2.1 config_site.h file
55
56 2.2 Disk Space Requirements
57
58 3. Building Linux, *nix, *BSD, and MacOS X Targets with GNU Build Systems
59
60 3.1 Supported Targets
61
62 3.2 Requirements
63
64 3.3 Running configure
65
66 3.4 Running make
67
68 3.5 Cross Compilation
69
70 4. Building for Windows Targets with Microsoft Visual Studio
71
72 4.1 Requirements
73
74 4.2 Building the Projects
75
76 4.3 Debugging the Sample Application
77
78 5. Building for Windows Mobile Targets (Windows CE/WinCE/PDA/SmartPhone)
79
80 5.1 Requirements
81
82 5.2 Building the Projects
83
84 6. Using PJPROJECT with Your Applications
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000085
86
Benny Prijonoc3416832006-09-12 18:58:19 +000087 Appendix I: Common Problems/Frequently Asked Question (FAQ)
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000088
Benny Prijonoc3416832006-09-12 18:58:19 +000089 I.1 fatal error C1083: Cannot open include file: 'pj/config_site.h':
90 No such file or directory
91
92
931. Getting the Source Code Distribution
94 _________________________________________________________________
95
96 Since all libraries are released under Open Source license, all source code
97 are available for your scrutinizing pleasure.
98
99 All libraries (PJLIB, PJLIB-UTIL, PJSIP, PJMEDIA, and PJMEDIA-CODEC) are
100 currently distributed under a single source tree, collectively named as
101 PJPROJECT or just PJ libraries. These libraries can be obtained by either
102 downloading the release tarball or getting them from the Subversion trunk.
103
104
1051.1 Getting the Release tarball
106 _________________________________________________________________
107
108 Getting the released tarball is a convenient way to obtain stable version of
109 PJPROJECT. The tarball may not contain the latest features or bug-fixes, but
110 normally it is considered more stable as it will be tested more rigorously
111 before it is released.
112
113 You can get the latest released tarball from the
114 http://www.pjsip.org/download.htm.
115
116
1171.2 Getting from Subversion trunk
118 _________________________________________________________________
119
120 You can always get the most up-to-date version of the sources from the
121 Subversion trunk. However, please bear in mind that the sources in the
122 Subversion trunk may not be the most stable one. In fact, it may not even
123 compile for some particular targets, because of the time lag in the updating
124 process for all targets. Please consult the mailing list if you encounter
125 such problems.
126
127 Using Subversion also has benefits of keeping your source up to date with
128 the main PJ source tree and to track your changes made to your local copy,
129 if any.
130
131
132What is Subversion
133
134 Subversion is Open Source version control system similar to CVS. Subversion
135 homepage is in http://subversion.tigris.org/
136
137
138Getting Subversion Client
139
140 Before you can download the PJ source files from pjsip.org SVN tree, you
141 need to install a Subversion client. You can download binaries from
142 http://subversion.tigris.org/ and follow the instructions there.
143 Subversion clients are available for Windows, Linux, MacOS X, and many more
144 platforms.
145
146
147Getting the Source for The First Time
148
149 Once Subversion client is installed, you can use these commands to initially
150 retrieve the latest sources from the Subversion trunk:
151
152 $ svn co http://svn.pjproject.net/repos/pjproject/trunk pjproject
153 $ cd pjproject
154
155
156Keeping Your Local Copy Up-to-Date
157
158 Once you have your local copy of the sources, you will want to keep your
159 local copy up to date by periodically synchronizing your source with the
160 latest revision from the Subversion trunk. The mailing list provides best
161 source of information about the availability of new updates in the trunk.
162
163 You can use these commands to synchronize your copy with the main trunk:
164
165 $ cd pjproject
166 $ svn update
167
168
169Tracking Local and Remote Changes
170
171 In general, it is not recommended to keep your local changes (to the library
172 source codes) for a long time, because the longer you keep your changes, the
173 more chances that your source will be out-of-sync with the main PJ source
174 tree (the trunk), because the trunk may be updated to support new features
175 or to fix some bugs.
176
177 The best way to resolve this is to send your modification back to the
178 author, so that he can change the copy in the SVN trunk.
179
180 To see what files have been changed locally:
181
182 $ cd pjproject
183 $ svn status
184
185 The above command only compares local file against the original local copy,
186 so it doesn't require Internet connection to perform the check.
187
188 To see what files have been changed both locally and remotely:
189
190 $ cd pjproject
191 $ svn status -u
192
193 Note that svn status -u requires Internet connection to the SVN tree.
194
195
1961.3 Source Directories Layout
197 _________________________________________________________________
198
199Top-Level Directory Layout
200
201 The top-level directories (denoted as $PJ here) in the source distribution
202 contains the sources of individual libraries:
203
204 $PJ/build
205 Contains makefiles that are common for all projects.
206
207 $PJ/pjlib
208 Contains PJLIB header and source files.
209
210 $PJ/pjlib-util
211 Contains PJLIB-UTIL header and source files.
212
213 $PJ/pjmedia
214 Contains PJMEDIA and PJMEDIA-CODEC header and source files.
215
216 $PJ/pjsip
217 Contains PJSIP header and source files.
218
219 $PJ/pjsip-apps
220 Contains source code for PJSUA and samples applications.
221
222
223Individual Directory Inside Each Project
224
225 The directories inside each project (for example, inside pjlib, pjmedia, or
226 pjsip) further contains some sub-directories below:
227
228 bin
229 Contains binaries produced by the build process. The contents of this
230 directory will not get synchronized with the SVN trunk.
231
232 build
233 Contains build scripts/makefiles, project files, project workspace,
234 etc. to build the project. In particular, it contains one Makefile
235 file to build the project with GNU build systems, and a *.dsw
236 workspace file to build the library with Microsoft Visual Studio 6 or
237 later.
238
239 build/output
240 The build/output directory contains the object files and other files
241 generated by the build process.
242
243 build/wince-evc4
244 This directory contains the project/workspace files to build Windows
245 CE/WinCE version of the project using Microsoft Embedded Visual C++
246 4.
247
248 docs
249 Contains Doxygen configuration file (doxygen.cfg) to generate online
250 documentation from the source files. The output documentation will be
251 put in this directory as well (for example, docs/html directory for
252 the HTML files).
253
254 include
255 Contains the header files for the project.
256
257 lib
258 Contains libraries produced by the build process.
259
260 src
261 Contains the source files of the project.
262
263
2642. Build Preparation
265 _________________________________________________________________
266
2672.1 config_site.h file
268 _________________________________________________________________
269
270 Before you can compile and use the libraries, you need to create your
271 config_site.h MANUALLY.
272
273 (Sorry to write in red background, but this question comes out quite often
274 so I thought it's worth to put some punctuation)
275
276Q: What is config_site.h File
277
278 The pjlib/include/pj/config_site.h contains your local customizations to the
279 libraries.
280
281Q: Why do we need config_site.h file
282
283 You should put your customization in this file instead of modifying PJ's
284 files, because if you modify PJ's files, then you will prevent those
285 modified files from being updated next time you synchronize your local copy
286 to the SVN trunk. Or even worse, you may accidently overwrite your local
287 modification with the fresh copy from the SVN.
288
289 Putting your local customization to the config_site.h solves this problem,
290 because this file is not included in the version control.
291
292Q: What customizations can be put in config_site.h file
293
294 You can put your #define macros in this file. You can find list of
295 configuration macros that you can override by scanning:
296 * pjlib/config.h file
297 * pjmedia/config.h file
298 * pjsip/sip_config.h file
299
300 You can also see a sample config_site.h file in
301 pjlib/include/config_site_sample.h.
302
303Q: How to create config_site.h file
304
305 The simplest way is just to create an empty file.
306
307 Another way to create your config_site.h is to write something like this:
308
309 // Uncomment to get minimum footprint (suitable for 1-2 concurrent calls
310 only)
311 //#define PJ_CONFIG_MINIMAL_SIZE
312 // Uncomment to get maximum performance
313 //#define PJ_CONFIG_MAXIMUM_SPEED
314 #include <pj/config_site_sample.h>
315
316
3172.2 Disk Space Requirements
318 _________________________________________________________________
319
320 PJ will need
321 currently about 50-60 MB of disk space to store the source files, and
322 * approximately 30-50 MB of additional space for building each target
323
324 (For example, Visual Studio Debug and Release are considered to be separate
325 targets, so you'll need twice the capacity to build both of them)
326
327
3283. Building Linux, *nix, *BSD, and MacOS X Targets with GNU Build Systems
329 _________________________________________________________________
330
3313.1 Supported Targets
332 _________________________________________________________________
333
334 The new, autoconf based GNU build system can be used to build the
335 libraries/applications for the following targets:
336 * Linux/uC-Linux (i386, Opteron, Itanium, MIPS, PowerPC, etc.),
337 * MacOS X (PowerPC),
338 * mingw (i386),
339 * *BSD (i386, Opteron, etc.),
340 * RTEMS (ARM, powerpc),
341 * etc.
342
343
3443.2 Requirements
345 _________________________________________________________________
346
347 To use PJ's GNU build system, you would need the typical GNU tools such as:
348 * GNU Make (other make will not work),
349 * binutils,
350 * gcc, and
351 * sh compatible shell (for autoconf to work)
352
353 On Windows, mingw will work, but cygwin currently doesn't. As usual, your
354 mileage may vary.
355
356
3573.3 Running configure
358 _________________________________________________________________
359
360Using Default Settings
361
362 Just run configure without any options to let the script detect the
363 appropriate settings for the host:
364
365 $ cd pjproject
366 $ ./configure
367 ...
368
369 Notes:
370 The default settings build the library in "release" mode, with
371 default CFLAGS set to "-O2 -DNDEBUG".
372
373 Features Customization
374
375 With the new autoconf based build system, most configuration/customization
376 can be specified as configure arguments. You can get the list of
377 customizable features by running ./configure --help:
378
379 $ cd pjproject
380 $ ./configure --help
381 ...
382 Optional Features:
383 --disable-floating-point Disable floating point where possible
384 --disable-sound Exclude sound (i.e. use null sound)
385 --disable-small-filter Exclude small filter in resampling
386 --disable-large-filter Exclude large filter in resampling
387 --disable-g711-plc Exclude G.711 Annex A PLC
388 --disable-speex-aec Exclude Speex Acoustic Echo Canceller/AEC
389 --disable-g711-codec Exclude G.711 codecs from the build
390 --disable-l16-codec Exclude Linear/L16 codec family from the build
391 --disable-gsm-codec Exclude GSM codec in the build
392 --disable-speex-codec Exclude Speex codecs in the build
393 --disable-ilbc-codec Exclude iLBC codec in the build
394 ...
395
396 Debug Version and Other Customizations
397
398 The configure script accepts standard customization such as the CFLAGS,
399 LDFLAGS, etc.
400
401 For example, to build the libraries/application in debug mode:
402
403 $ ./configure CFLAGS="-g"
404 ...
405
406
407 3.4 Cross Compilation
408 _________________________________________________________________
409
410 (.. to be completed)
411
412 $ ./configure --target=powerpc-linux-unknown
413 ...
414
415
416 3.5 Running make
417 _________________________________________________________________
418
419 Once the configure script completes successfully, start the build process by
420 invoking these commands:
421
422 $ cd pjproject
423 $ make dep
424 $ make
425
426 Note:
427 You may need to call gmake instead of make for your host to invoke
428 GNU make instead of the native make.
429
430 Description of all make targets supported by the Makefile's:
431
432 all
433 The default (or first) make target to build the libraries/binaries.
434
435 dep, depend
436 Build dependencies rule from the source files.
437
438 clean
439 Clean the object files, but keep the output library/binary files
440 intact.
441
442 distclean, realclean
443 Clean all generated files (object, libraries, binaries, and
444 dependency files).
445
446
447 Note:
448 You can run make in the top-level PJ directory or in build directory
449 under each project to build only the particular project.
450
451
4524. Building for Windows Targets with Microsoft Visual Studio
453 _________________________________________________________________
454
455 4.1 Requirements
456 _________________________________________________________________
457
458 In order to build the projects using Microsoft Visual Studio, you need to
459 have one of the following:
460
461 * Microsoft Visual Studio 6,
462 * Microsoft Visual Studio .NET 2002,
463 * Microsoft Visual Studio .NET 2003,
464 * Microsoft Visual Studio Express 2005 with Platform SDK and DirectX SDK,
465
466 For the host, you need:
467 * Windows NT, 2000, XP, 2003, or later (it may work on Windows 95 or 98,
468 but this has not been tested),
469 * Sufficient amount of RAM for the build process,
470
471
472 4.2 Building the Projects
473 _________________________________________________________________
474
475 Follow the steps below to build the libraries/application using Visual
476 Studio:
477 1. Open Visual Studio 6 workspace file pjsip-apps/build/pjsip_apps.dsw. If
478 you're using later version of Visual Studio, it should convert the
479 workspace file and project files into the new formats.
480 2. Set pjsua as Active Project.
481 3. Select Debug or Release build as appropriate.
482 4. Build the project. This will build pjsua application and all libraries
483 needed by pjsua.
484 5. After successful build, the pjsua application will be placed in
485 pjsip-apps/bin directory, and the libraries in lib directory under each
486 projects.
487
488 To build the samples:
489 1. (Still using the same workspace)
490 2. Set samples project as Active Project
491 3. Select Debug or Release build as appropriate.
492 4. Build the project. This will build all sample applications and all
493 libraries needed.
494 5. After successful build, the sample applications will be placed in
495 pjsip-apps/bin/samples directory, and the libraries in lib directory
496 under each projects.
497
498 4.3 Debugging the Sample Application
499 _________________________________________________________________
500
501 The sample applications are build using Samples.mak makefile, therefore it
502 is difficult to setup debugging session in Visual Studio for these
503 applications. To solve this issue, the pjsip_apps workspace contain one
504 project called sample_debug which can be used to debug the sample
505 application.
506
507 To setup debugging using sample_debug project:
508 1. (Still using pjsip_apps workspace)
509 2. Set sample_debug project as Active Project
510 3. Edit debug.c file inside this project.
511 4. Modify the #include line to include the particular sample application
512 you want to debug
513 5. Select Debug build.
514 6. Build and debug the project.
515
516
5175. Building for Windows Mobile Targets (Windows CE/WinCE/PDA/SmartPhone)
518 _________________________________________________________________
519
520 PJ supports building SIP and media stacks and applications for Windows
521 Mobile targets. A very simple WinCE SIP user agent (with media) application
522 is provided just as proof of concept that the port works.
523
524 5.1 Requirements
525 _________________________________________________________________
526
527 You will need the following to build SIP and media components for Windows
528 Mobile:
529 * Microsoft Embedded Visual C++ 4 with appropriate SDKs, or
530 * Microsoft Visual Studio 2005 for Windows Mobile with appropriate SDKs.
531
532 Note that VS2005 is not directly supported (as I don't have the tools), but
533 it is reported to work (and I assumed that VS2005 for Windows Mobile can
534 import EVC4 workspace file).
535
536 5.2 Building the Projects
537 _________________________________________________________________
538
539 The Windows Mobile port is included in the main source distribution. Please
540 follow the following steps to build the WinCE libraries and sample
541 application:
542 1. Open pjsip-apps/build/wince-evc4/wince_demos.vcw workspace file. If
543 you're using later version of EVC4 this may cause the workspace file to
544 be converted to the current version of your Visual Studio.
545 2. Select pjsua_wince project as the Active Project.
546 3. Select the appropriate SDK (for example Pocket PC 2003 SDK or SmartPhone
547 2003 SDK)
548 4. Select the appropriate configuration (for example, Win32 (WCE Emulator
549 Debug) if you plan to debug the program in emulator)
550 5. Select the appropriate device (Emulator or the actual Device).
551 6. Build the project. This will build the sample WinCE application and all
552 libraries (SIP, Media, etc.) needed by this application.
553
554 Notes
555 If your config_site.h includes config_site_sample.h file, then
556 there are certain configuration in config_site_sample.h that get
557 activated for Windows CE targets.
558
559
5606. Using PJPROJECT with Your Applications
561 _________________________________________________________________
562
563 Regardless if you use Visual Studio or GNU build systems or other tools, in
564 order to build your application to use PJSIP and PJMEDIA SIP and media
565 stack, you need to configure your build tools as follows:
566 1. Put these include directories in your include search path:
567 + pjlib/include
568 + pjlib-util/include
569 + pjmedia/include
570 + pjsip/include
571 2. Put these library directories in your library search path:
572 + pjlib/lib
573 + pjlib-util/lib
574 + pjmedia/lib
575 + pjsip/lib
576 3. Include the relevant PJ header files in your application source file.
577 For example, using these would include ALL APIs exported by PJ:
578
579 #include <pjlib.h>
580 #include <pjlib-util.h>
581 #include <pjsip.h>
582 #include <pjsip_ua.h>
583 #include <pjsip_simple.h>
584 #include <pjsua.h>
585 #include <pjmedia.h>
586 #include <pjmedia-codec.h>
587 (Note: the documentation of the relevant libraries should say which
588 header files should be included to get the declaration of the APIs).
589 4. Declare the OS macros.
590 + For Windows applications built with Visual Studio, you need to
591 declare PJ_WIN32=1 macro in your project settings (declaring the
592 macro in your source file may not be sufficient).
593 + For Windows Mobile applications build with Visual C++, you need to
594 declare PJ_WIN32_WINCE=1 macro in your project settings.
595 + For GNU build system/autoconf based build system, you need to
596 declare PJ_AUTOCONF=1 macro when compiling your applications.
597 (Note: the old PJ build system requires declaring the target processor
598 with PJ_M_XXX=1 macro, but this has been made obsolete. The target
599 processor will be detected from compiler's predefined macro by
600 pjlib/config.h file).
601 5. Link with the appropriate PJ libraries. The following libraries will
602 need to be included in your library link specifications:
603
604 pjlib
605 Base library used by all libraries.
606
607 pjlib-util
608 Auxiliary library containing scanner, XML, STUN, MD5, getopt,
609 etc, used by the SIP and media stack.
610
611 pjsip
612 SIP core stack library.
613
614 pjsip-ua
615 SIP user agent library containing INVITE session, call
616 transfer, client registration, etc.
617
618 pjsip-simple
619 SIP SIMPLE library for base event framework, presence, instant
620 messaging, etc.
621
622 pjsua
623 High level SIP UA library, combining SIP and media stack into
624 high-level easy to use API.
625
626 pjmedia
627 The media framework.
628
629 pjmedia-codec
630 Container library for various codecs such as GSM, Speex, and
631 iLBC.
632
633
634 Note: the actual library names will be appended with the target name and the
635 build configuration. For example:
636
637 For Visual Studio builds
638 The actual library names will look like
639 pjlib-i386-win32-vc6-debug.lib,
640 pjlib-i386-win32-vc6-release.lib, etc., depending on whether
641 you build the Debug or Release version of the library.
642
643 For GNU builds
644 You can get the library suffix by including PJ's build.mak file
645 from the root PJ directory (the suffix is contained in
646 TARGET_NAME variable). For example, to link with PJLIB and
647 PJMEDIA, you can use this in syntax your LDFLAGS:
648 "-lpj-$(TARGET_NAME) -lpjmedia-$(TARGET_NAME)"
649
650 Should you encounter any difficulties with using PJ libraries, you can
651 consult the mailing list for some help.
652
653
654Appendix I: Common Problems/Frequently Asked Question (FAQ)
655 _________________________________________________________________
656
657 I.1 fatal error C1083: Cannot open include file: 'pj/config_site.h': No such
658 file or directory
659
660 If you encounter this error, then probably you haven't created the
661 config_site.h file. Please follow the Build Preparation instructions
662 above to create this file.
663
664
665
666
667
668
669
670
671 _________________________________________________________________
672
673 Feedback:
674 Thanks for downloading PJ libraries and for reading this document. If
675 you'd like to comment on anything, send your email to me and I would
676 be delighted to hear them. -benny <bennylp at pjsip dot org>
Benny Prijonoeec4d7c2006-03-09 16:19:20 +0000677