IM OpenSource (Jabber)

概述

Jabber(XMPP- Extensible Messaging and Presence Protocol)协议,是一个开源的即时消息协议,建立在jabber协议上的IM客户端可以互连。关于XMPP的两个官方网http://www.xmpp.org/ http://www.jabber.org/

支持jabber协议的IM软件非常多 其中包括开源不开源的。参见:

http://www.jabber.org/clients(全部开源),主要以桌面客户端软件的形式运行,可以在一个界面上登陆msnjabbergtalk等。

http://www.laosafu.com/bbs/viewthread.php?action=printable&tid=202752(多数不开源)主要以web页面的方式提供msn,jabber,gtalk等登陆。

2       开源IM客户端比较

软件名 开源协议 开发语言及工具 运行平台 其他说明 源代码下载及说明
Pidgin GPL C/GTK 跨平台 在全球用得最广泛的一个开源IM软件 ttp://sourceforge.net下载排行第15位,下载量21,913,954
Miranda IM GPL C WIN32 windowsSDK编程,内存占用小,速度快 支持插件扩展功能, ttp://sourceforge.net下载排行第40位,下载量9,692,377
PSI GPL C++/QT+QCA 跨平台 google的官方网得到推荐使用 ttp://sourceforge.net下载排行第1782位,下载量1,943,875
Wippien GPL C++/WTL+ATL win32/linux console 需要付费才能使用它的3个组件(establish Virtual Private NetworkClient ActiveXwodAppUpdate ActiveX component  
Gajim GPL Python/C/GTK Linux,BSD及Windows 主要用PythonGTK开发  
Spark GPL Java 跨平台    

2.1          Pidgin

2.1.1 版本2.4.0

2.1.2主页: http://pidgin.im

2.1.3 源码下载http://sourceforge.net/projects/pidgin/

2.1.4 编译工具:Cygwin

2.1.5 编译步骤:

2.1.5.1  http://cygwin.com/下载setup.exe f:/Cygwin目录下 

2.1.5.2  运行setup.exe 选择【下载不安装】下载(http://kambing.vlsm.org)安装包到f:/Cygwin目录下。安装包:bzip2,coreutils,gawk,grep,gzip,make,patch,sed,monotone,tar,unzip andwget (除了粗体字外其他包是默认选择)。

2.1.5.3  安装Cygwin:运行setup.exe 选择【从本地目录安装】下一步,选择根目录C:/Cygwin和本地包目录: F:/Cygwin

2.1.5.4  运行Cygwin。运行界面会提示你是第一次运行Cygwin 并自动设置home环境变量目录C:/cygwin/home.(注意home环境变量中不要包含空格或中文字符要不然会给你后面的工作带来麻烦,如果home环境变量已经被设置为C:/Documents and Settings,可以在我的电脑/属性/高级/环境变量删除home环境变量。从新启动Cygwin。另外我相信Cygwin 也有设置环境变量的命令)

2.1.5.5  输入命令 “wget http://gaim-extprefs.sf.net/winpidgin-build-fetcher.sh”并回车.

2.1.5.6  在当前目录执行命令“bash winpidgin-build-fetcher.sh”。当执行该命令时会自动在C:/cygwin/home/Administrator/pidgin-temp目录下载一些编译pidgin要用到的软件包 如图:1-1

图1-1

下载完这些包后就自动安装这些软件包,最后自动下载pidgin-2.4.0源码包。Home 目录下文件如图1-2所示:

图1-2

2.1.5.7  最后执行 make –f Makefile.mingw install 命令(第一次运行这个命令的时候 make 出现错误,接着从新输入这个命令 make 成功) 在目录: C:/cygwin/home/Administrator/pidgin-2.4.0/win32-install-dir下生成安装文件。

2.1.5.8 同时也可以参考http://blog.csdn.net/happyhell/archive/2008/11/19/3336086.aspx该文章详细介绍了Pidgin的编译方法。

2.1.6  Pidgin源码分析:

Pidgin: pidgin is the GTK-based version of Pidgin.

Finch: Finch is the text- sion of Pbased veridgin. It supports the same IM networks, but you can run it in a console window. You can use it on Linux, BSD, and other Unixes.

Libpurple: libpurple is the programming library that powers Pidgin and Finch. It”s responsible for connecting to all the IM networks, and for managing your accounts and preferences. It”s written in C and makes heavy use of Glib.

 

2.1.6 :

Cygwin: Cygwin is a Linux-like environment for Windows. It consists of two parts: A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.  A collection of tools which provide Linux look and feel.

MinGW:  A collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU toolsets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs.

2.2  Miranda(迷人安达)

2.2.1 版本0.7.3

2.2.2 主页: http://www.miranda-im.org/

2.2.3 源码下载: http://sourceforge.net/projects/miranda/

2.2.4 编译工具:VS2005

2.2.5 编译步骤:

2.2.5.1源代里面的工程是VC6.0 VS2005 工具打开(VC6工程转换成VC8)并在解决方案里移除vc6.rc文件,添加resource.hresource.rcversion.rc文件。

2.2.5.3  编译工程(选择生成类型为win32 unicode exe文件)。

2.2.5.4  bin/ debug unicode目录下生成miranda32.exe。目前这个文件还不能正确运行,还需要一些相关文件(相关dll文件也可以用前面提到的方法编译得到)

2.2.5.5  miranda32.exe 拷贝到miranda-im-v0.7.3-unicode(在源码下载页面里面能看到这个文件夹的下载链接)文件夹下,并替换掉以前的miranda32.exe文件。

2.2.5.6 如果你用的工具是vs2005也可以直接在目录:../Miranda   IM/miranda-im-v0.7.3-src/miranda/bin8 打开解决方案文件miranda32.sln

 

 

 

2.3.1 版本0.11

2.3.2 主页: http://psi-im.org/

2.3.3 源码下载: http://sourceforge.net/projects/psi/ 要求QT4.2.3 +QCA 2.0.

2.3.4 编译工具:VC2005

2.3.5 编译步骤:

2.3.5.1  下载QT4.3.4windows商业安装版),安装目录C:/Qt/4.3.4

2.3.5.2  下载Win32OpenSSL-0_9_8g,安装目录C:/OpenSSL

2.3.5.3  下载psi-0.11源码,解压到C:/Psi-Qt4

2.3.5.4  下载 qca-2.0.0 源码 解压到C:/Psi-Qt4

2.3.5.5  运行VC命令行工具。

2.3.5.6  编译 qca: 输入命令 cd C:/Psi-Qt4/qca-2.0.0 ;qmake;nmake;编译完毕生成binlib文件夹。

2.3.5.7  增加path环境变量:C:/Qt/4.3.4/bin; C:/Psi-Qt4/qca-2.0.0/bin; C:/Psi-Qt4/qca-2.0.0/lib;另外还需要设置QTDIR环境变量: C:/Qt/4.3.4QMAKESPEC环境变量: win32-msvc2005

2.3.5.8 设置VC++目录的包含文件C:/Psi-Qt4/qca-2.0.0/include/QtCrypto; C:/Psi-Qt4/qca-2.0.0/include; C:/Qt/4.3.4/include;库文件: C:/Psi-Qt4/qca-2.0.0/lib; C:/Qt/4.3.4/lib78步骤中有些设置不是必须的)。

