2013/03/12

[工作點滴] pjsip on ubuntu

Before trying to make the pjsip work on my embedded device, I build the related libraries on PC as the reference. My environment is based Ubuntu 10.04. See the following guide.

The notes of packages building:
- ALSA and OpenSSL libraries are optional and I do not install for first.
- SDL, I download the version 2.0 and do "./configure", "make; make install" to install the package to system. If we encounter privilege problem, please add sudo.
- FFMPEG, please reference the document on FFMPEG official site. The link is as following. https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide
There are links for different version of the Ubuntu. We could follow the guide to build yasm, x264 and ffmpeg. The ffmpeg version(0.10.6) and building process is following pjsip guide.
- PJSIP, I follow the guide to add the "#define PJMEDIA_HAS_VIDEO 1" in config_site.h and do the "./configure". The weird thing is that the package still can be built whatever the definition is exist or not. Then "make dep", "make" and "make install"(optional).

It's not hard to build the packages but there are some uncertainty to me. Now let's quickly build an application with GNU tools.
There is an error occur when make.
cc -o myapp myapp.cpp `pkg-config --cflags --libs libpjproject`
/tmp/cczRrbTp.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [myapp] Error 1

There are two ways to solve this. One is change the myapp.cpp to be myapp.c and another way is to add -lstdc++ in the Makefile.
# Makefile
all: myapp
myapp: myapp.cpp
    $(CC) -o $@ $< `pkg-config --cflags --libs libpjproject` -lstdc++
clean:
    rm -f myapp.o myapp

The myapp.cpp code.
/* pjsip applicaiton */
#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()
{
    printf("hello pjsip\n");
    return 0;
}

Okay, that's all and we could start our application.

沒有留言: