oSip and eXosip
I set out to understand linphone source code so I decided to learn SIP and tried to built a terminal SIP client. A simple one. No voice, no nothing, just to perform signalling, registering to SIP registrar. That's all.
I started out by learning oSip. I found out later that oSip is lower level, suitable to build lower level service like SIP proxies or registrars, but too cumbersome to build SIP clients. eXosip is more suitable (=easier to use) to build SIP clients since eXosip is a higher layer abstraction over oSip.
Anyway, I'll tell my story with oSip first. So I installed both osip and exosip on my Ubuntu using the default packaged.
sudo apt-get install libexosip2-dev
The above command will automatically install libosip2 since libosip2 is libexosip2's dependency. I adapted wen's tutorial here for Linux (he wrote it for Windows).
From oSip mailing list, Aymeric Moizard (oSip and eXosip author) told me that the packaged lib is outdated. The Ubuntu packaged library is version 3 (while the latest is version 4) and I needed to compile my source files using the switch -DOSIP_MT . I don't need to use that option if I compile and link my source against the latest (v4) library.
I then decided to download the latest (version 4 as of this writing) oSip and eXosip source from the GNU repo and compiled and installed them on my own. The library is installed inside /usr/local/lib.
When reading the README of eXosip, it told me to install c-ares for asynchronous network operation, so I did that too.
There are quite some things that I learnt during compilation with these libraries.
First of all, I need to run ldconfig as a root right after I install the libraries. I don't really understand why, but otherwise I get numerous errors when compiling and then linking against the newly installed libraries.
Since I have two kinds of osip and exosip (one installed by apt-get, one manually installed), I need to tell the compiler which lib I want to use. I want to compile against the latest, which is manually installed, so this compiler option is necessary:
-L/usr/local/lib
It tells the compiler the location of my library. I also learnt how library naming system works. Library names end with .a extension and starts with the substring lib. For instance, the following is the result of doing ls /usr/local/lib on my system:
If you want to link against a certain library, then strip the lib and the extension from the library name, and prepend -l to it and use it as compiler option. So if you want to link against libeXosip2.a, you put this as compiler option:
-leXosip2
Or you can also use the cumbersome and longer form:
g++ myfile.c /path/to/my/libeXosip.a
Anyway, the following is my simple Makefile to compile my eXosip source:
exosip: exosip.c
g++ -L/usr/local/lib -Wall -g exosip.c -o exosip -leXosip2 -lcares -DENABLE_TRACE
I needed to remove -DENABLE_TRACE (against what the README recommended) because it gave me errors. I need to find out why.
I started out by learning oSip. I found out later that oSip is lower level, suitable to build lower level service like SIP proxies or registrars, but too cumbersome to build SIP clients. eXosip is more suitable (=easier to use) to build SIP clients since eXosip is a higher layer abstraction over oSip.
Anyway, I'll tell my story with oSip first. So I installed both osip and exosip on my Ubuntu using the default packaged.
sudo apt-get install libexosip2-dev
The above command will automatically install libosip2 since libosip2 is libexosip2's dependency. I adapted wen's tutorial here for Linux (he wrote it for Windows).
From oSip mailing list, Aymeric Moizard (oSip and eXosip author) told me that the packaged lib is outdated. The Ubuntu packaged library is version 3 (while the latest is version 4) and I needed to compile my source files using the switch -DOSIP_MT . I don't need to use that option if I compile and link my source against the latest (v4) library.
I then decided to download the latest (version 4 as of this writing) oSip and eXosip source from the GNU repo and compiled and installed them on my own. The library is installed inside /usr/local/lib.
When reading the README of eXosip, it told me to install c-ares for asynchronous network operation, so I did that too.
There are quite some things that I learnt during compilation with these libraries.
First of all, I need to run ldconfig as a root right after I install the libraries. I don't really understand why, but otherwise I get numerous errors when compiling and then linking against the newly installed libraries.
Since I have two kinds of osip and exosip (one installed by apt-get, one manually installed), I need to tell the compiler which lib I want to use. I want to compile against the latest, which is manually installed, so this compiler option is necessary:
-L/usr/local/lib
It tells the compiler the location of my library. I also learnt how library naming system works. Library names end with .a extension and starts with the substring lib. For instance, the following is the result of doing ls /usr/local/lib on my system:
If you want to link against a certain library, then strip the lib and the extension from the library name, and prepend -l to it and use it as compiler option. So if you want to link against libeXosip2.a, you put this as compiler option:
-leXosip2
Or you can also use the cumbersome and longer form:
g++ myfile.c /path/to/my/libeXosip.a
Anyway, the following is my simple Makefile to compile my eXosip source:
exosip: exosip.c
g++ -L/usr/local/lib -Wall -g exosip.c -o exosip -leXosip2 -lcares -DENABLE_TRACE
I needed to remove -DENABLE_TRACE (against what the README recommended) because it gave me errors. I need to find out why.
0 komentar:
Posting Komentar