2.3.5.9  编译psi-0.11: 输入命令 cd C:/Psi-Qt4/psi-0.11; qmake; nmake debug;编译完毕生成debug目录(里面包含psi.exe文件),qcad2.dll文件拷贝到该目录下。

3  开源IM服务端比较

软件名 开源协议 开发语言及工具 运行平台 其他说明 源代码下载及说明
Openfire GPL Java Windows,Linux,Mac    
ejabberd GPL Erlang Linux, Windows, MacOS X    
Jabberd 1.x GPL C Linux,Windows主要用于Linux jabberd 1.4 is the latest version of the original implementation of the jabberd server. While not supporting some of the more advanced features of the Jabber protocols, it is stable, reliable and well tested.  
Jabberd 2.x GPL C/C++ Linux,Windows主要用于Linux jabberd 2 is the next generation of the jabberd server. It has been rewritten from the ground up to be scalable, architecturally sound, and to support the latest protocol extensions coming out of the IETFand JSF.  
DJabberd GPL Perl Linux    
Jabber XCP:     Windows,Solaris,GNU/Linux    

http://swik.net/Jabber-linux/Jabber+XMPP+resource/%E5%B8%B8%E7%94%A8%E5%BC%80%E6%BA%90Jabber(XMPP)+IM%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%BB%8B%E7%BB%8D/od3z

 C/C++编程GUI库比较 

http://blog.csdn.net/lostown/archive/2006/04/11/658654.aspx.QT功能是最强大的,还支持嵌入式GUI,开发资料也比较多。QT虽然有open source版,但是开发商用用途软件必须使用商业版,而且版权贵。

Pidgin 也叫 Gaim,是一个非常出名的开源软件。由著名程序员 Sean Egan(现在在google开发Gtalk)主持开发。这个软件是一个多协议集成化的即时通讯工具,可以支持AIMBonjour Gadu-Gadu Groupwise ICQ IRC MSN QQ SILC SIMPLE Sametime XMPP Yahoo!Zephyr, 并且它还支持IRC

Miranda IM 国外一种老牌的聚合聊天软件,通过安装丰富的插件可以支持例如QQICQAIMMSNJabber (gtalk使用的协议YahooGadu-GaduNetsend以及其他一些聊天协议。

Psi也是款不错的开源软件在名气上不如前两个,关于它的介绍也比较少。

 

REF:

http://xmpp.org/xmpp-software/clients/
https://xmpp.net/directory.php
http://www.jabber.org/
http://blog.csdn.net/happyhell/article/details/3336210

How to config gtk Enviroment‎ in cygwin?

src: http://blog.sina.com.cn/s/blog_7530db6f0100qrbx.html

1) download cygwin setup from http://www.cygwin.com/

http://cygwin.com/setup-x86.exe OR http://cygwin.com/setup-x86_64.exe

 

2) select packages:

libiconv: GNU character set conversion library and utilities
libiconv2: GNU character set conversion library and utilities – runtime(1)
pkg-config: A utility used to retrieve information about installed libraries
zlib-devel: The zlib compression/decompression library (development)
zlib0: The zlib compression/decompression library (runtime)
libpng14: PNG library (1.4 runtime)
libpng14-devel: PNG library (development)
libjpeg-devel: A library for manipulating JPEG image format files (devel)
libjpeg8: A library for manipulating JPEG image format files (runtime)
libtiff-devel: TIFF image library (development)
libtiff5: TIFF image library (runtime)
libglib2.0-devel: GNOME C function library (development)
libglib2.0_0: GNOME C function library (runtime)
libatk1.0-devel: Accessibility Toolkit library (developement)
libatk1.0_0: Accessibility Toolkit library (runtime)
libpango1.0-devel: GNOME text layout and renadering library (development)
libpango1.0_0: GNOME text layout and renadering library (runtime)
libcairo-devel: Cross-device vector graphics library (development)
libcairo: Cross-device vector graphics library (runtime)
libgtk2.0-devel: Multi-platform GUI toolkit (development)
libgtk2.0_0: Multi-platform GUI toolkit (runtime)
gcc-core: C compiler
gcc-g++: C++ compiler

AND very important package:
xinit: X.Org X server initializer

 
3) write a hello world:




















 

4) compile:

$ gcc hello-world.c pkg-config gtk+-2.0 --cflags --libs
$ ls
a.exe hello-world.c
$ ./a.exe

 

if it display error like:
(a:3696): Gtk-WARNING **: cannot open display:

the reason is you not install the package “xinit“,
run cygwin setup again and select xinit, xorg-server packages, you can fixed it.

 

Ref:
http://x.cygwin.com/
http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-cant-read-lock-file
http://www.02.246.ne.jp/~torutk/cxx/gtk/GTK+ on Cygwin.html

 

how to build gcc 4.8.2 (failed)

1)download:

open http://gcc.gnu.org/mirrors.html, select one mirror

http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.gz
ftp://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2
ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz

 

2) install:

=================install GMP===================
cd gmp-5.1.3
./configure –prefix=/usr/local/gmp-5.1.3
make
sudo make install

NOTE: #if INT_MAX == 32767 cause a error in sys/config.h, I remark it

===================install mpfr & mpc==================
cd mpfr-3.1.2
./configure –with-gmp=/usr/local/gmp-5.1.3

cd mpc-1.0.2
./configure –with-gmp=/usr/local/gmp-5.1.3 –with-mpfr=/usr/local/mpfr-3.1.2

======================install gcc=========================

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.2/lib:/usr/local/gmp-5.1.3/lib:/usr/local/mpfr-3.1.2/lib

./configure –prefix=/usr/local –enable-shared –enable-shared-libgcc –enable-static –enable-version-specific-runtime-libs –enable-bootstrap –disable-__cxa_atexit –with-dwarf2 –with-tune=generic –enable-languages=c,c++ –enable-graphite –enable-threads=posix –enable-libatomic –enable-libgomp –disable-libitm –enable-libquadmath –enable-libquadmath-support –enable-libssp –disable-libgcj-sublibs –disable-java-awt –disable-symvers –disable-checking –disable-multilib  –without-ecj-jar –with-gnu-ld –with-gnu-as –without-libiconv-prefix –without-libintl-prefix –with-system-zlib –with-gmp=/usr/local/gmp-5.1.3 –with-mpfr=/usr/local/mpfr-3.1.2 –with-mpc=/usr/local/mpc-1.0.2

     make

     sudo make install

 

NOTE:

gcc-4.8.2/host-i686-pc-msys/lto-plugin/config.h,  add:
#undef HAVE_INTTYPES_H
#define uint32_t unsigned int

gcc-4.8.2/lto-plugin/lto-plugin.c,  remark:
//#include <inttypes.h>

 

how to compile pidgin?

I try to compile pidgin in mingw, but failed. there are two reasons:

a) the gcc version in msys is 3.4.4 (must be >=3.8)
b)the gcc version in mingw cannot find sys/socket.h

so I compile pidgin with cygwin.

 

 

2.1  http://cygwin.com/下载setup.exe f:/Cygwin目录下 

2.2  运行setup.exe 选择【下载不安装】下载(http://kambing.vlsm.org)安装包到f:/Cygwin目录下。安装包:bzip2,coreutils,gawk,grep,gzip,make,patch,sed,monotone,tar,unzip andwget (除了粗体字外其他包是默认选择)。

2.3  安装Cygwin:运行setup.exe 选择【从本地目录安装】下一步,选择根目录C:/Cygwin和本地包目录: F:/Cygwin

2.4  运行Cygwin。运行界面会提示你是第一次运行Cygwin 并自动设置home环境变量目录C:/cygwin/home.(注意home环境变量中不要包含空格或中文字符要不然会给你后面的工作带来麻烦,如果home环境变量已经被设置为C:/Documents and Settings,可以在我的电脑/属性/高级/环境变量删除home环境变量。从新启动Cygwin。另外我相信Cygwin 也有设置环境变量的命令)

2.5  输入命令 “wget http://gaim-extprefs.sf.net/winpidgin-build-fetcher.sh”并回车.

2.6  在当前目录执行命令“bash winpidgin-build-fetcher.sh”。当执行该命令时会自动在C:/cygwin/home/Administrator/pidgin-temp目录下载一些编译pidgin要用到的软件包 

下载完这些包后就自动安装这些软件包,最后自动下载pidgin-2.4.0源码包。

2.7  最后执行 make –f Makefile.mingw install 命令(第一次运行这个命令的时候 make 出现错误,接着从新输入这个命令 make 成功) 在目录: C:/cygwin/home/Administrator/pidgin-2.4.0/win32-install-dir下生成安装文件。

2.8 同时也可以参考http://blog.csdn.net/happyhell/archive/2008/11/19/3336086.aspx该文章详细介绍了Pidgin的编译方法。

 

 

 

 

1) change export in file “/etc/profile”
DEV_BASE=/win32-dev
PATH=$DEV_BASE/gcc-core-4.4.0-mingw32-dll/bin:$DEV_BASE/gettext-0.17/bin:$DEV_BASE/enchant_1.6.0_win32/bin:$DEV_BASE/gtk_2_0-2.14/bin:$DEV_BASE/gtkspell-2.0.16/bin:$DEV_BASE/js-1.8.5-mingw32/bin:$DEV_BASE/libcurl/bin:$DEV_BASE/libxml2-2.9.0/bin:$DEV_BASE/meanwhile-1.0.2_daa3/bin:$DEV_BASE/nss-3.13.6-nspr-4.9.2/bin:$DEV_BASE/silc-toolkit-1.1.10/bin:$DEV_BASE/sqlite3/bin:$DEV_BASE/zlib/bin:$PATH
export PATH

LD_LIBRARY_PATH=$DEV_BASE/gcc-core-4.4.0-mingw32-dll/lib:$DEV_BASE/gettext-0.17/lib:$DEV_BASE/enchant_1.6.0_win32/lib:$DEV_BASE/gtk_2_0-2.14/lib:$DEV_BASE/gtkspell-2.0.16/lib:$DEV_BASE/js-1.8.5-mingw32/lib:$DEV_BASE/libcurl/lib:$DEV_BASE/libxml2-2.9.0/lib:$DEV_BASE/meanwhile-1.0.2_daa3/lib:$DEV_BASE/nss-3.13.6-nspr-4.9.2/lib:$DEV_BASE/silc-toolkit-1.1.10/lib:$DEV_BASE/sqlite3/lib:$DEV_BASE/zlib/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

