Tampilkan postingan dengan label Linphone. Tampilkan semua postingan
Tampilkan postingan dengan label Linphone. Tampilkan semua postingan

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.

Installing Linphone for Ubuntu

As is always the case with Linphone, there are many steps not written in the README that one needs do.

First get linphone:

git clone git://git.linphone.org/linphone.git --recursive


And then, do the following (I'm on Ubuntu. If your on other distros the lib name might be different!)


sudo apt-get install libgtk2.0-dev
sudo apt-get install intltool
sudo apt-get install libosip2-dev
sudo apt-get install libexosip2-dev
sudo apt-get install libspeex-dev
sudo apt-get install libspeexdsp-dev
sudo apt-get install ffmpeg
sudo apt-get install libavcodec-dev
sudo apt-get install libswscale-dev
sudo apt-get install libxv-dev
sudo apt-get install libv4l-dev

Lib name is case sensitive and differ from platform to platform. To know the exact lib name, you can go to http://pkgs.org/search and enter the common lib name (as is mentioned in the README) in the search field in the top right corner. The site will then list the exact library name for your distro and how to install it. Very convenient!

After all the above directories are installed, enter the directory where you git pulled linphone and do:

./autogen.sh
./configure
make
sudo make install

Last step, you need to have the shared dynamic library generated during linphone compilation into your path. I added the following line to my ~/.profile

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

And then I restarted my machine to make the changes in profile takes permanent effect.

Now linphone is installed in /usr/local/bin and just type:

linphone

from terminal to execute it.

Compile linphone for iPhone

My environment is Mac OS X Lion, newest macports (version 2.1.2). I followed the README down to each letter but errors were returned. The tools in the newest version of Macports have different requirements than the older ones used to write the README.

I then submitted a question to the linphone mailing list and got an answer. As follow:

Arek,

I've been struggling with this for days. It's mystifying to me that it was so hard to get working. I'm using Mountain Lion, Xcode 4.5, and iOS 6. I wonder if perhaps MacPorts is now installing newer versions of the tools required by the install guide.

At any rate, I just got Linphone fully built earlier today. To fix your 'install-sh' problem, you just need to create an empty file that is required by newer versions of autoconf:
> 'touch submodules/linphone/install-sh

At this point, I was stumped for a very long time by another error: 
> ./configure: line 4543: syntax error near unexpected token `HAVE_MD5SUM,test'
> ./configure: line 4543: `AM_CONDITIONAL(HAVE_MD5SUM,test -n $MD5SUM)'
As it turned out, the problem was again triggered by a line in configure.ac:
> configure.ac:42: error: 'AM_PROG_CC_STDC': this macro is obsolete.

The solution was to edit submodules/linphone/configure.ac and delete the line that says:
AM_PROG_CC_STDC
You will need to 'make veryclean' or run 'cd build/linphone; ./autogen.sh'

Incidentally, while working through this I also figured out the necessary steps to replace MacPorts with brew which has the advantage of being more self-contained and easily reversible than MacPorts.
1) Install brew: (instructions at http://mxcl.github.com/homebrew/)
2) Install dependencies:
brew install coreutils automake autoconf libtool intltool 
brew install wget pkgconfig cmake gmake yasm doxygen ImageMagick optipng
brew tap homebrew/dupes
brew install xz homebrew/dupes/grep

Linphone is hardcoded to look for a lot of tools in MacPorts-specific locations, (e.g. /opt/local/bin) so I also had to create a link from there to brew's standard install location: 'ln -s /usr/local /opt/local'

Good luck!
Eli

On Jan 15, 2013, at 12:00 PM, linphone-developers-request@nongnu.org wrote:

> Message: 1
> Date: Tue, 15 Jan 2013 16:08:36 +0800 (SGT)
> From: Firman 
> To: linphone-developers@nongnu.org
> Subject: [Linphone-developers] liblinphone SDK build failed.
> Message-ID:
>     <1358237316.44153.YahooMailClassic@web193306.mail.sg3.yahoo.com>
> Content-Type: text/plain; charset="iso-8859-1"

> Hi everybody,
> I have sifted through the mailing list archives but have not found anyone posting the same build failure problem as mine.

> So I cloned the git repo for iPhone
> git clone 
> git://git.linphone.org/linphone-iphone.git?--recursive

> and then followed everything that the README file says about how to build the liblinphone SDK down to each letter. And then I do

> sudo make all.

> It failed first with the following error:

> Generating configuration files for Speex, please wait....
> ? aclocal 
> configure.ac:5: error: 'AM_CONFIG_HEADER': this macro is obsolete.
> ??? You should use the 'AC_CONFIG_HEADERS' macro instead.
> /opt/local/share/aclocal-1.13/obsolete-err.m4:12: AM_CONFIG_HEADER is expanded from...
> configure.ac:5: the top level
> autom4te: /opt/local/bin/gm4 failed with exit status: 1
> aclocal: error: echo failed with exit status: 1
> make[1]: *** [/Users/barablu/Documents/workspace/liniphone/linphone-iphone/submodules/build/..//externals/speex/configure] Error 1
> make: *** [build] Error 2

> I then changed line 5 of configure.ac in speex directory from 
> AM_CONFIG_HEADER to AC_CONFIG_HEADERS. That error went away but now I get the following error that I have no clue how to solve. Can anybody please help me? I'm using XCode 4.5, iOS SDK 6, Mac OS X Lion. Thank you.

> Best regards,
> Arek Malang

> configure: loading site script /Users/barablu/Documents/workspace/liniphone/linphone-iphone/submodules/build/..//build/iphone-config.site
> Loading config.site for iPhone platform=Simulator version=4.0
> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk
> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk
> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk
> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk
> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
> /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
> Selecting SDK path = /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk
> configure: error: cannot find install-sh, install.sh, or shtool in "/Users/barablu/Documents/workspace/liniphone/linphone-iphone/submodules/build/..//linphone" "/Users/barablu/Documents/workspace/liniphone/linphone-iphone/submodules/build/..//linphone/.." "/Users/barablu/Documents/workspace/liniphone/linphone-iphone/submodules/build/..//linphone/../.."
> make[1]: *** [/Users/barablu/Documents/workspace/liniphone/linphone-iphone/submodules/build/../build-i386-apple-darwin/linphone/Makefile] Error 1
> make: *** [build] Error 2

Compile linphone for Android

Compiling linphone has always been a challenge for me. Even after following the README down to each letter, I always get errors. Compiling linphone for Android is no difference.

So I followed the README, got everything installed, and did make.

And I ended up with numerous such errors:

Fatal error: invalid -march= option: `armv5te'

After a while, I figured out that it was caused by failure in cross compilation. So linphone uses a lot of libraries written for intel (desktop) processors. Those libraries need to be cross compiled for ARM. I failed at this stage.

So to summarize, the following are the steps needed to compile linphone for Android. These steps are taken from the README, with my comments inside the parentheses.
(My OS is Ubuntu 12).

0) download the Android sdk with platform-tools and tools updated to latest revision (at least API 16 is needed), then add both 'tools' and 'platform-tools' folders in your path.
1) download the Android ndk (>=r8b) from google and add it to your path.
2) install the autotools: autoconf, automake, aclocal, libtoolize pkgconfig (On my Ubuntu, aclocal is part of automake. pkgconfig is in a package called pkg-config and already installed. libtoolize is in a package called libtool. So actually I had to: sudo apt-get install automake autoconf libtool)
3) install the code sourcery toolchain. This step is crucial as the toolchain is needed for succesful cross compilation. This step is not mentioned in the README!!!!

So to install the sourcery toolchain, do these steps:
1. Get the binary from sourcery.mentor.com. Get the binary for Linux, not the source, to save you from compilation headache. The filename is: arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2. You have to register, agree to some formalities, and then download it.
2. Unzip it. Preferable to a subdir inside the /opt dir to make it look pro.
3. Add path to the bin directory inside the unzipped directory to your path.

And then, done. Follow the readme to make and make install and you'll compile with success.