blob: d431b386c43e1820f80437f801de2e7ce3f02fb1 [file] [log] [blame]
Benny Prijono10a20802006-03-02 21:52:18 +00001
Benny Prijonoc3416832006-09-12 18:58:19 +00002Getting Started: Building and Using PJSIP and PJMEDIA
Benny Prijonoc3416832006-09-12 18:58:19 +00003
Benny Prijono81d89ea2007-02-02 20:49:33 +00004 [Last Update: $Date: 2007-02-02 20:42:44 +0000 (Fri, 02 Feb 2007) $]
Benny Prijono646b7b72006-10-21 18:28:07 +00005
Benny Prijono81d89ea2007-02-02 20:49:33 +00006 Print Friendly Page
Benny Prijonoabd2ae92006-09-13 11:02:26 +00007 _________________________________________________________________
8
9 This article describes how to download, customize, build, and use the open
10 source PJSIP and PJMEDIA SIP and media stack. The online (and HTML) version
11 of this file can be downloaded from http://www.pjsip.org/using.htm
Benny Prijonodb419fd2006-03-05 11:54:33 +000012
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000013
Benny Prijonoabd2ae92006-09-13 11:02:26 +000014Quick Info
Benny Prijono646b7b72006-10-21 18:28:07 +000015 _________________________________________________________________
Benny Prijonoc3416832006-09-12 18:58:19 +000016
Benny Prijono646b7b72006-10-21 18:28:07 +000017 Building with GNU tools (Linux, *BSD, MacOS X, mingw, etc.)
Benny Prijonoabd2ae92006-09-13 11:02:26 +000018 Generally these should be all that are needed to build the libraries,
19 applications, and samples:
Benny Prijonoc3416832006-09-12 18:58:19 +000020
Benny Prijono81d89ea2007-02-02 20:49:33 +000021 $ ./configure
22 $ make dep && make clean && make
Benny Prijonoc3416832006-09-12 18:58:19 +000023
Benny Prijonoabd2ae92006-09-13 11:02:26 +000024 Building Win32 Target with Microsoft Visual Studio
25 Generally we can just do these steps:
Benny Prijonoc3416832006-09-12 18:58:19 +000026
Benny Prijono81d89ea2007-02-02 20:49:33 +000027 1. Visual Studio 6: open pjproject.dsw workspace,
28 2. Visual Studio 2005: open pjproject-vs8.sln solution,
29 3. Create an empty pjlib/include/pj/config_site.h, and
30 4. build the pjsua application.
Benny Prijonoc3416832006-09-12 18:58:19 +000031
32 Building for Windows Mobile
Benny Prijonoabd2ae92006-09-13 11:02:26 +000033 Generally these are all that are needed:
Benny Prijonoc3416832006-09-12 18:58:19 +000034
35 1. Open pjsip-apps/build/wince-evc4/wince_demos.vcw EVC4 workspace,
36 2. Create an empty pjlib/include/pj/config_site.h, and
37 3. build the pjsua_wince application.
38
Benny Prijono81d89ea2007-02-02 20:49:33 +000039 Invoking Older Build System (e.g. for RTEMS)
40 Generally these should be all that are needed to build the libraries,
41 applications, and samples:
42
43 $ ./configure-legacy
44 $ make dep && make clean && make
45
Benny Prijono646b7b72006-10-21 18:28:07 +000046 Locating Output Binaries/Libraries
47 Libraries will be put in lib directory, and binaries will be put in
48 bin directory, under each projects.
49
50 Running the Applications
51 After successful build, you can try running pjsua application on
Benny Prijono81d89ea2007-02-02 20:49:33 +000052 pjsip-apps/bin directory. PJSUA manual can be found in
53 http://www.pjsip.org/pjsua.htm page.
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000054
55
Benny Prijonoc3416832006-09-12 18:58:19 +000056Table of Contents:
57 _________________________________________________________________
Benny Prijonoeec4d7c2006-03-09 16:19:20 +000058
Benny Prijonoc3416832006-09-12 18:58:19 +000059 1. Getting the Source Distribution
60
61 1.1 Getting the Release tarball
62
63 1.2 Getting from Subversion trunk
64
65 1.3 Source Directories Layout
66
67 2. Build Preparation
68
69 2.1 config_site.h file
70
71 2.2 Disk Space Requirements
72
Benny Prijono646b7b72006-10-21 18:28:07 +000073 3. Building Linux, *nix, *BSD, and MacOS X Targets with GNU Build
74 Systems
Benny Prijonoc3416832006-09-12 18:58:19 +000075
76 3.1 Supported Targets
77
78 3.2 Requirements
79
80 3.3 Running configure
81
82 3.4 Running make
83
84 3.5 Cross Compilation
85
Benny Prijono646b7b72006-10-21 18:28:07 +000086 3.6 Build Customizations
87
Benny Prijonoc3416832006-09-12 18:58:19 +000088 4. Building for Windows Targets with Microsoft Visual Studio
89
90 4.1 Requirements
91
92 4.2 Building the Projects
93
94 4.3 Debugging the Sample Application
95
96 5. Building for Windows Mobile Targets (Windows CE/WinCE/PDA/SmartPhone)
97
98 5.1 Requirements
99
100 5.2 Building the Projects
101
Benny Prijono81d89ea2007-02-02 20:49:33 +0000102 6. Older PJLIB Build System for Non-Autoconf Targets (e.g. RTEMS)
103
104 6.1 Supported Targets
105
106 6.2 Invoking the Build System
107
108 7. Running the Applications
109
110 7.1 pjsua
111
112 7.2 Sample Applications
113
114 7.3 pjlib-test
115
116 7.4 pjsip-test
117
118 8. Using PJPROJECT with Applications
Benny Prijonoeec4d7c2006-03-09 16:19:20 +0000119
120
Benny Prijonoc3416832006-09-12 18:58:19 +0000121 Appendix I: Common Problems/Frequently Asked Question (FAQ)
Benny Prijonoeec4d7c2006-03-09 16:19:20 +0000122
Benny Prijonoc3416832006-09-12 18:58:19 +0000123 I.1 fatal error C1083: Cannot open include file: 'pj/config_site.h':
124 No such file or directory
125
126
1271. Getting the Source Code Distribution
128 _________________________________________________________________
129
Benny Prijonoc3416832006-09-12 18:58:19 +0000130 All libraries (PJLIB, PJLIB-UTIL, PJSIP, PJMEDIA, and PJMEDIA-CODEC) are
131 currently distributed under a single source tree, collectively named as
132 PJPROJECT or just PJ libraries. These libraries can be obtained by either
133 downloading the release tarball or getting them from the Subversion trunk.
134
135
1361.1 Getting the Release tarball
137 _________________________________________________________________
138
139 Getting the released tarball is a convenient way to obtain stable version of
140 PJPROJECT. The tarball may not contain the latest features or bug-fixes, but
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000141 normally it is considered more stable as each will be tested more rigorously
142 before released.
Benny Prijonoc3416832006-09-12 18:58:19 +0000143
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000144 The latest released tarball can be downloaded from the
Benny Prijonoc3416832006-09-12 18:58:19 +0000145 http://www.pjsip.org/download.htm.
146
147
1481.2 Getting from Subversion trunk
149 _________________________________________________________________
150
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000151 PJPROJECT Subversion repository will always contain the latest/most
152 up-to-date version of the sources. Normally the Subversion repository is
153 always kept in a "good" state. However, there's always a chance that things
154 break and the tree doesn't build correctly (particularly for the
155 "not-so-popular" targets), so please consult the mailing list should there
156 be any problems.
Benny Prijonoc3416832006-09-12 18:58:19 +0000157
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000158 Using Subversion also has benefits of keeping the local copy of the source
159 up to date with the main PJ source tree and to easily track the changes made
160 to the local copy, if any.
Benny Prijonoc3416832006-09-12 18:58:19 +0000161
162
163What is Subversion
164
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000165 Subversion (SVN) is Open Source version control system similar to CVS.
166 Subversion homepage is in http://subversion.tigris.org/
Benny Prijonoc3416832006-09-12 18:58:19 +0000167
168
169Getting Subversion Client
170
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000171 A Subversion (SVN) client is needed to download the PJ source files from
172 pjsip.org SVN tree. SVN client binaries can be downloaded from
173 http://subversion.tigris.org/, and the program should be available for
174 Windows, Linux, MacOS X, and many more platforms.
Benny Prijonoc3416832006-09-12 18:58:19 +0000175
176
177Getting the Source for The First Time
178
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000179 Once Subversion client is installed, we can use these commands to initially
Benny Prijonoc3416832006-09-12 18:58:19 +0000180 retrieve the latest sources from the Subversion trunk:
181
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000182
183
Benny Prijonoc3416832006-09-12 18:58:19 +0000184 $ svn co http://svn.pjproject.net/repos/pjproject/trunk pjproject
185 $ cd pjproject
186
187
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000188Keeping The Local Copy Up-to-Date
Benny Prijonoc3416832006-09-12 18:58:19 +0000189
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000190 Once sources have been downloaded, we can keep the local copy up to date by
191 periodically synchronizing the local source with the latest revision from
192 the PJ's Subversion trunk. The mailing list provides best source of
193 information about the availability of new updates in the trunk.
Benny Prijonoc3416832006-09-12 18:58:19 +0000194
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000195 To update the local copy with the latest changes in the main PJ's
196 repository:
197
198
Benny Prijonoc3416832006-09-12 18:58:19 +0000199
200 $ cd pjproject
201 $ svn update
202
203
204Tracking Local and Remote Changes
205
Benny Prijonoc3416832006-09-12 18:58:19 +0000206 To see what files have been changed locally:
207
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000208
209
Benny Prijonoc3416832006-09-12 18:58:19 +0000210 $ cd pjproject
211 $ svn status
212
213 The above command only compares local file against the original local copy,
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000214 so it doesn't require Internet connection while performing the check.
Benny Prijonoc3416832006-09-12 18:58:19 +0000215
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000216 To see both what files have been changed locally and what files have been
217 updated in the PJ's Subversion repository:
218
219
Benny Prijonoc3416832006-09-12 18:58:19 +0000220
221 $ cd pjproject
222 $ svn status -u
223
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000224 Note that this command requires active Internet connection to query the
225 status of PJPROJECT's source repository.
Benny Prijonoc3416832006-09-12 18:58:19 +0000226
227
2281.3 Source Directories Layout
229 _________________________________________________________________
230
231Top-Level Directory Layout
232
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000233 The top-level directories (denoted as $TOP here) in the source distribution
234 contains the following sub-directories:
Benny Prijonoc3416832006-09-12 18:58:19 +0000235
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000236 $TOP/build
Benny Prijonoc3416832006-09-12 18:58:19 +0000237 Contains makefiles that are common for all projects.
238
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000239 $TOP/pjlib
240 Contains header and source files of PJLIB. PJLIB is the base
241 portability and framework library which is used by all other
242 libraries
Benny Prijonoc3416832006-09-12 18:58:19 +0000243
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000244 $TOP/pjlib-util
245 Contains PJLIB-UTIL header and source files. PJLIB-UTIL is an
246 auxiliary library that contains utility functions such as scanner,
247 XML, STUN, MD5 algorithm, getopt() implementation, etc.
Benny Prijonoc3416832006-09-12 18:58:19 +0000248
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000249 $TOP/pjmedia
250 Contains PJMEDIA and PJMEDIA-CODEC header and source files. The
251 sources of various codecs (such as GSM, Speex, and iLBC) can be found
252 under this directory.
Benny Prijonoc3416832006-09-12 18:58:19 +0000253
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000254 $TOP/pjsip
Benny Prijonoc3416832006-09-12 18:58:19 +0000255 Contains PJSIP header and source files.
256
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000257 $TOP/pjsip-apps
258 Contains source code for PJSUA and various sample applications.
Benny Prijonoc3416832006-09-12 18:58:19 +0000259
260
261Individual Directory Inside Each Project
262
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000263 Each library directory further contains these sub-directories:
Benny Prijonoc3416832006-09-12 18:58:19 +0000264
265 bin
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000266 Contains binaries produced by the build process.
Benny Prijonoc3416832006-09-12 18:58:19 +0000267
268 build
269 Contains build scripts/makefiles, project files, project workspace,
270 etc. to build the project. In particular, it contains one Makefile
271 file to build the project with GNU build systems, and a *.dsw
272 workspace file to build the library with Microsoft Visual Studio 6 or
273 later.
274
275 build/output
276 The build/output directory contains the object files and other files
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000277 generated by the build process. To support building multiple targets
278 with a single source tree, each build target will occupy a different
279 subdirectory under this directory.
Benny Prijonoc3416832006-09-12 18:58:19 +0000280
281 build/wince-evc4
282 This directory contains the project/workspace files to build Windows
283 CE/WinCE version of the project using Microsoft Embedded Visual C++
284 4.
285
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000286 build/wince-evc4/output
287 This directory contains the library, executable, and object files
288 generated by Windows Mobile build process.
289
Benny Prijonoc3416832006-09-12 18:58:19 +0000290 docs
291 Contains Doxygen configuration file (doxygen.cfg) to generate online
292 documentation from the source files. The output documentation will be
293 put in this directory as well (for example, docs/html directory for
294 the HTML files).
295
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000296 (to generate Doxygen documentation from the source tree, just run
297 "doxygen docs/doxygen.cfg" in the individual project directory. The
298 generated files will reside in docs directory).
299
Benny Prijonoc3416832006-09-12 18:58:19 +0000300 include
301 Contains the header files for the project.
302
303 lib
304 Contains libraries produced by the build process.
305
306 src
307 Contains the source files of the project.
308
309
3102. Build Preparation
311 _________________________________________________________________
312
Benny Prijono646b7b72006-10-21 18:28:07 +00003132.1 Create config_site.h file
Benny Prijonoc3416832006-09-12 18:58:19 +0000314 _________________________________________________________________
315
Benny Prijono646b7b72006-10-21 18:28:07 +0000316 Before source files can be built, the pjlib/include/pj/config_site.h file
317 must be created (it can just be an empty file).
318
319 Note:
320 When the Makefile based build system is used, this process is taken
321 care by the Makefiles. But when non-Makefile based build system (such
322 as Visual Studio) is used, the config_site.h file must be created
323 manually.
324
325
326What is config_site.h File
327
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000328 The pjlib/include/pj/config_site.h contains local customizations to the
Benny Prijonoc3416832006-09-12 18:58:19 +0000329 libraries.
330
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000331 All customizations should be put in this file instead of modifying PJ's
332 files, because if PJ's files get modified, then those modified files will
333 not be updated the next time the source is synchronized. Or in other case,
334 the local modification may be overwritten with the fresh copy from the SVN.
Benny Prijonoc3416832006-09-12 18:58:19 +0000335
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000336 Putting the local customization to the config_site.h solves this problem,
337 because this file is not included in the version control, so it will never
338 be overwritten by "svn update" command.
Benny Prijonoc3416832006-09-12 18:58:19 +0000339
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000340 Please find list of configuration macros that can be overriden from these
341 files:
Benny Prijono646b7b72006-10-21 18:28:07 +0000342 * PJLIB Configuration (the pjlib/config.h file)
343 * PJLIB-UTIL Configuration (the pjlib-util/config.h file)
344 * PJMEDIA Configuration (the pjmedia/config.h file)
345 * PJSIP Configuration (the pjsip/sip_config.h file)
Benny Prijonoc3416832006-09-12 18:58:19 +0000346
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000347 A sample config_site.h file is also available in
Benny Prijonoc3416832006-09-12 18:58:19 +0000348 pjlib/include/config_site_sample.h.
349
Benny Prijonoc3416832006-09-12 18:58:19 +0000350
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000351Creating config_site.h file
Benny Prijonoc3416832006-09-12 18:58:19 +0000352
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000353 The simplest way is just to create an empty file, to use whetever default
354 values set by the libraries.
355
356 Another way to create the config_site.h file is to write something like the
357 following:
358
Benny Prijonoc3416832006-09-12 18:58:19 +0000359
360 // Uncomment to get minimum footprint (suitable for 1-2 concurrent calls
361 only)
362 //#define PJ_CONFIG_MINIMAL_SIZE
363 // Uncomment to get maximum performance
364 //#define PJ_CONFIG_MAXIMUM_SPEED
365 #include <pj/config_site_sample.h>
366
367
3682.2 Disk Space Requirements
369 _________________________________________________________________
370
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000371 The building process needs:
Benny Prijono646b7b72006-10-21 18:28:07 +0000372 about 50-60 MB of disk space to store the uncompressed source files, and
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000373 * about 30-50 MB of additional space for building each target
Benny Prijonoc3416832006-09-12 18:58:19 +0000374
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000375 (Visual Studio Debug and Release are considered as separate targets)
Benny Prijonoc3416832006-09-12 18:58:19 +0000376
377
3783. Building Linux, *nix, *BSD, and MacOS X Targets with GNU Build Systems
379 _________________________________________________________________
380
3813.1 Supported Targets
382 _________________________________________________________________
383
384 The new, autoconf based GNU build system can be used to build the
385 libraries/applications for the following targets:
386 * Linux/uC-Linux (i386, Opteron, Itanium, MIPS, PowerPC, etc.),
387 * MacOS X (PowerPC),
388 * mingw (i386),
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000389 * FreeBSD and maybe other BSD's (i386, Opteron, etc.),
390 * RTEMS with cross compilation (ARM, powerpc),
Benny Prijonoc3416832006-09-12 18:58:19 +0000391 * etc.
392
393
3943.2 Requirements
395 _________________________________________________________________
396
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000397 In order to use PJ's GNU build system, these typical GNU tools are needed:
398 * GNU make (other make will not work),
399 * GNU binutils for the target, and
400 * GNU gcc for the target.
Benny Prijono81d89ea2007-02-02 20:49:33 +0000401 * OpenSSL header files/libraries (optional) if TLS support is wanted.
Benny Prijonoc3416832006-09-12 18:58:19 +0000402
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000403 In addition, the appropriate "SDK" must be installed for the particular
404 target (this could just be a libc and the appropriate system abstraction
405 library such as Posix).
406
407 The build system is known to work on the following hosts:
408 * Linux, many types of distributions.
409 * MacOS X 10.2
410 * mingw (Win2K, XP)
411 * FreeBSD (must use gmake instead of make)
412
Benny Prijono81d89ea2007-02-02 20:49:33 +0000413 Building Win32 applications with Cygwin is currently not supported by the
414 autoconf script (there is some Windows header conflicts), but one can still
415 use the old configure script by calling ./configure-legacy. More over,
416 cross-compilations might also work with Cygwin.
Benny Prijonoc3416832006-09-12 18:58:19 +0000417
418
4193.3 Running configure
420 _________________________________________________________________
421
422Using Default Settings
423
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000424 Run "./configure" without any options to let the script detect the
Benny Prijonoc3416832006-09-12 18:58:19 +0000425 appropriate settings for the host:
426
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000427
428
Benny Prijonoc3416832006-09-12 18:58:19 +0000429 $ cd pjproject
430 $ ./configure
431 ...
432
433 Notes:
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000434 The default settings build the libraries in "release" mode, with
435 default CFLAGS set to "-O2 -DNDEBUG". To change the default CFLAGS,
436 we can use the usual "./configure CFLAGS='-g'" construct.
Benny Prijonoc3416832006-09-12 18:58:19 +0000437
438 Features Customization
439
440 With the new autoconf based build system, most configuration/customization
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000441 can be specified as configure arguments. The list of customizable features
442 can be viewed by running "./configure --help" command:
443
444
Benny Prijonoc3416832006-09-12 18:58:19 +0000445
446 $ cd pjproject
447 $ ./configure --help
448 ...
449 Optional Features:
Benny Prijono81d89ea2007-02-02 20:49:33 +0000450 --disable-floating-point Disable floating point where possible
451 --disable-sound Exclude sound (i.e. use null sound)
452 --disable-small-filter Exclude small filter in resampling
453 --disable-large-filter Exclude large filter in resampling
454 --disable-g711-plc Exclude G.711 Annex A PLC
455 --disable-speex-aec Exclude Speex Acoustic Echo Canceller/AEC
456 --disable-g711-codec Exclude G.711 codecs from the build
457 --disable-l16-codec Exclude Linear/L16 codec family from the build
458 --disable-gsm-codec Exclude GSM codec in the build
459 --disable-speex-codec Exclude Speex codecs in the build
460 --disable-ilbc-codec Exclude iLBC codec in the build
461 --disable-tls Force excluding TLS support (default is autodetected based on
462 OpenSSL availability)
463 ...
Benny Prijonoc3416832006-09-12 18:58:19 +0000464
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000465 Configuring Debug Version and Other Customizations
Benny Prijonoc3416832006-09-12 18:58:19 +0000466
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000467 The configure script accepts standard customization, which details can be
468 obtained by executing ./configure --help.
Benny Prijonoc3416832006-09-12 18:58:19 +0000469
Benny Prijono646b7b72006-10-21 18:28:07 +0000470 Below is an example of specifying CFLAGS in configure:
Benny Prijonoc3416832006-09-12 18:58:19 +0000471
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000472
473
Benny Prijono646b7b72006-10-21 18:28:07 +0000474 $ ./configure CFLAGS="-O3 -DNDEBUG -msoft-float -fno-builtin"
Benny Prijonoc3416832006-09-12 18:58:19 +0000475 ...
476
Benny Prijono81d89ea2007-02-02 20:49:33 +0000477 Configuring TLS Support
478
479 By default, TLS support is configured based on the availability of OpenSSL
480 header files and libraries. If OpenSSL is available at the default include
481 and library path locations, TLS will be enabled by the configure script.
482
483 You can explicitly disable TLS support by giving the configure script
484 --disable-tls option.
485
Benny Prijonoc3416832006-09-12 18:58:19 +0000486
487 3.4 Cross Compilation
488 _________________________________________________________________
489
Benny Prijono646b7b72006-10-21 18:28:07 +0000490 Cross compilation should be supported, using the usual autoconf syntax:
Benny Prijonoc3416832006-09-12 18:58:19 +0000491
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000492
493
Benny Prijono646b7b72006-10-21 18:28:07 +0000494 $ ./configure --host=arm-elf-linux
Benny Prijonoc3416832006-09-12 18:58:19 +0000495 ...
496
Benny Prijono646b7b72006-10-21 18:28:07 +0000497 Since cross-compilation is not tested as often as the "normal" build, please
498 watch for the ./configure output for incorrect settings (well ideally this
499 should be done for normal build too).
500
501 Please refer to Porting Guide for further information about porting PJ
502 software.
503
Benny Prijonoc3416832006-09-12 18:58:19 +0000504
505 3.5 Running make
506 _________________________________________________________________
507
508 Once the configure script completes successfully, start the build process by
509 invoking these commands:
510
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000511
512
Benny Prijonoc3416832006-09-12 18:58:19 +0000513 $ cd pjproject
514 $ make dep
515 $ make
516
517 Note:
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000518 gmake may need to be specified instead of make for some hosts, to
519 invoke GNU make instead of the native make.
520
Benny Prijonoc3416832006-09-12 18:58:19 +0000521
522 Description of all make targets supported by the Makefile's:
523
524 all
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000525 The default (or first) target to build the libraries/binaries.
Benny Prijonoc3416832006-09-12 18:58:19 +0000526
527 dep, depend
528 Build dependencies rule from the source files.
529
530 clean
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000531 Clean the object files for current target, but keep the output
532 library/binary files intact.
Benny Prijonoc3416832006-09-12 18:58:19 +0000533
534 distclean, realclean
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000535 Remove all generated files (object, libraries, binaries, and
536 dependency files) for current target.
Benny Prijonoc3416832006-09-12 18:58:19 +0000537
538
539 Note:
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000540 make can be invoked either in the top-level PJ directory or in build
541 directory under each project to build only the particular project.
Benny Prijonoc3416832006-09-12 18:58:19 +0000542
543
Benny Prijono646b7b72006-10-21 18:28:07 +0000544 3.6 Build Customizations
545 _________________________________________________________________
546
547 Build features can be customized by specifying the options when running
548 ./configure as described in Running Configure above.
549
550 In addition, additional CFLAGS and LDFLAGS options can be put in user.mak
551 file in PJ root directory (this file may need to be created if it doesn't
552 exist). Below is a sample of user.mak file contents:
553
554
555
556 export CFLAGS += -msoft-float -fno-builtin
557 export LDFLAGS +=
558
559
Benny Prijonoc3416832006-09-12 18:58:19 +00005604. Building for Windows Targets with Microsoft Visual Studio
561 _________________________________________________________________
562
563 4.1 Requirements
564 _________________________________________________________________
565
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000566 The Microsoft Visual Studio based project files can be used with one of the
567 following:
Benny Prijonoc3416832006-09-12 18:58:19 +0000568
569 * Microsoft Visual Studio 6,
570 * Microsoft Visual Studio .NET 2002,
571 * Microsoft Visual Studio .NET 2003,
Benny Prijono81d89ea2007-02-02 20:49:33 +0000572 * Microsoft Visual C++ 2005 (including Express edition),
573
574 In addition, the following SDK's are needed:
575 * Platform SDK, if you're using Visual Studio 2005 Express (tested with
576 Platform SDK for Windows Server 2003 SP1),
577 * DirectX SDK (tested with DirectX version 8 and 9),
578 * OpenSSL development kit would be needed if TLS support is wanted, or
579 otherwise this is optional.
Benny Prijonoc3416832006-09-12 18:58:19 +0000580
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000581 For the host, the following are required:
582 * Windows NT, 2000, XP, 2003, or later ,
583 * Windows 95/98 should work too, but this has not been tested,
Benny Prijono81d89ea2007-02-02 20:49:33 +0000584 * Sufficient amount of RAM for the build process (at least 256MB).
585
586
587 Enabling TLS Support with OpenSSL
588
589 If TLS support is wanted, then OpenSSL SDK must be installed in the
590 development host.
591
592 To install OpenSSL SDK from the Win32 binary distribution:
593 1. Install OpenSSL SDK to any folder (e.g. C:\OpenSSL)
594 2. Add OpenSSL DLL location to the system PATH.
595 3. Add OpenSSL include path to Visual Studio includes search directory.
596 Make sure that OpenSSL header files can be accessed from the program
597 with #include <openssl/ssl.h> construct.
598 4. Add OpenSSL library path to Visual Studio library search directory. Make
599 sure the following libraries are accessible:
600 + For Debug build: libeay32MTd and ssleay32MTd.
601 + For Release build: libeay32MT and ssleay32MT.
602
603 Then to enable TLS transport support in PJSIP, just add
604
605 #define PJSIP_HAS_TLS_TRANSPORT 1
606
607 in your pj/config_site.h. When this macro is defined, OpenSSL libraries will
608 be automatically linked to the application via the #pragma construct in
609 sip_transport_tls_ossl.c file.
Benny Prijonoc3416832006-09-12 18:58:19 +0000610
611
612 4.2 Building the Projects
613 _________________________________________________________________
614
615 Follow the steps below to build the libraries/application using Visual
616 Studio:
Benny Prijono81d89ea2007-02-02 20:49:33 +0000617 1. For Visual Studio 6: open pjproject.dsw workspace file.
618 2. For Visual Studio 8 (VS 2005): open pjproject-vs8.sln solution file.
619 3. Set pjsua as Active Project.
620 4. Select Debug or Release build as appropriate.
621 5. Build the project. This will build pjsua application and all libraries
Benny Prijonoc3416832006-09-12 18:58:19 +0000622 needed by pjsua.
Benny Prijono81d89ea2007-02-02 20:49:33 +0000623 6. After successful build, the pjsua application will be placed in
Benny Prijonoc3416832006-09-12 18:58:19 +0000624 pjsip-apps/bin directory, and the libraries in lib directory under each
625 projects.
626
627 To build the samples:
628 1. (Still using the same workspace)
629 2. Set samples project as Active Project
630 3. Select Debug or Release build as appropriate.
631 4. Build the project. This will build all sample applications and all
632 libraries needed.
633 5. After successful build, the sample applications will be placed in
634 pjsip-apps/bin/samples directory, and the libraries in lib directory
635 under each projects.
636
637 4.3 Debugging the Sample Application
638 _________________________________________________________________
639
640 The sample applications are build using Samples.mak makefile, therefore it
641 is difficult to setup debugging session in Visual Studio for these
642 applications. To solve this issue, the pjsip_apps workspace contain one
643 project called sample_debug which can be used to debug the sample
644 application.
645
646 To setup debugging using sample_debug project:
647 1. (Still using pjsip_apps workspace)
648 2. Set sample_debug project as Active Project
649 3. Edit debug.c file inside this project.
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000650 4. Modify the #include line to include the particular sample application to
651 debug
Benny Prijonoc3416832006-09-12 18:58:19 +0000652 5. Select Debug build.
653 6. Build and debug the project.
654
655
6565. Building for Windows Mobile Targets (Windows CE/WinCE/PDA/SmartPhone)
657 _________________________________________________________________
658
659 PJ supports building SIP and media stacks and applications for Windows
660 Mobile targets. A very simple WinCE SIP user agent (with media) application
661 is provided just as proof of concept that the port works.
662
663 5.1 Requirements
664 _________________________________________________________________
665
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000666 One of the following development tools is needed to build SIP and media
667 components for Windows Mobile:
Benny Prijonoc3416832006-09-12 18:58:19 +0000668 * Microsoft Embedded Visual C++ 4 with appropriate SDKs, or
669 * Microsoft Visual Studio 2005 for Windows Mobile with appropriate SDKs.
670
671 Note that VS2005 is not directly supported (as I don't have the tools), but
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000672 it is reported to work (I assumed that VS2005 for Windows Mobile can import
673 EVC4 workspace file).
Benny Prijonoc3416832006-09-12 18:58:19 +0000674
675 5.2 Building the Projects
676 _________________________________________________________________
677
678 The Windows Mobile port is included in the main source distribution. Please
679 follow the following steps to build the WinCE libraries and sample
680 application:
681 1. Open pjsip-apps/build/wince-evc4/wince_demos.vcw workspace file. If
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000682 later version of EVC4 is being used, this may cause the workspace file
683 to be converted to the appropriate format.
Benny Prijonoc3416832006-09-12 18:58:19 +0000684 2. Select pjsua_wince project as the Active Project.
685 3. Select the appropriate SDK (for example Pocket PC 2003 SDK or SmartPhone
686 2003 SDK)
687 4. Select the appropriate configuration (for example, Win32 (WCE Emulator
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000688 Debug) to debug the program in emulator, or other configurations such as
689 ARMV4, MIPS, SH3, SH4, or whatever suitable for the device)
Benny Prijonoc3416832006-09-12 18:58:19 +0000690 5. Select the appropriate device (Emulator or the actual Device).
691 6. Build the project. This will build the sample WinCE application and all
692 libraries (SIP, Media, etc.) needed by this application.
693
694 Notes
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000695
696 + If the config_site.h includes config_site_sample.h file, then
697 there are certain configuration in config_site_sample.h that get
698 activated for Windows CE targets. Please make sure that these
699 configurations are suitable for the application.
700 + The libraries, binaries and object files produced by the build
701 process are located under build/wince-evc4/output directory of each
702 projects.
Benny Prijonoc3416832006-09-12 18:58:19 +0000703
704
Benny Prijono81d89ea2007-02-02 20:49:33 +00007056. Older PJLIB Build System for Non-Autoconf Targets (e.g. RTEMS)
706 _________________________________________________________________
707
708 The old PJLIB build system can still be used for building PJ libraries, for
709 example for RTEMS target. Please see the Porting PJLIB page in PJLIB
710 Reference documentation for information on how to support new target using
711 this build system.
712
713 6.1 Supported Targets
714 _________________________________________________________________
715
716 The older build system supports building PJ libraries for the following
717 operating systems:
718 * RTEMS
719 * Linux
720 * MacOS X
721 * Cygwin and Mingw
722
723 And it supports the following target architectures:
724 * i386, x86_64, itanium
725 * ARM
726 * mips
727 * powerpc
728 * mpc860
729 * etc.
730
731 For other targets, specific files need to be added to the build system,
732 please see the Porting PJLIB page in PJLIB Reference documentation for
733 details.
734
735 6.2 Invoking the Build System
736 _________________________________________________________________
737
738 To invoke the older build system, run the following:
739
740
741
742 $ cd pjproject
743 $ ./configure-legacy
744 $ make dep && make clean && make
745
746
747
7487. Running the Applications
749 _________________________________________________________________
750
751 Upon successful build, the output libraries (PJLIB, PJLIB-UTIL, PJMEDIA,
752 PJSIP, etc.) are put under ./lib sub-directory under each project directory.
753 In addition, some applications may also be built, and such applications will
754 be put in ./bin sub-directory under each project directory.
755
756
757 7.1 pjsua
758 _________________________________________________________________
759
760 pjsua is the reference implementation for both PJSIP and PJMEDIA stack, and
761 is the main target of the build system. Upon successful build, pjsua
762 application will be put in pjsip-apps/bin directory.
763
764 pjsua manual can be found in pjsua Manual Page.
765
766
767 7.2 Sample Applications
768 _________________________________________________________________
769
770 Sample applications will be built with the Makefile build system. For Visual
771 Studio, you have to build the samples manually by selecting and building the
772 Samples project inside pjsip-apps/build/pjsip_apps.dsw project workspace.
773
774 Upon successful build, the sample applications are put in
775 pjsip-apps/bin/samples directory.
776
777 The sample applications are described in PJMEDIA Samples Page and
778 PJSIP Samples Page in the website.
779
780
781 7.3 pjlib-test
782 _________________________________________________________________
783
784 pjlib-test contains comprehensive tests for testing PJLIB functionality.
785 This application will only be built when the Makefile build system is used;
786 with Visual Studio, one has to open pjlib.dsw project in pjlib/build
787 directory to build this application.
788
789 If you're porting PJLIB to new target, it is recommended to run this
790 application to make sure that all functionalities works as expected.
791
792
793 7.4 pjsip-test
794 _________________________________________________________________
795
796 pjsip-test contains codes for testing various SIP functionalities in PJSIP
797 and also to benchmark static performance metrics such as message parsing per
798 second.
799
800
801
8028. Using PJPROJECT with Applications
Benny Prijonoc3416832006-09-12 18:58:19 +0000803 _________________________________________________________________
804
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000805 Regardless of the build system being used, the following tasks are normally
806 needed to be done in order to build application to use PJSIP and PJMEDIA:
807 1. Put these include directories in the include search path:
Benny Prijonoc3416832006-09-12 18:58:19 +0000808 + pjlib/include
809 + pjlib-util/include
810 + pjmedia/include
811 + pjsip/include
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000812 2. Put these library directories in the library search path:
Benny Prijonoc3416832006-09-12 18:58:19 +0000813 + pjlib/lib
814 + pjlib-util/lib
815 + pjmedia/lib
816 + pjsip/lib
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000817 3. Include the relevant PJ header files in the application source file. For
818 example, using these would include ALL APIs exported by PJ:
Benny Prijonoc3416832006-09-12 18:58:19 +0000819
820 #include <pjlib.h>
821 #include <pjlib-util.h>
822 #include <pjsip.h>
823 #include <pjsip_ua.h>
824 #include <pjsip_simple.h>
825 #include <pjsua.h>
826 #include <pjmedia.h>
827 #include <pjmedia-codec.h>
828 (Note: the documentation of the relevant libraries should say which
829 header files should be included to get the declaration of the APIs).
830 4. Declare the OS macros.
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000831 + For Windows applications built with Visual Studio, we need to
832 declare PJ_WIN32=1 macro in the project settings (declaring the
833 macro in the source file may not be sufficient).
834 + For Windows Mobile applications build with Visual C++, we need to
835 declare PJ_WIN32_WINCE=1 macro in the project settings.
836 + For GNU build system/autoconf based build system, we need to
837 declare PJ_AUTOCONF=1 macro when compiling the applications.
Benny Prijonoc3416832006-09-12 18:58:19 +0000838 (Note: the old PJ build system requires declaring the target processor
839 with PJ_M_XXX=1 macro, but this has been made obsolete. The target
840 processor will be detected from compiler's predefined macro by
841 pjlib/config.h file).
842 5. Link with the appropriate PJ libraries. The following libraries will
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000843 need to be included in the library link specifications:
Benny Prijonoc3416832006-09-12 18:58:19 +0000844
845 pjlib
846 Base library used by all libraries.
847
848 pjlib-util
849 Auxiliary library containing scanner, XML, STUN, MD5, getopt,
850 etc, used by the SIP and media stack.
851
852 pjsip
853 SIP core stack library.
854
855 pjsip-ua
856 SIP user agent library containing INVITE session, call
857 transfer, client registration, etc.
858
859 pjsip-simple
860 SIP SIMPLE library for base event framework, presence, instant
861 messaging, etc.
862
863 pjsua
864 High level SIP UA library, combining SIP and media stack into
865 high-level easy to use API.
866
867 pjmedia
868 The media framework.
869
870 pjmedia-codec
871 Container library for various codecs such as GSM, Speex, and
872 iLBC.
873
874
875 Note: the actual library names will be appended with the target name and the
876 build configuration. For example:
877
878 For Visual Studio builds
879 The actual library names will look like
880 pjlib-i386-win32-vc6-debug.lib,
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000881 pjlib-i386-win32-vc6-release.lib, etc., depending on whether we
882 are building the Debug or Release version of the library.
883
884 An easier way to link with the libraries is to include PJ
885 project files in the workspace, and to configure project
886 dependencies so that the application depends on the PJ
887 libraries. This way, we don't need to manually add each PJ
888 libraries to the input library file specification, since VS
889 will automatically link the dependency libraries with the
890 application.
891
892 For Windows Mobile builds
893 Unfortunately the PJ libraries built for Windows Mobile will
894 not be placed in the usual lib directory, but rather under the
895 output directory under build/wince-evc4 project directory.
896
897 An easier way to link with the libraries is to include PJ
898 project files in the workspace, and to configure project
899 dependencies so that the application depends on the PJ
900 libraries. This way, we don't need to manually add each PJ
901 libraries to the input library file specification, since VS
902 will automatically link the dependency libraries with the
903 application.
Benny Prijonoc3416832006-09-12 18:58:19 +0000904
905 For GNU builds
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000906 Application's Makefile can get the PJ library suffix by
907 including PJ's build.mak file from the root PJ directory (the
908 suffix is contained in TARGET_NAME variable). For example, to
909 link with PJLIB and PJMEDIA, we can use this syntax in the
910 LDFLAGS: "-lpj-$(TARGET_NAME) -lpjmedia-$(TARGET_NAME)"
Benny Prijonoc3416832006-09-12 18:58:19 +0000911
912
Benny Prijono646b7b72006-10-21 18:28:07 +0000913 6. Link with system spesific libraries:
914
915 Windows
916 Add (among other things): wsock32.lib, ws2_32.lib, ole32.lib,
917 dsound.lib
918
919 Linux, *nix, *BSD
920 Add (among other things): '-lpthread -lm' (at least).
921
922 MacOS X
923 Add (among other things): '-framework CoreAudio -lpthread -lm'.
924
925
Benny Prijonoc3416832006-09-12 18:58:19 +0000926Appendix I: Common Problems/Frequently Asked Question (FAQ)
927 _________________________________________________________________
928
929 I.1 fatal error C1083: Cannot open include file: 'pj/config_site.h': No such
930 file or directory
931
Benny Prijonoabd2ae92006-09-13 11:02:26 +0000932 This error normally occurs when the config_site.h file has not been created.
933 This file needs to be created manually (an empty file is sufficient). Please
934 follow the Build Preparation instructions above to create this file.
Benny Prijonoc3416832006-09-12 18:58:19 +0000935
936
937
938
939
940
Benny Prijono646b7b72006-10-21 18:28:07 +0000941
942
943 _________________________________________________________________
944
945 Feedback:
946 Thanks for using PJ libraries and for reading this document. Please
947 send feedbacks or general comments to <bennylp at pjsip dot org>.
Benny Prijonoeec4d7c2006-03-09 16:19:20 +0000948