PKG_CONFIG_PATH=$DEV_BASE/gcc-core-4.4.0-mingw32-dll/lib/pkgconfig:$DEV_BASE/gettext-0.17/lib/pkgconfig:$DEV_BASE/enchant_1.6.0_win32/lib/pkgconfig:$DEV_BASE/gtk_2_0-2.14/lib/pkgconfig:$DEV_BASE/gtkspell-2.0.16/lib/pkgconfig:$DEV_BASE/js-1.8.5-mingw32/lib/pkgconfig:$DEV_BASE/libcurl/lib/pkgconfig:$DEV_BASE/libxml2-2.9.0/lib/pkgconfig:$DEV_BASE/meanwhile-1.0.2_daa3/lib/pkgconfig:$DEV_BASE/nss-3.13.6-nspr-4.9.2/lib/pkgconfig:$DEV_BASE/silc-toolkit-1.1.10/lib/pkgconfig:$DEV_BASE/sqlite3/lib/pkgconfig:$DEV_BASE/zlib/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH

 

2) change file “/etc/fstab”:

d:/pidgin/win32-dev /win32-dev
d:/pidgin/win32-dev/perl-5.10.0 /opt/perl

 

3)
cd /d/pidgin/pidgin-2.10.7

./configure —without-x –disable-gstreamer –disable-vv –disable-idn  –disable-avahi –disable-dbus –disable-nss –disable-gnutls –disable-tcl

NOTE: disable nss & gnutls : openssl MSN, Yahoo!, Novell Groupwise, Google Talk

CKEditor从word粘贴问题

在ckeditor/config.js的CKEDITOR.editorConfig = function( config ){}函数中添加如下配置

  1. //是否强制复制来的内容去除格式 plugins/pastetext/plugin.js
  2. config.forcePasteAsPlainText =false//不去除
  3. //是否使用等标签修饰或者代替从word文档中粘贴过来的内容 plugins/pastefromword/plugin.js
  4. config.pasteFromWordKeepsStructure = false;
  5. //从word中粘贴内容时是否移除格式 plugins/pastefromword/plugin.js
  6. config.pasteFromWordRemoveStyle = false
  7. config.pasteFromWordRemoveFontStyles = false;

the difference between Windows Socket & Linux Socket

src: http://blog.csdn.net/wxqian25/article/details/8252661

 

SOCKET在原理上应该是一样的,只是不同系统的运行机置有些不同。

Socket 编程 windows到Linux代码移植遇到的问题

1、一些常用函数的移植
http://www.vckbase.com/document/viewdoc/?id=1586

2、网络

socket相关程序从windows移植到linux下需要注意的

1)头文件

windows下winsock.h/winsock2.h

linux下sys/socket.h

错误处理:errno.h

其他常用函数的头文件可到命令行下用man指令查询。

2)初始化

windows下需要用WSAStartup

linux下不需要(很方便),直接可以使用

3)关闭socket

windows下closesocket(…)

linux下close(…)

4)类型

windows下SOCKET

在linux下为int类型

5)绑定地址的结构体

名称相同,都是struct sockaddr、struct sockaddr_in,这两者通常转换使用;

在Windows下面名称都是大写,而在Linux下为小写

常用:

Linux下:

sockaddr_in destAddr;

destAdd.sin_family=AF_INET;

destAddr.sin_port=htons(2030);

destAddr.sin_addr.s_addr=inet_addr(“192.168.1.1”);

Windows下:

SOCKADDR_IN destAddr;

destAddr.sin_addr.S_un.S_addr=inet_addr(“192.168.1.1”);

但结构体中成员的名称不同

Windows中结构体成员

下面的一些宏可以使windows下的程序移植到linux下(通过类型的重新定义,使代码具有linux和windows下的移植性)

  1. #ifdef WIN32
  2. typedef int socklen_t;
  3. typedef int ssize_t;
  4. #endif
  5. #ifdef __LINUX__
  6. typedef int SOCKET;
  7. typedef unsigned char BYTE;
  8. typedef unsigned long DWORD;
  9. #define FALSE 0
  10. #define SOCKET_ERROR (-1)
  11. #endif
  1. #ifdef WIN32
  2. typedef int socklen_t;
  3. typedef int ssize_t;
  4. #endif
  5. #ifdef __LINUX__
  6. typedef int SOCKET;
  7. typedef unsigned char BYTE;
  8. typedef unsigned long DWORD;
  9. #define FALSE 0
  10. #define SOCKET_ERROR (-1)
  11. #endif
6)获取错误码
windows下getlasterror()/WSAGetLastError()
linux下errno变量
7)设置非阻塞
windows下ioctlsocket()
linux下fcntl() <fcntl.h>
8)send函数最后一个参数
windows下一般设置为0
linux下最好设置为MSG_NOSIGNAL,如果不设置,在发送出错后有可 能会导致程序退出。
9)毫秒级时间获取
windows下GetTickCount()
linux下gettimeofday()
10)数据类型的一些转化
通用的:
小端到大端(网络协议使用)的转换:htonl, htons
点分十进制IP和整数之间的相互转换:inet_addr()(该函数将点分十进制转为整数),inet_aton(),inet_ntoa(),inet_pton()(linux下独有  该函数可以实现相互之间的转换)
使用到的头文件不相同,linux下用man命令查询。
另外注意:
linux下使用的套接字为伯克利套接字,因此在select()函数的使用上(第一个参数的设置)也有区别;

windows下为了与伯克利套接字匹配,第一个参数是无所谓,一般可设为0;

int maxfdp是一个整数值,是指集合中所有文件描述符的范围,即所有文件描述符的最大值加1,不能错!

3、多线程
多线程: (win)process.h –〉(linux)pthread.h
_beginthread –> pthread_create
_endthread –> pthread_exit

在windows下编译pidgin以及pidgin-plugin-lwqq

src(正解): https://github.com/xiehuc/pidgin-lwqq/wiki/Install-From-Source

另外可以参考(仅供参考):
http://blog.csdn.net/happyhell/article/details/3336086
http://blog.csdn.net/trublemaker/article/details/2316565

prepare

  1. 参考lwqq/wiki配置好编译环境
  2. 这里(http://sourceforge.net/projects/pidgin/files/Pidgin/2.10.7/pidgin-2.10.7.tar.bz2/download)下载pidgin的源代码,并且解压缩到lwqq_root/pidgin目录下,根据BuildWinPidgin编译Windows版本的Pidgin(其实主要是为了获取libpurple) 编译完成之后把该文件夹复制到lwqq_root/win32-dev/pidgin目录下.
    • bonjourd的编译依赖获取太麻烦了,所以我们这里直接修改pidgin/libpurple/protocols/Makefile.mingw.删除bonjour.
    • 一些包的名字有问题,应该是源代码不是最新的缘故:nss的那个包文件夹名字为nss-3.13.6-nspr-4.9.2以及pidgin-inst-deps-20120910
    • 在win8下编译,会因为wstcpip和winsock的冲突,导致无法编译,需要调整include的顺序。
    • 这里(http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/Previous%20Release%20gcc-4.4.0/gcc-core-4.4.0-mingw32-dll.tar.gz/download)下载并解压缩到win32-dev中
  3. 在第2步中就会获取glib的依赖,所以这里不用再做什么。如果要自己重新弄glib依赖,到这里下载:
    glib_2.28.8-1_win32.zipglib-dev_2.28.8-1_win32.zip
  4. 这里(https://osspack32.googlecode.com/files/SpiderMonkey-1.8.5_mingw32.7z)下载spider monkey的mingw32预编译好的包,解压缩到win32-dev/js-1.8.5-mingw32目录下.
  5. 需要使用在上面提供的依赖的压缩包文件,如果是随意复制其它来源的dll(如pthreadGC2.dll会导致这些dll依赖libgccsw***.dll 从而使得静态链接的libwebqq.dll失效,直接导致了pidgin退出的时候出现异常错误)

prepare directly

也可以直接下载整理好的pidgin-dependenciespidgin-lwqq-dependencies直接解压缩到win32-dev中,pidgin源代码中需要修改的文件放在了pidgin-dependencies/pidgin目录下了。

build

打开一个MinGW Shell,进入lwqq_root目录,输入

最后,就可以在build/src目录下获得libwebqq.dll. PACKAGE选项可以自动打包成zip文件,使用make package之后可以在build目录下获得zip包

install

将制作的zip包解压缩到pidgin的根目录即可。执行pidgin就可以在协议中看到WebQQ协议了。

 

=====================(以下仅供参考)==========================

建立Mingw + MSYS编译环境

网络上方法很多,笔者经过试验,选择了一个比较简单方便的安装方法。

一、到下面的网站下载MingW安装文件
http://www.tdragon.net/recentgcc/
TDM/MinGW Installer

不用MingW网站上的安装文件,是因为MingW的安装程序无法手工选择速度较快的sf.net下载网站。

安装时,先选择检查更新,然后选择安装部件,因为目的仅仅是编译pidgin,所以只选择了TDM recommanded C/C++,选择下载的镜像服务器,以大陆的网络环境,通常以选择北美的服务器速度较快。

安装位置,本人选择在:D:/MINGW

二、下载安装msys和msysDTK
google MSYS-1.0.10.exe
得到下载地址:
http://sourceforge.net/project/downloading.php?groupname=mingw&filename=MSYS-1.0.10.exe

google msysDTK-1.0.1.exe
得到下载地址:
http://sourceforge.net/project/downloading.php?groupname=mingw&filename=msysDTK-1.0.1.exe

下载完成后,2个文件都安装到安装到目录:D:/msys/1.0

msys安装到最后会出现一个Dos窗口,都选择y,当询问 MinGW 的安装路径时:
Please answer the following in the form of c:/msys Where is your MinGW installation?
输入MinGW的安装路径D:/MinGW

注意:
切不可把MSYS安装到D:/MINGW,否则,编译时会出现错误:
gcc.exe: no input files
而无法进行编译工作。

三、修改windows环境变量
进入“控制面板-系统-高级-环境变量-系统变量”,找到PATH一栏,点选“编辑”,在末尾加入以下新路径
d:/mingw/bin;D:/msys/1.0/bin;

编译pidgin

一、下载pidgin的源代码和编译所需要的各种库文件
主要参照以下pidgin文档
http://developer.pidgin.im/wiki/BuildingWinPidgin

先建立一个pidgin开发目录,如:
F:/pidgin
将pidgin的源文件,如pidgin-2.10.7.tar.bz2,存入F:/pidgin。

以下库文件存入 F:/pidgin/win32-dev 目录:

GTK+

Pidgin depends on GTK+ 2.14.7 (newer runtime versions can be used). The GTK+ All-in-one bundle contains all of GTK+’s dependencies in one zip file. Download ​gtk+-bundle_2.14.7-20090119_win32.zip and extract to $PIDGIN_DEV_ROOT/win32-dev/gtk_2_0-2.14 (you’ll need to create this directory).
Visit the ​GTK+ website for official binary and source releases.

gettext

You’ll need gettext to compile translations. Download ​gettext-tools-0.17.zip and ​gettext-runtime-0.17-1.zip. Extract both to $PIDGIN_DEV_ROOT/win32-dev/gettext-0.17 (you’ll need to create this directory).

Libxml2

Download ​libxml2-dev_2.9.0-1_win32.zip and ​libxml2_2.9.0-1_win32.zip. Extract both to$PIDGIN_DEV_ROOT/win32-dev/libxml2-2.9.0 (you’ll need to create this directory).

Perl 5.10

Install Perl 5.10 (I use ​ActivePerl), and make sure it is in your PATH. If ‘perl’ isn’t in your PATH then you will need to override the PERL variable in pidgin/local.mak. You will also need to download perl_5-10-0.tar.gz and extract to $PIDGIN_DEV_ROOT/win32-dev (it creates its own directory). This contains headers and an import lib for mingw gcc.

  • Note: If using MSYS and you installed the mingw-developer-toolkit, keep in mind that it installsmsys-perl-bin (Perl 5.6) which takes precedence over the (5.10 or newer) perl in your path, and that will cause problems! You will need to do one of the following:
    • Remove the mingw-developer-toolkit supplied (older) perl (but MAKE SURE you have mingw-get-0.2-mingw32-alpha-3 or later as previous version had issue with unlink’ing/deleting files):
    • or Set your ActivePerl 5.10 installation location at the beginning of the Cygwin-specific PATH. Assuming it is installed in c:\Perl, put something like this in your ~/.bashrc:

Tcl 8.4.5

Download and extract tcl-8.4.5.tar.gz to $PIDGIN_DEV_ROOT/win32-dev

GtkSpell

Enchant

Mozilla NSS

SILC Toolkit

Download and extract silc-toolkit-1.1.10.tar.gz to $PIDGIN_DEV_ROOT/win32-dev

 

Meanwhile

Download and extract meanwhile-1.0.2_daa3-win32.zip to $PIDGIN_DEV_ROOT/win32-dev

Bonjour SDK

Download the Bonjour SDK for Windows from ​the Apple developer website and install it to$PIDGIN_DEV_ROOT/win32-dev/Bonjour_SDK.

Note: The Bonjour SDK may install to its default location (Program Files\Bonjour SDK) regardless what you have specified during installation. In that case, simply copy everything from Program Files\Bonjour SDK to $PIDGIN_DEV_ROOT/win32-dev/Bonjour_SDK.

Cyrus SASL

Download and extract cyrus-sasl-2.1.25.tar.gz to $PIDGIN_DEV_ROOT/win32-dev
(this also contains the MIT GSSAPI module)

Intltool

Download and extract ​intltool_0.40.4-1_win32.zip to $PIDGIN_DEV_ROOT/win32-dev/intltool_0.40.4-1_win32

Crash Reporting Library

Download and extract pidgin-inst-deps-20130214.tar.gz to $PIDGIN_DEV_ROOT/win32-dev.

Get the Pidgin source code

The source for Pidgin 2.10.7 is available ​here (use the latest release if this isn’t updated yet).

The development source is available via mercurial. See UsingPidginMercurial for more information.

Build Pidgin

Run the following:

Now just wait and let your compiler do its thing. When finished, Pidgin will be in$PIDGIN_DEV_ROOT/pidgin-<version>/win32-install-dir.

 

http://sourceforge.net/projects/gtkspell/files/2.0.16/gtkspell-2.0.16.tar.gz/download
https://developer.apple.com/downloads/index.action?q=Bonjour%20SDK%20for%20Windows#
http://gstreamer.freedesktop.org/src/gstreamer/

 

安装后的目录结构如下图:

F:.
|─pidgin
|─pidgin-2.5.2
|─win32-dev
|–aspell-dev-0-50-3-3
|–Bonjour_SDK
|–cyrus-sasl-2.1.25
|–enchant_1.6.0_win32
|–gettext-0.17
|–gstreamer-0.10.13

   |–gtk+-bundle_2.14.7-20090119_win32
|–gtkspell-2.0.16
|–intltool_0.40.4-1_win32

   |–libxml2_2.9.0-1_win32
|–meanwhile-1.0.2_daa3
|–nss-3.15.4-nspr-4.10.2
|–perl-5.10.0
|–silc-toolkit-1.1.10
|–tcl-8.4.5

二、开始编译
进入DOS命令窗口,切换到目录:
F:/pidgin/pidgin-2.5.1

输入命令并按回车执行:
make -f Makefile.mingw

如果没有安装perl和tcl,不需要按网站上说的那样去下载安装,直接修改:
libpurple/plugins/Makefile.mingw
pidgin/plugins/Makefile.mingw
用 # 注释掉perl和tcl相关的行就可以继续编译了

如果安装了perl,参照说明,还有一个要注意的地方,就是Perl的安装目录,默认是安装在C:/Perl目录中,在cygwin环境中的目录是/cygwin/c/Perl,而MSYS中是没有映射/cygwin目录的,开始的时候使用ln将安装好的Perl连接到/cygwin/c中,发现由于WIN下没有文件LINK,MSYS是把文件直接考到自己的安装目录下,这个方法显然是不行的。后来注意到说明里面有一句“If you install Perl anywhere else, you will need to override the PERL and EXTUTILS variables in your pidgin/local.mak file.” 在pidgin目录中搜索一下PERL和EXTUTILS的写法,创建一个local.mak,内容如下:

        PERL := /c/Perl/bin/perl
EXTUTILS := c:/perl/lib/ExtUtils

编译中的一些问题和选项

1. windres的一个小问题
当编译到pidgin/win32/pidgin_dll_rc.rc和pidgin_exe_rc.rc时,编译器提示:
windress无法打开’pixmap/tray/16/’,访问权限错误。

检查pidgin_exe_rc.rc可以发现以下2条语句:
#define PIXMAPDIR “pixmaps/”
PIDGIN_ICON ICON PIXMAPDIR “pidgin.ico”

怀疑所用的windres版本不支持这种dir定义方式,改成:
PIDGIN_ICON ICON “pixmaps/pidgin.ico”

同理修改pidgin_dll_rc.rc,修改ICO路径修改为:

PIDGIN_TRAY_AVAILABLE_4BIT ICON  “pixmaps/tray/16/available_4bit.ico”

PIDGIN_TRAY_AWAY_4BIT         ICON  “pixmaps/tray/16/away_4bit.ico”

PIDGIN_TRAY_BUSY_4BIT          ICON  “pixmaps/tray/16/busy_4bit.ico”

PIDGIN_TRAY_XA_4BIT              ICON  “pixmaps/tray/16/extended-away_4bit.ico”

PIDGIN_TRAY_OFFLINE_4BIT     ICON  “pixmaps/tray/16/offline_4bit.ico”

PIDGIN_TRAY_CONNECTING_4BIT    ICON  “pixmaps/tray/16/connecting_4bit.ico”

PIDGIN_TRAY_PENDING_4BIT    ICON  “pixmaps/tray/16/message_4bit.ico”

PIDGIN_TRAY_INVISIBLE_4BIT  ICON  “pixmaps/tray/16/invisible_4bit.ico”

编译通过.

2. 编译debug版本
修改config.h,增加一行:
#define DEBUG

重新编译。

3. 安装文件
执行命令
make -f Makefile.mingw install
自动生成目录和安装文件
win32-install-dir

注意:编译过程中,有些地方会出错,暂时写在这里:

1) __stack_chk_fail

说是libssp.a(ssp.o):ssp.c 和 libpurple/libpurple.dll.a都定义了

解决方案:win-dev下面的版本不对,按推荐的包下载,并配置好

2)libpurple/plugin.c 出错,原因是没有写版本号,
解决方案:open the file “version.h”, change () to (1) or any integer

