qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
27.75k stars 3.92k forks source link

Compilation error for qbt 4.1.0 alpha with libtorrent 1.0.11 #8798

Closed airium closed 6 years ago

airium commented 6 years ago

qBittorrent version and Operating System

qBittorrent-nox 4.1.0 Alpha (using the latest master branch) on Ubuntu 16.04 LTS

If on linux, libtorrent and Qt version

libtorrent 1.0.11 (local compilation) + Qt 5.5.1 (PPA)

What is the problem

With a successful configuration, I encountered the compiling error:

......
compiling base/bittorrent/torrenthandle.cpp
base/bittorrent/torrentcreatorthread.cpp: In member function ‘virtual void BitTorrent::TorrentCreatorThread::run()’:
base/bittorrent/torrentcreatorthread.cpp:137:48: error: ‘optimize_alignment’ is not a member of ‘libtorrent::create_torrent’
             , (m_params.isAlignmentOptimized ? libt::create_torrent::optimize_alignment : 0));
                                                ^~~~
base/bittorrent/torrentcreatorthread.cpp: In static member function ‘static int BitTorrent::TorrentCreatorThread::calculateTotalPieces(const QString&, int, bool)’:
base/bittorrent/torrentcreatorthread.cpp:208:35: error: ‘optimize_alignment’ is not a member of ‘libtorrent::create_torrent’
         , (isAlignmentOptimized ? libt::create_torrent::optimize_alignment : 0)).num_pieces();
                                   ^~~~
Makefile:1646: recipe for target 'torrentcreatorthread.o' failed
make[1]: *** [torrentcreatorthread.o] Error 1
make[1]: *** Waiting for unfinished jobs....
......

It seems that the new code for creating torrent explicitly introduces libtorrent 1.1 flag optimize_alignment, which is optimize in libtorrent 1.0. Then I tried to replace all presence to the older one, and got new error:

base/bittorrent/torrentinfo.cpp: In static member function ‘static BitTorrent::TorrentInfo BitTorrent::TorrentInfo::loadFromFile(const QString&, QString*)’:
base/bittorrent/torrentinfo.cpp:109:5: error: ‘bdecode_node’ is not a member of ‘libt’
     libt::bdecode_node node;
     ^~~~
base/bittorrent/torrentinfo.cpp:111:65: error: ‘node’ was not declared in this scope
     bdecode(data.constData(), (data.constData() + data.size()), node, ec
                                                                 ^~~~
base/bittorrent/torrentinfo.cpp:112:42: error: ‘bdecode’ was not declared in this scope
         , nullptr, depthLimit, tokenLimit);
                                          ^
base/bittorrent/torrentinfo.cpp:119:66: error: no matching function for call to ‘BitTorrent::TorrentInfo::TorrentInfo(<brace-enclosed initializer list>)’
     TorrentInfo info {NativePtr(new libt::torrent_info(node, ec))};
                                                                  ^

This time it seems that libtorrent 1.0.11 totally has no such file bdecode.hpp and bdecode.cpp defining bdecode_node and I temporarily find no old API replacement for it.

Does it mean qbt 4.1.0 will possibly break any further dependency on libtorrent 1.0.11? or simply I just forget to do something? Personally, I am still a little bit sticking to libtorrent 1.0.11, which is more robust than current 1.1. I expect I could still use 1.0.11 for a while.

KozakaiAya commented 6 years ago

+1 for libtorrent 1.0.11 I have encountered several tracker announcement and disk IO issues with libtorrent 1.1.x branch, not a bug, but lt 1.0.11 performs more like what I expected.

sledgehammer999 commented 6 years ago

IIRC @Chocobo1 finalized the PR for the torrent creation.

As for bdecode_node, there's something equivalent in 1.0.x. I think it is lazy_entry and entry (from bdecode). I am away now, and can't confirm. Other places in our codebase must have an alternative implementation for 1.0.x. This should be an oversight. Online git blame shows that @Chocobo1 added those lines too.

sledgehammer999 commented 6 years ago

@airium check patch in #8811

amefs commented 6 years ago

Verfied this patch in Windows, successfully compiled. (libtorrent1.0.11 qt5.9.4)

airium commented 6 years ago

@sledgehammer999 Sorry for my delay to check the patch. I have just experimented it on both Windows 10 and Ubuntu 16 and now it passes all compilation and works well, even immediately better than 4.0.4.

Thank you for your timely hotfix. I will close this issue and please merge the patch.