Recently, I was involved in an xmpp protocol-related project. I need to find an xmpp library under c to help with development. The c library on xmpp.org is poor. Iksemel is too low-level, and is an xml parser. It only supports jabber. You must write your own network connection and logon. libstrophe cannot find the manual, the only one found seems to be for javascript. Finally, I saw the loudmouth guy. The current version is 1.4.3. I have never done such a level of work before. This is the first time, and some problems will inevitably occur in the process. I wrote about my learning process and encountered problems. Of course, there is still a solution! 1. Learn xmpp
The first is to learn xmpp protocol, mainly RFC3920 [XMPP-CORE] And RFC3921 [XMPP-IM. The xmpp paper recommended by the boss is indeed very good: <Extensible Messaging and Presence Protocol>
By Mikko Laukkanen, after reading this paper, I have a good understanding of xmpp. The server in our office has an xmpp server, so you can log on to a client directly. If not, gtalk is based on xmpp. It should be) 2. loudmouth library compilation and Installation The installation process is mainly linux trilogy./configure
Make
Make install but I encountered a problem in./configure. The error is that the glib version is too low. Finally, I installed ubuntu9.04 in vmware, and then installed glib2.13 to the/usr directory. Here, the installation process is relatively simple and passes through a few places. For example, if there is a glib before, but the version is relatively low, I suggest you, it would be better to reinstall a newer version of linux, Because I encountered the problem that the glib version was too low on rh9, and it took some time to upgrade glib, at last, we had to reinstall ubuntu to solve the problem. Remember to add the parameter -- prefix =/usr when installing/usr, that is, adding the parameter to glib./configure. 3. loudmouth call In this way, you can directly run the test program under the examples directory. However, a problem is found here, that is, the test programs that come with the library are all very strange. bash programs are implemented one by one, and ooxx is used. In short, the makefile under examples is very complex and automatically generated. Here I encountered a problem: how do we call the loudmouth function in our own program? Try to write test. c and include it: // test. c # include <loudmouth/loudmouth. h>
Int main (void ){
Return 0;
} This doesn't work for gcc directly. Add some parameters contained in the directory. Note that you need loudmouth's own directory and glib ). I wrote a simple Makefile: project = test
$ (Project): $ (project). c
Gcc-o $ @-I/usr/local/include/loudmouth-1.0-I/usr/include/glib-2.0-I/usr/lib/glib-2.0/include- l/usr/local/lib-lloudmouth-1 $ <
Put it in the test. c directory and make will be fine. This does not work, run will also find the following error: error while loading shared libraries: libloudmouth-1.so.0: cannot open shared object file: No such file or directory this is ldconfig problem, for more information, see google ldconfig. Run the following command to solve the problem: echo "/usr/local/lib">/etc/ld. so. confldconfig. 4. Miscellaneous For the specific use of loudmouth, there is a detailed html format manual in its package, which seems to be quite useful. We recommend that you use a good software for code editing and reading. In addition to the editing method, source insight is a little worse than vim, I personally think it is easier than using vim + ctags + tlist. Of course, I didn't use vim to compile large programs at all, let alone the methods I use may be lacking ...... In short, you can try this insight. It can view the call status of the function itself and so on, which is very convenient.) You may need to put this thing on the arm and run it ...... There is no concept yet. I don't know if glib will find something for me again ...... I have an ominous hunch, but let's talk about it later. 2009.7.7 by Peter. Xu