T4 Tutorial: Debugging Code Generation Files

src: http://www.olegsych.com/2008/09/t4-tutorial-debugging-code-generation-files/

Posted by Oleg SychSeptember 13, 2008

This post is a part of the series that introduces code generation with Text Templates (also known as T4Templates) in Visual Studio using C# and Visual Basic; explains how to create reusable templates and combine them in complex code generators. In order to follow examples in this article, you need to have Visual Studio 2008 Standard Edition or higher, SQL Server 2005 or later, T4 Toolbox and T4 Editorinstalled on your computer.

Overview

As you remember from the previous article in this series, Runtime Errors are caused by exceptions thrown by code in the GeneratedTextTransformation class, which is compiled and executed by the code generation Engine.

Compilation and Runtime Errors

Although the Engine reports detailed stack dump for every exception thrown, troubleshooting non-trivial runtime errors may require using a debugger to step through the template code as it executes. Because template code is running inside of Visual Studio process itself, a second instance of Visual Studio is required to serve as a debugger for the first instance, which is running the template code.

Current support for debugging of code generation templates in Visual Studio is somewhat limited. It requires you to either use a manual breakpoint in the template code to trigger the just-in-time debugger or starting a debugging instance of Visual Studio in advance and attaching it to the instance that’s running the template.

