# X-Chat 2 for Windows

## Hackers Guide

This page describes X-Chat compiling/building process on Windows using Microsoft's Visual C++ compiler. Thanks to zed for making X-Chat and porting it to Windows, thus making this all possible.

Read EVERYTHING carefully. Other stuff is here.

1. Firstly, `INSTALL.w32` file in X-Chat's tarball (e. g. `xchat-2.8.4.tar.bz2`) is your (short) guide on compiling X-Chat for Windows.
2. Get yourself a C compiler. X-Chat may be build with several compilers, including GCC from MinGW project, but that one lacks IPv6 headers, so we'll stick to Microsoft ones. There is a Microsoft Visual C++ Toolkit 2003 which one can download freely, or you can use Visual Studio .NET one. Since I already use Visual Studio .NET for other purposes, I'll desribe the process with the latter one. Example installation options (possibly not minimal) are here.
3. Copy `C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\io.h` to `unistd.h` in the same directory.
4. GTK+ is compiled with earlier version of Visual C++ compiler, thus linked to `msvcrt.dll`. Visual Studio .NET compiler by default links to `msvcrt71.dll`, which results in incompatible file handles and X-Chat crashing on connect. Backup `C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\msvcrt.lib` and replace it with one, which forces programs to be linked to `msvcrt.dll`.
5. If you want MMX-optimized background tinting, and since MMX tinting code in X-Chat (`src/fe-gtk/mmx_cmod.S`) is gasm code, you'll need GCC to compile it. I haven't tried this, but always used `mmx_cmod.o` compiled by zed.
1. `atk-1.12.3.zip`, `atk-dev-1.12.3.zip`
2. `cairo-1.4.8.zip`, `cairo-dev-1.4.8.zip`
3. `dirent.zip`
4. `expat-2.0.0.zip`
5. `fontconfig-2.4.2-tml-20070301.zip`, `fontconfig-dev-2.4.2-tml-20070301.zip`
6. `freetype-2.3.4.zip`, `freetype-dev-2.3.4.zip`
7. `gettext-0.14.5.zip`, `gettext-dev-0.14.5.zip`
8. `glib-2.12.13.zip`, `glib-dev-2.12.13.zip`
9. `gtk+-2.10.14.zip`, `gtk+-dev-2.10.14.zip`
10. `jpeg-6b-4-bin.zip`, `jpeg-6b-4-dep.zip`, `jpeg-6b-4-lib.zip`
11. `libiconv-1.9.1.bin.woe32.zip`
12. `libpng-1.2.8-bin.zip`, `libpng-1.2.8-dep.zip`, `libpng-1.2.8-lib.zip`
13. `pango-1.16.4.zip`, `pango-dev-1.16.4.zip`
14. `pkg-config-0.20.zip`
15. `tiff-3.8.2-1-bin.zip`, `tiff-3.8.2-1-dep.zip`, `tiff-3.8.2-1-lib.zip`
16. `zlib123-dll.zip`
7. Extract all archives to one directory (I use `D:\dev\root`, and call it `%ROOT%`), overwriting duplicated files. Move `zlib1.dll` to `bin` directory.
8. Get latest NASM (Win32 binary). It's needed to compile OpenSSL. Extract nasmw.exe to `%ROOT%\bin` directory.
9. Get ActiveState ActivePerl, ActiveState ActivePython and/or ActiveState ActiveTcl if you plan to compile respective plugins for X-Chat, and install them (I install them to `C:\Active\Perl`, `Python23` and `Tcl` directories). Perl is required to compile OpenSSL. Don't forget to check options to add directories to environment `PATH` variable, if available in installers. Extract `dirent.lib` from `dirent.zip` (above) to Tcl's `lib` directory; building Tcl plugin for X-Chat will require it.
10. Download latest OpenSSL release, and make sure you have NASM and Perl installed. Extract, open Visual Studio .NET 2003 Command Prompt from Start menu and navigate to directory you extracted it. Run `perl Configure VC-WIN32`, `ms\do_nasm` and `nmake -f ms\ntdll.mak`. Copy `inc32\openssl` directory to `%ROOT%\include directory`, `out32dll\*.dll` to `%ROOT%\bin`, `out32dll\*.lib` and `*.exp` to `%ROOT%\lib` directory. `INSTALL.W32` in tarball is your friend.
11. Edit Visual Studio .NET 2003 Command Prompt `.bat` file (`C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat`): add `@set PATH=C:\Program Files\Common Files\GTK\2.0\bin;C:\Program Files\Common Files\GTK\2.0\lib;D:\dev\root\bin;D:\dev\root\lib;%PATH%` to the end. It'll save you some headache later. Be sure to replace `D:\dev\root` with your `%ROOT%`.
12. If you want IPv6 support, download `tpipv6-001205.exe` from Microsoft IPv6. Extract `*.h` files to `C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include` directory. These headers are for Visual C++ compiler only, so GCC is not suitable if you want IPv6 support.
13. Get `cvs.exe` from https://www.cvshome.org/ and run `cvs -z3 -d:pserver:anonymous@xchat.cvs.sourceforge.net:/cvsroot/xchat co -kb -P xchat2`. This way you will get X-Chat CVS sources. Don't forget to add `-kb` option, this way CVS won't distort line endings. Alternatively, grab latest release sources tarball and extract it.
14. Edit `config.h.win32` file to reflect current version number. Add two lines at the end of file: `#define GETTEXT_PACKAGE "xchat"`, and `#define PACKAGE_TARNAME "xchat-2.8.4"`.
15. Place you GCC-compiled `mmx_cmod.o` (or zed's `mmx_cmod.o`) to `src\fe-gtk` directory).
16. Edit X-Chat's `src\makeinc.msc` file. Uncomment `OPENSSL`, `IPV6` and `MMX` defines. Add `pkg-config glib-2.0 --msvc-syntax --cflags` output to `GLIB` line, and add `-ID:/dev/root/include` (replace with your `%ROOT%/include`). Add `pkg-config gtk+-2.0 --msvc-syntax --cflags` output to `GTK` line, and `pkg-config gtk+-2.0 --msvc-syntax --libs` to `LIBS` line. Modify `PERLPATH`, `PYTHONPATH` and `TCLPATH` to real ones. Change `libssl32.lib` occurrence to `ssleay32.lib`.
17. In `plugins\perl\makefile.msc`, `link ...` line, add `\$(LIBS)` before, between or after specified `.lib` files.
18. Grab my `po.bat`, place it in `src\` and run it. It will generate `.mo` files (translations) with appropriate directory structure for using with gettext.
19. Run `nmake -f makefile.msc` within `src\`, and the same in `plugins\perl`, `python` and `tcl`. Use your hacking skills to fix errors.
20. Put resulting `src\fe-gtk\xchat.exe` to some dir, and `plugins\*\*.dll`'s to `plugins\`, `po\locale` to `locale\` dirs.
21. Run `xchat.exe` and enjoy plugins and translations, and tell all your friends what have you just done.

Easy!

Atom feed; Hosting Services & silverex.org: All My Data Email here