Windows compilation self-notes (MSVC)

For the generic offtopic chit-chat
Post Reply
User avatar
Peter
Administrator
Administrator
Posts: 2702
Joined: Wed Jul 07, 2010 6:14 pm

Windows compilation self-notes (MSVC)

Post by Peter »

Yes, I am using the forums as a personal notepad. Sorry.

This is the guide you should follow: https://github.com/qbittorrent/qBittorr ... c-linkage)

But...

- I did not use the Microsoft VM because it is SUCH A HASSLE to import it. Oh my god. Hours of waiting in Virtualbox. Nah. And it can't even run in qemu unless you export it, import it.. no. No way.
- I put vcpkg into C:\vcpkg\
- I put my source stuff into C:\build\
- Even though libtorrent is now 2.0.9 in vcpkg, it would not work for me, so I had to compile it too. It's ok, not much extra work.
- This guide installs Qt5 and the build also defaults to Qt5. If you want Qt6, you will have to grab Qt6 stuff via vcpkg and also call the qbittorrent configure step to build it Qt6. Qt6 instructions, see bottom of this post (WIP).

= VM PART =
- I had greater success with Virtualbox + a blank Windows 11 machine
- This whole setup will require about 100GB-150GB of space. An SSD is highly recommended. You don't need a lot of RAM, 16GB was enough.
- If you use QEMU, make sure to change CPU topology. By default, even though it detects Windows 11, it will put CPUs as sockets. This won't work on Windows, so change it to 10 cores instead.

= FIRST PART =
- Just rely on the linked guide on top mainly for dependencies
- Grab "ninja" and "cmake" put them into a folder, put the folders into PATH
- Install Visual Studio community, make sure to install the listed stuff. I just looked for "latest" and that made it easier.
- Install git for windows

= VCPKG =
- Just go to C:\ in cmd
- And git checkout "vcpkg" into C:\vcpkg\ to shorten path; it works and in other places it'll complain about path length.

= SECOND PART =
- Install the requirements via vcpkg as listed in Wiki
- Install libtorrent too but we will also compile it real fast!
- Grab libtorrent from the project site. You will also have to grab the deps folders!
As of writing this:
> https://github.com/arvidn/libtorrent/re ... 0.9.tar.gz
> https://github.com/paullouisageneau/boo ... bc2913700a
> https://github.com/arvidn/try_signal/tr ... cd3caf583d

You can use this tool to grab folders (the deps trees): https://minhaskamal.github.io/DownGit/#/home

- So, extract the libtorrent release.
- Drop the "deps" into the \deps\ folder, so it will look like this:
> \libtorrent-2.0.9\deps\boost-asio-gnutls
> \libtorrent-2.0.9\deps\try_signal

= COMPILATION BEGINS: dev tools & libtorrent =

- At this point, close the previous cmd, and open "Visual Studio developer command line". It's in Start.
- Run this command: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
Every time you want to compile, mess around, you will have to open the dev console and run the command above! So if you reboot your PC, do it again.

- If you find this post like years later, just look for "vcvarsall.bat" inside your Visual Studio folder. It's what you need.
- Now compile libtorrent per instructions from Wiki. Make sure to pick a simple folder.

Great, now you have libtorrent compiled.

= COMPILATION CONTINUES: qBittorrent =

- Extract the qBittorrent release you want. Stable, old version, RC version, or even git. Up to you.
- Make your changes to the source.
- Run the build command (make sure you replace the vcpkg and Libtorrent path with yours!)
> $ cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows-static" -DMSVC_RUNTIME_DYNAMIC=OFF -DLibtorrentRasterbar_DIR=C:\Users\x\libtorrent_209\lib\cmake\LibtorrentRasterbar

As you can see, at the last part I specified my libtorrent folder where I did the compilation.

- Do the build (per wiki): cmake --build build

The EXE will be in ".\build" of your qb source folder, just run it.
Any changes you make, you can just rebuild with "cmake --build build".

= Qt6 section =
(WIP)

[Step 1] Install the Qt6 deps from vcpkg: vcpkg install qt qtbase qtconnectivity

I'll keep updating this guide.

Changelist:
v2: replaced the dep downloader link
Post Reply