Setup

Use Visual Studio to open CrudStoredProcedures.tt created in the first article of this series (you can download the source code using links at the end of this article). As you remember, it’s a code generation file that produces a DELETE stored procedure using table schema information retrieved from SQL server using SMO.

  • Simulate a runtime error by assigning null or Nothing to the server variable. This should trigger a run-time exception in the call to Database constructor.
  • Save the template file or select Run Custom Tool item from context menu in Solution Explorer to trigger template transformation.

Troubleshooting Runtime Errors

C#

Introducing ArgumentNullException in C# code

Visual Basic

Introducing ArgumentNullException in Visual Basic code

Runtime Error, Error List

    Just-In-Time Debugging

The quickest way to start debugging is by placing a breakpoint in the code of the template and triggering the just-in-time debugger. Note, if you are using Windows Vista or 2008 Server, this technique can hang Visual Studio. Please read the Just In Time Debugging on Windows Vista and 2008 Server section below first.

  • Make sure that debug parameter of the template directive is set to True.
  • Modify the template to call Debugger.Break method in the beginning of the code block.
C#

Setting just-in-time breakpoint in C# code

Visual Basic

Setting just-in-time breakpoint in Visual Basic code

  • Save the template file or select Run Custom Tool item from context menu in Solution Explorer to trigger template transformation.

Just-in-time debugging prompt

Debugger.Break method attempts to launch the Just-In-Time Debugger configured on your system.You should see a Visual Studio Just-In-Time Debugger dialog (shown above).

  • In Visual Studio Just-In-Time Debugger dialog, select New instance of Visual Studio 2008 in the list and click Yes.
C#

Stepping from just-in-time breakpoint in C# code

Visual Basic

Stepping from just-in-time breakpoint in Visual Basic code

This will launch a new instance of Visual Studio and attach it as a debugger to the first instance which is running your template. You should see the source code of your template automatically loaded in debugger and a green line pointing where the execution point currently is.

While in debugger, you can use all standard features, like stepping through code, and windows, like Watch, Call Stack, Immediate, etc.

  • Select Exceptions item from Debug menu in Visual Studio; turn on the option to break when exception is thrown and click OK.

Turning on Break-On-Exception option

  • Select Continue item from Debug menu in Visual Studio.

Exception details dialog

The template will continue to run until it encounters the exception. At that point, the Visual Studio debugger will pause it and display the dialog shown above. You can inspect the exception object by clicking View Detail link.

  • Select Continue item from Debug menu.
  • Close the debugging instance of Visual Studio.
  • Back in the original instance of Visual Studio, remove the call to Debugger.Break method from the template code.

Just-In-Time Debugging on Windows Vista and 2008 Server

By default on Windows Vista, the just-in-time debugger is configured to display a user-friendly dialog shown below. Although you can click the Debug the program button and start the debugger successfully, your original Visual Studio instance will hang in the end of the debugging session.

User-defined breakpoint dialog on Windows Vista

In order to avoid having to constantly kill the Visual Studio process after debugging, you will want to change Just-In-Time debugger configuration to work the same way it does on Windows XP and Windows Server 2003. This configuration is stored in registry as DbgJITDebugLaunchSetting value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework key. It’s default value on Windows Vista is 0×10. Change it to 0×2, which is the default value on Windows XP. After making this change, you should no longer see the User-Defined Breakpoint dialog and will be able to continue using Visual Studio after debugging.

