Skip to content

Instantly share code, notes, and snippets.

@qwerty12
Last active February 11, 2019 21:56
Show Gist options
  • Save qwerty12/5f5efe165ddacbd6447826a5bb0c7d73 to your computer and use it in GitHub Desktop.
Save qwerty12/5f5efe165ddacbd6447826a5bb0c7d73 to your computer and use it in GitHub Desktop.
Building transmission-daemon on for Windows 64-bit

Building transmission-daemon on and for Windows 64-bit

This short guide is only possible because of the Transmission, OpenSSL, curl and CMake developers' work.
Thanks to https://github.com/transmission/transmission-release-scripts/blob/master/build-windows.ps1 and https://build.transmissionbt.com/job/trunk-win32/arch=x64,label=pepito-win10/lastSuccessfulBuild/consoleText for showing the way.

The Transmission Project itself already provides [https://transmissionbt.com/download/](official builds w/ installer) which I install myself to have, among other things, an entry in the Windows services database for transmission-daemon.

I build my own transmission-daemon for these excellent patches:

You need the following installed:

  • Visual Studio 2017 (the Community Edition is sufficient - just make sure its C[++] compiler, MSVC, is installed)
  • ActivePerl
  • CMake (choose to add CMake to your path)
  • Possibly Git for Windows to have tools like patch present
  • jom (very recommended, esp. for OpenSSL compilation which can take ages on a single core. If you want to use nmake, use "NMake Makefiles" as the CMake generator & don't add /FS to CFLAGS)

Set up the environment

Open a Command Prompt and run the following:

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
set "TPDIR=C:\3rd-party-msvc64"
set "PATH=%TPDIR%\bin;%PATH%"
set "TPCFLAGS=/nologo /MP /GS /GL /Gy /Oi /Oy /O2 /DWIN32 /D_WINDOWS"
set "TPLDFLAGS=/NOLOGO /DYNAMICBASE /NXCOMPAT /LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF /machine:x64"
set "CFLAGS=%TPCFLAGS%"
set "LDFLAGS=%TPLDFLAGS%"

mkdir "%TPDIR%" & cd "%TPDIR%"

Build zlib (tested with 1.2.11)

Download zlib, extract the contents of it into %TPDIR% and cd into the extracted zlib folder.

To build zlib with optimised ASM routines, apply CristiFati's patch:

"%ProgramFiles%\Git\mingw64\bin\curl.exe" -fsSL https://github.com/madler/zlib/pull/376.diff | "%ProgramFiles%\Git\usr\bin\patch.exe" -Np1

(else, set AMD64 below to OFF)

Run the following to build and install zlib into %TPDIR%:

mkdir build & cd build
cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%TPDIR%" -DCMAKE_SHARED_LINKER_FLAGS="%LDFLAGS%" -DCMAKE_C_FLAGS="%CFLAGS%" -DBUILD_SHARED_LIBS=ON -DSKIP_INSTALL_FILES=ON -DAMD64=ON
nmake
nmake install/fast

Build OpenSSL (tested with 1.1.1a)

Download OpenSSL, extract the contents of it into %TPDIR% and cd into the extracted OpenSSL folder.

Run the following to build and install OpenSSL into %TPDIR%:

set "CFLAGS=%TPCFLAGS% /I"%TPDIR%\include" /FS"
set "LDFLAGS=%TPLDFLAGS% /DEBUG:FASTLINK"
perl Configure --prefix="%TPDIR%" --openssldir="C:\Program Files\Transmission\ssl" VC-WIN64A-masm zlib-dynamic
REM possibly install dmake - I did
jom
nmake install_sw
set "CFLAGS=%TPCFLAGS%"
set "LDFLAGS=%TPLDFLAGS%"

Build curl (tested with 7.63.0)

Download curl, extract the contents of it into %TPDIR% and cd into the extracted curl folder.

Run the following to build and install curl into %TPDIR%:

mkdir build & cd build
cmake .. -G "NMake Makefiles JOM" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%TPDIR%" -DCMAKE_SHARED_LINKER_FLAGS="%LDFLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LDFLAGS%" -DCMAKE_C_FLAGS="%CFLAGS%" -DBUILD_CURL_EXE=OFF -DUSE_WIN32_LDAP=OFF -DBUILD_TESTING=OFF -DCMAKE_USE_OPENSSL=ON -DCURL_WINDOWS_SSPI=OFF -DBUILD_TESTING=OFF -DCURL_DISABLE_DICT=ON -DCURL_DISABLE_GOPHER=ON -DCURL_DISABLE_IMAP=ON -DCURL_DISABLE_SMTP=ON -DCURL_DISABLE_POP3=ON -DCURL_DISABLE_RTSP=ON -DCURL_DISABLE_TFTP=ON -DCURL_DISABLE_TELNET=ON -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_LDAPS=ON -DENABLE_MANUAL=OFF
jom
nmake install/fast

Build Transmission

Download Transmission, be this a tarball from the official website or Git master and cd into the extracted transmission folder.

Run the following to build and install Transmission into %TPDIR%

set "CXXFLAGS=%TPCFLAGS% /GR /EHsc"
mkdir build & cd build
cmake .. -G "NMake Makefiles JOM" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%TPDIR%" -DCMAKE_SHARED_LINKER_FLAGS="%LDFLAGS%" -DCMAKE_STATIC_LINKER_FLAGS="/NOLOGO /LTCG /machine:x64" -DCMAKE_EXE_LINKER_FLAGS="%LDFLAGS%" -DCMAKE_C_FLAGS="%CFLAGS%" -DCMAKE_CXX_FLAGS="%CXXFLAGS%" -DENABLE_CLI=ON -DENABLE_GTK=OFF -DENABLE_QT=OFF -DENABLE_MAC=OFF -DENABLE_TESTS=OFF -DINSTALL_DOC=OFF
jom
nmake install/fast

You should now have Transmission and the DLL files required to run it in %TPDIR%\bin. Optionally, you can save tr.manifest (itexplicitly marks transmission-daemon as W7+ compatible to avoid folder virtualisation etc.) from this gist to %TPDIR% and then run:

mt -manifest %TPDIR%\tr.manifest -inputresource:"%TPDIR%\bin\transmission-daemon.exe;#1" -outputresource:"%TPDIR%\bin\transmission-daemon.exe;#1"

You can replace the files in your installed version of Transmission with the ones from bin. Don't forget to do the same with %TPDIR%\share\transmission\web.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
type="win32"
name="Transmission.transmission-daemon"
version="1.0.0.0"
processorArchitecture="amd64"
/>
<description>Transmission</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment