How to build Transmission without QT for Windows

Ask for help and report issues with the Windows version of Transmission
Post Reply
Luna
Posts: 2
Joined: Mon Sep 28, 2009 10:18 pm

How to build Transmission without QT for Windows

Post by Luna »

Hello, I wish to know if there is a guide to do this like in mingw or cross-compiling for fedora(not cygwin). I seen a topic that builds Transmission with QT but not with gtk interface(though I seen a screen shot in the same post) though it never states how to build it for windows only using gtk interface(GTK++). I have search for a good bit-torrent client for windows and have not yet to find one. I am hoping that, Transmission can be build for windows.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How to build Transmission without QT for Windows

Post by rb07 »

Have you tried building it?

I made the GTK+ client for Windows the first time I built the Qt version, is about the same procedure just need to add an additional package to the mix (which I mentioned on the Wiki article).

Transmission 1.75 no longer builds clean with the procedure... up to 1.74 the procedure works even with the old patch, but now something was changed and linking fails with the latest version. Doesn't look like a big problem but is a strange one so I haven't wasted much time with it, I probably just need to see the changes to figure out what the real problem is.

Anyway back to your question, using the Fedora-mingw environment works fine for the GTK+ client for versions 1.74 and below. I didn't use that client much so I don't really know how well it works, I didn't see any problem, but with the Qt client it took me a while to become aware of all the little bugs and annoyances.

BTW use the Fedora 11 image from VMWare, I haven't changed the link in the article which is for the beta version, no need to use it and it became corrupted for me after upgrading many packages so I had to change images.

If you are interested in version 1.75 and can't figure out what the problem with linking is, let me know and I'll give it another try... I haven't since the Qt client hasn't changed anyway, at least I don't think it has changed, so I'm still using the 1.74 version.
Luna
Posts: 2
Joined: Mon Sep 28, 2009 10:18 pm

Re: How to build Transmission without QT for Windows

Post by Luna »

Thanks for telling me this, I tried 1.75 it came up with errors trying to make something with libevent or so. I'll try 1.74 tomorrow since my laptop is put away at the moment.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How to build Transmission without QT for Windows

Post by rb07 »

Strange, that's not where it fails for me, libevent builds fine, so on until libtransmission builds fine also, then linking some test programs (which are not even used) to libtransmission fails.

My current patch for 1.75, shorter than the one in the Wiki since libevent and the other 3rd party libraries don't have problems anymore :

Code: Select all

diff -NaurX diff-excludes.txt transmission-1.75-orig/libtransmission/JSON_parser.h transmission-1.75/libtransmission/JSON_parser.h
--- transmission-1.75-orig/libtransmission/JSON_parser.h	2009-09-13 22:50:55.000000000 -0500
+++ transmission-1.75/libtransmission/JSON_parser.h	2009-09-30 07:27:49.709386730 -0500
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 /* Windows DLL stuff */
-#ifdef _WIN32
+#if defined(WIN32) && !defined(STATICLIB)
 #	ifdef JSON_PARSER_DLL_EXPORTS
 #		define JSON_PARSER_DLL_API __declspec(dllexport)
 #	else
diff -NaurX diff-excludes.txt transmission-1.75-orig/libtransmission/net.c transmission-1.75/libtransmission/net.c
--- transmission-1.75-orig/libtransmission/net.c	2009-09-13 22:50:55.000000000 -0500
+++ transmission-1.75/libtransmission/net.c	2009-09-30 08:18:15.247415379 -0500
@@ -31,8 +31,8 @@
 #include <sys/types.h>
 
 #ifdef WIN32
- #include <winsock2.h> /* inet_addr */
- #include <WS2tcpip.h>
+ #define _WIN32_WINNT	0x0501
+ #include <ws2tcpip.h>
 #else
  #include <arpa/inet.h> /* inet_addr */
  #include <netdb.h>
diff -NaurX diff-excludes.txt transmission-1.75-orig/libtransmission/net.h transmission-1.75/libtransmission/net.h
--- transmission-1.75-orig/libtransmission/net.h	2009-09-13 22:50:55.000000000 -0500
+++ transmission-1.75/libtransmission/net.h	2009-09-17 08:53:20.681334572 -0500
@@ -32,7 +32,7 @@
 #ifdef WIN32
  #include <inttypes.h>
  #include <winsock2.h>
- #include <WS2tcpip.h>
+ #include <ws2tcpip.h>
  typedef int socklen_t;
 #else
  #include <sys/types.h>
diff -NaurX diff-excludes.txt transmission-1.75-orig/libtransmission/tr-dht.c transmission-1.75/libtransmission/tr-dht.c
--- transmission-1.75-orig/libtransmission/tr-dht.c	2009-09-13 22:50:55.000000000 -0500
+++ transmission-1.75/libtransmission/tr-dht.c	2009-09-30 08:10:18.233433037 -0500
@@ -25,12 +25,19 @@
 #include <stdio.h>
 
 /* posix */
-#include <netinet/in.h> /* sockaddr_in */
 #include <signal.h> /* sig_atomic_t */
 #include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h> /* socket(), bind() */
 #include <unistd.h> /* close() */
+#ifdef WIN32
+ #include <inttypes.h>
+ #include <winsock2.h>
+ #define WINVER		WindowsXP
+ #include <ws2tcpip.h>
+#else
+ #include <sys/types.h>
+ #include <sys/socket.h> /* socket(), bind() */
+ #include <netinet/in.h> /* sockaddr_in */
+#endif
 
 /* third party */
 #include <event.h>
diff -NaurX diff-excludes.txt transmission-1.75-orig/libtransmission/trevent.c transmission-1.75/libtransmission/trevent.c
--- transmission-1.75-orig/libtransmission/trevent.c	2009-09-13 22:50:55.000000000 -0500
+++ transmission-1.75/libtransmission/trevent.c	2009-09-17 09:07:12.150251914 -0500
@@ -23,7 +23,7 @@
 
 #ifdef WIN32
 
-#include <WinSock2.h>
+#include <winsock2.h>
 
 static int
 pgpipe( int handles[2] )
diff -NaurX diff-excludes.txt transmission-1.75-orig/libtransmission/utils.c transmission-1.75/libtransmission/utils.c
--- transmission-1.75-orig/libtransmission/utils.c	2009-09-13 22:50:55.000000000 -0500
+++ transmission-1.75/libtransmission/utils.c	2009-09-17 09:09:27.796265108 -0500
@@ -1392,7 +1392,11 @@
     in = tr_open_file_for_scanning( oldpath );
     tr_preallocate_file( newpath, bytesLeft );
     out = tr_open_file_for_writing( newpath );
+#ifdef WIN32
+    buflen = 4096;
+#else
     buflen = stat( newpath, &st ) ? 4096 : st.st_blksize;
+#endif
     buf = tr_new( char, buflen );
     while( bytesLeft > 0 )
     {
diff -NaurX diff-excludes.txt transmission-1.75-orig/qt/qtr.pro transmission-1.75/qt/qtr.pro
--- transmission-1.75-orig/qt/qtr.pro	2009-09-13 22:50:57.000000000 -0500
+++ transmission-1.75/qt/qtr.pro	2009-09-17 09:30:38.787294687 -0500
@@ -1,7 +1,7 @@
 TARGET = qtr
 NAME = "Transmission"
 DESCRIPTION = "Transmission: a fast, easy, and free BitTorrent client"
-VERSION = 1.60
+VERSION = 1.75
 LICENSE = "GPL"
 
 target.path = /bin
@@ -18,6 +18,7 @@
 LIBS += $${TRANSMISSION_TOP}/third-party/miniupnp/libminiupnp.a
 LIBS += $${TRANSMISSION_TOP}/third-party/libnatpmp/libnatpmp.a
 LIBS += $${TRANSMISSION_TOP}/third-party/libevent/.libs/libevent.a
+win32:LIBS += -lws2_32 -lintl
 
 TRANSLATIONS += transmission_en.ts transmission_ru.ts
 
@@ -32,3 +33,4 @@
 HEADERS += $$replace(SOURCES, .cc, .h)
 HEADERS += speed.h types.h
 
+win32:RC_FILE = qtr.rc
diff -NaurX diff-excludes.txt transmission-1.75-orig/qt/qtr.rc transmission-1.75/qt/qtr.rc
--- transmission-1.75-orig/qt/qtr.rc	1969-12-31 18:00:00.000000000 -0600
+++ transmission-1.75/qt/qtr.rc	2009-09-17 09:32:49.633252289 -0500
@@ -0,0 +1 @@
+IDI_ICON1	ICON	DISCARDABLE "qtr.ico"
diff -NaurX diff-excludes.txt transmission-1.75-orig/third-party/dht/dht.c transmission-1.75/third-party/dht/dht.c
--- transmission-1.75-orig/third-party/dht/dht.c	2009-09-13 22:52:23.000000000 -0500
+++ transmission-1.75/third-party/dht/dht.c	2009-09-30 08:08:04.848659589 -0500
@@ -39,10 +39,18 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/time.h>
+#ifndef WIN32
 #include <arpa/inet.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#else
+#include <winsock2.h>
+#define WINVER  WindowsXP       /* freeaddrinfo(),getaddrinfo(),getnameinfo() */
+#include <ws2tcpip.h>
+#define random	rand		/* int rand() since no long random() */
+static const char *inet_ntop(int, const void *, char *, socklen_t);
+#endif
 
 #include "dht.h"
 
@@ -1295,6 +1303,9 @@
 dht_init(int s, const unsigned char *id, const unsigned char *v)
 {
     int rc;
+#ifdef WIN32
+    unsigned long flags = 1;
+#endif
 
     if(buckets) {
         errno = EBUSY;
@@ -1309,11 +1320,15 @@
 
     storage = NULL;
 
+#ifndef WIN32
     rc = fcntl(s, F_GETFL, 0);
     if(rc < 0)
         goto fail;
 
     rc = fcntl(s, F_SETFL, (rc | O_NONBLOCK));
+#else
+    rc = ioctlsocket(s, FIONBIO, &flags);
+#endif
     if(rc < 0)
         goto fail;
 
@@ -2306,3 +2321,29 @@
     debugf("Truncated message.\n");
     return -1;
 }
+
+#ifdef WIN32
+static const char *
+inet_ntop (int af, const void *src, char *dst, socklen_t cnt)
+{
+    if (af == AF_INET)
+    {
+        struct sockaddr_in in;
+        memset(&in, 0, sizeof(in));
+        in.sin_family = AF_INET;
+        memcpy(&in.sin_addr, src, sizeof(struct in_addr));
+        getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST);
+        return dst;
+    }
+    else if (af == AF_INET6)
+    {
+        struct sockaddr_in6 in;
+        memset(&in, 0, sizeof(in));
+        in.sin6_family = AF_INET6;
+        memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
+        getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST);
+        return dst;
+    }
+    return NULL;
+}
+#endif
diff -NaurX diff-excludes.txt transmission-1.75-orig/third-party/miniupnp/miniupnpcstrings.h transmission-1.75/third-party/miniupnp/miniupnpcstrings.h
--- transmission-1.75-orig/third-party/miniupnp/miniupnpcstrings.h	1969-12-31 18:00:00.000000000 -0600
+++ transmission-1.75/third-party/miniupnp/miniupnpcstrings.h	2009-09-18 07:33:12.344489616 -0500
@@ -0,0 +1,15 @@
+/* $Id: miniupnpcstrings.h.in,v 1.1 2009/07/09 16:13:31 nanard Exp $ */
+/* Project: miniupnp
+ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
+ * Author: Thomas Bernard
+ * Copyright (c) 2005-2009 Thomas Bernard
+ * This software is subjects to the conditions detailed
+ * in the LICENCE file provided within this distribution */
+#ifndef __MINIUPNPCSTRINGS_H__
+#define __MINIUPNPCSTRINGS_H__
+
+#define OS_STRING "Linux/2.6.29.6-217.2.16.fc11.i586"
+#define MINIUPNPC_VERSION_STRING "1.3"
+
+#endif
+
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How to build Transmission without QT for Windows

Post by rb07 »

I corrected the patch above, version 1.75 compiles now (it was my own mistake while trying to clean up the patch). I'll update the Wiki article later.

I'll try also to build the GTK+ Windows client and report back...
  • yum install intltool
  • tar xf transmission-1.75.tar.bz2
  • cd transmission-1.75
  • patch -p1 < ../transmission-1.75-Qt-build.diff
  • cp -rp ../transmission-1.74/qt/qtr.ico qt/
  • mingw32-configure --disable-largefile --disable-cli --enable-daemon
So far, so good. Of course you may skip the copy of the icon since that was for the Qt application, but, bad news the GTK+ application also needs it and doesn't have it, and more pieces are missing and some quick hacks are needed, not a big problem I just know somebody is going to criticize what comes next:

The icon you can get from the same link I show in the Wiki (the subversion repository), just store it as gtk/transmission.ico

The resource file (only needed in Windows so nobody has complained) is also missing... you can copy the one I left (with the patch above) in qt/qtr.rc, this one goes into gtk/transmission.rc, edit the content to change the icon file name to the correct one.

The gtk/Makefile makes reference to setransmission.res, I don't know where that came from, either edit the generated Makefile and delete that line (and the backslash in the previous line) or change it to plain transmission.res (I did the later).

Continue...
  • make CFLAGS="-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mms-bitfields -DSTATICLIB"
  • make install
  • nsiswrapper --run --name Transmission --outfile TransmissionGTK-1.75_installer.exe --installdir 'C:\Program Files\Transmission' /usr/i686-pc-mingw32/sys-root/mingw/bin/transmission.exe
The result is a 14M Windows installer. It installs the application and all the libraries needed (if you already had GTK+, for instance with Gimp, the application will use its own libraries... but there might be conflicts one way or another if 2 different version libraries are loaded in memory... the wonders of Windows ;-)

Perhaps nsiswrapper won't work, I may have a changed version (like I describe in the Wiki, the patch I show there for it probably is still good).
Post Reply