Attaching Debugger Manually

Just-in-time debugging, described above, is the fastest and most precise way to set a breakpoint in template code and hit it in the debugger. However, it may not be appropriate if the code generation file you want to debug is read-only (such as when it is stored in source control repository or received from a third-party). In this situation, you can attach the debugger manually, which takes longer but doesn’t require you to modify the template code.

  • Start a second instance of Visual Studio and open the code generation file you need to debug –CrudStoredProcedures.tt in this example.
  • Select Attach to Process from the Debug menu in Visual Studio.

Attach to Process dialog

  • In the list of Available Processes, select devenv.exe and click the Attach button. This will attach the current instance of Visual Studio as a debugger for the first instance of Visual Studio running the template. Let’s call the first instance as simply Visual Studio and the second instance as Debugger.
  • Back in text editor of the Debugger, where you have the CrudStoredProcedures.tt file open, click on the left side of line 8 to sent a breakpoint.
C#

Setting breakpoint in C# code using attached debugger

Visual Basic

Setting breakpoint in Visual Basic code using attached debugger

Normally, the red breakpoint icon would appear next to the line you clicked. However, due to limitations in the current support for template debugging, Visual Studio displays the breakpoint icon in line 2 instead.

  • In the original Visual Studio instance, trigger template transformation by either saving the template or selecting Run Custom Tool from the context menu in Solution Explorer. This will trigger the breakpoint and you will see something like this in the Debugger.
C#

Stepping through C# code in attached debugger

Visual Basic

Stepping through Visual Basic code in attached debugger

You can use all debugging features as you would expect in regular .NET code with the exception of breakpoints. I have not found a way to place breakpoints in the template code precisely using the debugger and have to resort to manual breakpoints using Debugger.Break as described above.

  • Select Continue item from Debug menu.
  • Close the debugging instance of Visual Studio.
  • Back in the original instance of Visual Studio, restore the original initialization code for server variable.

Conclusion

Debugging is the most powerful technique in troubleshooting runtime errors that occur during code generation. Although current support for debugging of template code in Visual Studio is somewhat limited, you can debug templates effectively by either triggering Just-In-Time debugger with Debugger.Break from template code or by attaching a separate instance of Visual Studio as a debugger in advance.

In the next article of this series, we will talk about creating reusable code generation templates.

T4 (Text Template Transformation Toolkit) Code Generation – Best Kept Visual Studio Secret

src:http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx

 

Rob beat me to it. Blogging about T4 (the Text Template Transformation Toolkit) had been on my list literally for a year. He and I were singing its praises last night. Hopefully I can add something small to the conversation.

What’s the story? Well, T4 is a code generator built right into Visual Studio. To be clear, you HAVE THIS NOW on your system…go play. Now’s the time to introduce code generation to your company. If you’re doing something twice or more, manually, in your company, generate it.

However, it’s not deep-deep built in, because there’s no item templates in File | New Item and there’s no intellisense or syntax highlighting.

You don’t need this, but if you want really get the most out of T4, first, head over to Clarius Consulting and get their “T4 Editor Community Edition.” That’ll get you some basic coloring. They have a pay version that gets you more if you want.

Now, go into Visual Studio and make a Console App (or any app) and add a Text File, but name it something with a .tt extension. You’ll get a warning since it’s a generator, that someone could generate evil. Click OK if you are cool with potential evil. ;)

Security Warning

imageNow, look in Solution Explorer at the .tt file. If you’re using C#, you’ll have a sub .cs file, or if you’re using VB, a sub .vb file. That’s the file that will hold the result of the generation. This is the same visual metaphor used to the express the template/generated file relationship with .designer files you’ve seen elsewhere in Visual Studio.

If you look in the Properties for the .tt file, you’ll see it’s using a CustomTool listed as the “TextTemplatingFileGenerator.” This custom tool extensibility point is how things like XSD and WSDL code generators hook in to generate their artifacts.

T4 can generate any kind of text file, not just code. Whatever you like. You can use it in your projects, as above, or you can call T4 from the command-line.

Aside from Kzu and the folks at ClariusRob notes that Oleg Sych has a great collection of T4 resources. He’s got some great Tutorials:

Here’s some of the links from Oleg’s blog.

Oleg also has a CodePlex project called T4 Toolbox that is a library of T4 templates that get added to File | New Item.

Also, check out Damien Guard’s T4 templates that are a wholesale replacement of code that LINQ to SQL generates. Here’s an example, where I use Damien’s T4 templates against the sample Chinook Database.

image

Notice that I’ve named the .tt file the same as the .dbml, so Damian’s code can find it. I also continue to let original LINQ to SQL generate it’s .designer.cs file, but make that file’s Build Action “None” so it’s not ever compiled. That effectively puts Damian’s code in charge.

Here’s a screenshot showing a bit of Damian’s T4 template using the syntax highlighting from the Clairus T4 Visual Studio free download. If I’d pay them, I’d get intellisense and syntax highlighting inside the code blocks also. It looks like a lot like ASP.NET Web Forms, or Velocity, or any templating language really. The code blocks are where your logic is and outside the codeblocks is the template for whatever you want to generate. Notice how Damien gets input and sets output. You have full control, you can read files off the file system, from with your project, etc. He sets the output extension also. I like to use .g.cs or .g.vb, myself. In this example his generated file is Chinook.generated.cs.

I particularly like Damien’s example because he’s swapping out parts of LINQ to SQL that he didn’t like (the generated code) while keeping the part he did (the general mode, the designer, the dbml file.) If you don’t like something, fix it.

Plus, it all works in Visual Studio without installing anything.

image

If you’re doing Code Gen, or thinking about it, check out T4 as it’s a great place to start. Also, search my blog for “Code Generation” as I was livign and breathing it with CodeSmith for the many years I worked atCorillian. Have fun!