19 March 2011

INSTALL XML-RPC DI UBUNTU 10.10

INSTALL XML-RPC DI UBUNTU 10.10

Silahkan baca dan coba
http://wonderfuldream.tistory.com/179
https://trac.macports.org/ticket/15443

This is for those who are trying (struggling) to make XML RPC applications using C/C++ under linux (Ubuntu) platform. In fact, I've played around with a couple of open source libraries to develop C++ XML RPC server and client application last several months.

After several trials and errors, I reckon xmlrpc-c library is the ever-existing most strong and competent library for XML-RPC application development considering others don't support server side multi-threading architecture, secure authentication and authorization mechanism and many more. Honestly, I am not linux guru (at all) or whatever that you can't solely rely on this information. I strongly recommend you to have some level of openness for this jobs. Just do try and read error messages carefully.

Everything on the web is born to be quite volatile. Likewise, i am not sure how long this information last.
Any questions regarding build issues, just google it like what i did. Google JUST know everything. For this article, you could ask me directly. But, I didn't say i can answer it. ;)


1. Prerequisites

Check whether below libraries are installed on your system. Otherwise, install before you play around with xmlrpc-c lib using Ubuntu software centre.

libxmlrpc-core-c3
libxmlrpc-core-c3-dev
libxmlrpc-c3
libxmlrpc-c3-dev
libcurl3-dbg
libcurl4-openssl-dev

Last two libcurl* library becomes important if you are using this libs for xmlrpc client development. Without these two libs, sample client applications comes with library itself do not be compiled. And more importantly, make sure your platform is 32 bit version of Ubuntu. In my case, i installed Ubuntu using wubi installer.

If you just downloaded and installed via wubi, its installation default setting is 64 bit which is error-prone environment for xmlrpc-c development. If you are going to use wubi installer, rather than double-clicking it, open command and type below.

> wubi --32bit

This would force wubi to install 32 bit Ubuntu.


2. Download XMLRPC-C library

You can get xmlrpc-c library through source forge website (http://sourceforge.net/projects/xmlrpc-c/)
Via the link above you could download two types of libraries. The one is Ubuntu package (*.deb) and the other is tar ball.

I recommend you to download tarball and build yourself rather than installing package because i personally suffered package installation failure. It possibly related to some sort of dependency error - as error message means - and i couldn't resolve it. As of today (14, Oct, 2010), the latest super stable version of xmlrpc-c library is 1.06.41. You may know how to unzip tarballed file. ($tar -xvzf filename)


3. Installation

It's relatively easy if you followed from the top without any issues. It's all about configure, make and make install. For your assurance and mental health, it's always better idea to do this kind of stuffs under root account. In Ubuntu, it's sudo as you may already know. Then, it becomes like below.

$sudo ./configure
$sudo make
$sudo make install

if there is no error message when you complete above commands, then you are almost there. (congratulation!) But the reality is not that simple as always. If you encountered some error messages during configure and make. It's may be related to file linkage problem. Check /usr/local/include directory, there must be xmlrpc_client.h symbolic link file which points to xmlrpc-c/client.h. However, you might have found the symbolic linkage has broken (it's red-colored). Actually there is no such name of file(client.h) under the path of /usr/local/include/xmlrpc-c. Then you have to copy that file from somewhere else.
You can find the file(client.h) from your_download_path/xmlrpc-c-1.06.41/include/xmlrpc-c directory. Just copy the file into above directory to rebuild the link, and repeat above commands. Now check whether the build is successful using browsing your_download_path/xmlrpc-c-1.06.41/examples directory. If you can find xmlrpc_sample_add_client and xmlrpc_sample_add_server binaries, then you succeeded.


PATCH

I just installed macports and wanted to install xmlrpc-c. Curl was installed before xmlrpc-c due to another package depending on it, and still the same error as above is thrown when xmlrpc-c is being built.

A quick search on google reveals, that Gentoo and Debian have similar problems when installing xmlrpc-c against curl-7.18.1 (7.18.2 is the version macports installed)
http://bugs.gentoo.org/216139 provides a patch to solve this error (within xmlrpc-c NOT curl)
Line 1217 in lib/curl_transport/xmlrpc_curl_transport.c reads:

curl_easy_setopt(curlSessionP, CURLOPT_SSLENGINE_DEFAULT); 

needing to be corrected to

curl_easy_setopt(curlSessionP, CURLOPT_SSLENGINE_DEFAULT,1); 

As suggested by the patch from gentoo I manually changed it after xmlrpc-c failed and this solved the problem instantly, and xmlrpc-c compiled fine.
Maybe macports can supply a patch for all others?

Here's the gentoo patch in raw text, seeing as I don't know how to commit it to the ports. Note that the line needs to be changed to 1217 (aswell as adapting the version), for xmlrpc-c 1.06.11!!

--- xmlrpc-c-1.06.09/lib/curl_transport/xmlrpc_curl_transport.c.orig 2008-04-06 18:34:12.000000000 +0200 +++ xmlrpc-c-1.06.09/lib/curl_transport/xmlrpc_curl_transport.c 2008-04-06 18:34:35.000000000 +0200 @@ -1214,7 +1214,7 @@              curl_easy_setopt(curlSessionP, CURLOPT_SSLENGINE,                               curlSetupP->sslEngine);          if (curlSetupP->sslEngineDefault) -            curl_easy_setopt(curlSessionP, CURLOPT_SSLENGINE_DEFAULT); +            curl_easy_setopt(curlSessionP, CURLOPT_SSLENGINE_DEFAULT,1);          if (curlSetupP->sslVersion != XMLRPC_SSLVERSION_DEFAULT)              curl_easy_setopt(curlSessionP, CURLOPT_SSLVERSION,                               curlSetupP->sslVersion); 

regards,
-Brian