Building Transmission Qt for Windows
The following procedure in not the only one possible, it was just the easiest for me.
If you have a MinGW http://mingw.org/ development environment (Qt SDK http://www.qtsoftware.com/downloads/downloads#lgpl installs the basic tools but with an old winapi that is not enough) then you can skip the first part, add as many ported packages as you can find http://sourceforge.net/project/showfiles.php?group_id=2435, port the rest, and try the 2nd part.
Cross build environment
Using the excellent tools from the Fedora project(*) http://fedoraproject.org/wiki/MinGW we can build Transmission for running on Windows (XP and above).
You don't need to install Fedora 11 (or 12, or 13), I run it under Windows on a virtual machine (VMWare Player http://www.vmware.com/download/player/download.html), the Fedora 11 image is from one of the available options http://www.vmware.com/appliances/directory/cat/9833.
Once you have it, log in, su to root, and install the cross-development tools:
- Create the file /etc/yum.repos.d/mingw.repo running:
echo "[mingw] name=Fedora Windows cross-compiler, libraries, and tools. baseurl=http://homes.merjis.com/~rich/mingw/fedora-rawhide/x86_64/ enabled=1 gpgcheck=0 " > /etc/yum.repos.d/mingw.repo
- yum install mingw32-gcc mingw32-gtk2 mingw32-crossreport mingw32-nsiswrapper wine
- yum install mingw32-curl
- yum install mingw32-qt
- yum install mingw32-gcc-c++
- yum install patch
Curl and its dependencies was already ported, so we got that for free. If you are working on MinGW, go to the Curl site, the downloads include libraries and everything ported to Windows. I'm not building a multi-language version, just English, so I'm skipping the step about installing intltool (which is not in the yum repository, you have to build it, and I did for the Gtk version which requires it; not difficult).
(*) Note: I've also used "Mingw Cross Compiling Environment" http://www.nongnu.org/mingw-cross-env/ which can be installed in any Linux (I used Gentoo) and build static linked versions very similar to what I describe here, Qt is part of that environment... but I had to change it to build dynamic apps for Transmission 2.00b1 since DBus is a new requirement and I couldn't make it link statically (a Qt problem really).
Building Transmission library
For native MinGW replace mingw32-configure with ./configure, qmake-qt4 with qmake, and i686-pc-mingw32-g++ with g++.
Start by downloading and installing the source in your workspace (change version number to latest you can find):
- curl http://download.transmissionbt.com/files/transmission-1.83.tar.bz2 -O
- tar xvf transmission-1.83.tar.bz2
We are using one patch BuildingTransmissionQtWindows/transmission-1.83-Qt-build.diff; the download is done in one of the steps below.
Newer versions require different patches (instead of the one shown above):
- For version 2.04 use the same patch as 2.03
- Version 2.10, no patch is necessary (but DBUS support is broken -- correction: no, it isn't, see note below).
- Version 2.11, no patch necessary.
- Version 2.12, libtransmission now uses strsep() which MingW doesn't have. Quick fix: change it to strtok(), better fix: get a real strsep(), like the one in upcoming version 2.13.
- Version 2.13, no patch necessary.
- Version 2.20b, first change libevent to version 2.0.10, then try to build (beta 1 needed a small patch to get rid of the fork(), this change is already included on betas 2 and 3; also need to undefine ERROR on qt/session.cc -- Windows defines it on wingdi.h which is included by windows.h).
- Version 2.20, skip this version unless you only use remote sessions, it has a nasty bug on encrypted connections.
- Version 2.21, remember to change libevent to 2.0.10, and undefine ERROR at the top of qt/session.cc .
- Version 2.22, same as 2.21 .
- Version 2.30 & Version 2.31, needs some patching and building with FD_SETSIZE=1024 (or it crashes). Curl also needs to be build with the changed FD_SETSIZE. I don't have a clean patch for the released code, my patch includes many changes for supporting foreign characters and can be found in https://trac.transmissionbt.com/ticket/4160 and for current releases at https://sourceforge.net/tracker/?func=browse&group_id=380410&atid=1582675.
- Version 2.32, same as 2.31.
- Version 2.33, ditto.
- Version 2.40, 2.42, same.
- Version 2.50 same as 2.31.
- Version 2.51, ditto.
Note: Large File Support (LFS) is not enabled on a default MinGW environment, MinGW does have LFS but it doesn't expose it in a way that the configure script can use to find it. What I did was to apply Gianluigi Tiesi's patch, I found it with the name file64_mingw.diff, and you have to apply it by hand since it is a very old patch (I also added an extra guard on the #if to avoid breaking other packages that depend on no LFS detected, for instance PostgreSQL which is used as dependency to build Qt).
Note: For Transmission version < 2.20 libevent http://www.monkey.org/~provos/libevent/ is no longer included with Transmission. You'll have to download it and build it in your development environment (its being statically linked, so you don't need it on your run environment); it builds out of the box. Only the 1.4.x versions are supported, don't use the 2.0.x versions. CHANGED: For version >= 2.20 libevent 2.0.10 or later is used.
Note for version > 2.00: This version uses DBUS and only the latest development version of DBUS works in Windows, I just build it (version 1.3.1) and added the library changing its name (because Qt looks for a fixed-number older version), so you build libdbus-1-3.dll and copy it or change its name to dbus-1.dll; since DBUS is not really used by anything else (except probably Gnome desktop) I didn't add the DBUS daemon or anything else, and you get to see some complaints by the qtr application if you run it in a console, but it doesn't need it unless you run the app more than once). CHANGED: I have been using DBUS 1.4.0 with little problem, but 1.4.1 and 1.4.3 (not released) introduce problems where the library doesn't communicate with the dbus-daemon if autolaunch is used. On the other hand, if you start the session daemon, and set the environment variable DBUS_SESSION_BUS_ADDRESS correctly, then the library has no problem communicating. CHANGED: I found the bug in DBUS later than 1.4.0, reported it and until it is fixed I use my own patch (which just like version 1.4.0 publishes the daemon address on its main() since the place this functionality was moved to is not being executed).
Note for version 2.1x : After changing from building dynamic linked versions to statically linked, DBUS support appeared to broke, it seems Qt 4.7 is doing a dynamic load of dbus-1.dll in a non standard way. The solution, if you are using DBUS support which is mostly used with file and magnet association, is to include the dynamic library alongside the application; of course if you build everything dynamic, it was already there. CHANGED: Building Qt with -dbus-linked fixes this, the library is really linked statically (and, if doing a dynamic build, the library started showing as dependency so the problem was in my development environment).
- cd transmission-1.83
- curl "http://trac.transmissionbt.com/wiki/BuildingTransmissionQtWindows/transmission-1.83-Qt-build.diff?format=txt" -O transmission-1.83-Qt-build.diff
- patch -p1 < transmission-1.83-Qt-build.diff
- mingw32-configure --disable-nls --disable-largefile --disable-cli --disable-gtk
- make CFLAGS="-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mms-bitfields -DSTATICLIB"
- make install
Build Transmission Qt
- cd qt
- Just once, either copy the Gtk icon (if you have it) or download it:
- cp ../gtk/transmission.ico qtr.ico
- curl http://trac.transmissionbt.com/export/8538/trunk/gtk/transmission.ico -o qtr.ico
- Just once, either copy the Gtk icon (if you have it) or download it:
- export QMAKESPEC=fedora-win32-cross
- export PKG_CONFIG_LIBDIR=/usr/i686-pc-mingw32/sys-root/mingw/lib/pkgconfig
- qmake-qt4 -win32 QT_LIBINFIX=4 qtr.pro
- perl -pi -e 's/-fno-rtti' Makefile.Debug Makefile.Release
- make clean && make release
- INSTALL_ROOT=/usr/i686-pc-mingw32/sys-root/mingw make release-install
Make the Windows installer
The following steps are to correct a deficiency of nsiswrapper :
- ln -s /usr/i686-pc-mingw32/sys-root/mingw/bin/QtCore4.dll /usr/i686-pc-mingw32/sys-root/mingw/bin/qtcore4.dll
- ln -s /usr/i686-pc-mingw32/sys-root/mingw/bin/QtGui4.dll /usr/i686-pc-mingw32/sys-root/mingw/bin/qtgui4.dll
- ln -s /usr/i686-pc-mingw32/sys-root/mingw/bin/QtNetwork4.dll /usr/i686-pc-mingw32/sys-root/mingw/bin/qtnetwork4.dll
You may also have to set the PATH to include /usr/i686-pc-mingw32/sys-root/mingw/bin (unless my latest patch is already included in the distributed nsiswrapper).
Finally create the installer:
- nsiswrapper --run --name "QtTransmission" --outfile QtTransmission-1.83_installer.exe --installdir 'C:\Program Files\Transmission' /usr/i686-pc-mingw32/sys-root/mingw/bin/qtr.exe
That's it, now just copy the installer to Windows, I use ftp but of course I have a ftp server... haven't tried other means but scp (putty or OpenSSH) should work, also using a flash drive, or a Windows/Samba share.
I've put more documentation at SourceForge, first describing other 2 procedures I've explored http://sourceforge.net/apps/wordpress/trqtw/, and the "unofficial Transmission-Qt build for Windows" http://sourceforge.net/projects/trqtw where you can find already made builds packaged in an installer.