qbittorrent / qBittorrent

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

Compiler breaks base/bittorrent/infohash.cpp: In constructor ‘BitTorrent::InfoHash::InfoHash(const sha1_hash&)’: #8751

Closed shinenelson closed 6 years ago

shinenelson commented 6 years ago

I don't know whether this is something that I'm doing wrong or something with the configurations that I've done. I had compiled a working build off of ff80208 until today when I thought of updating to the latest version. I tried this on both master as well as v4_0_x and hit the same block.

qBittorrent version and Operating System

I'm attempting to compile qBittorrent from source

If on linux, libtorrent and Qt version

libtorrent : 1.2 (compiled off of latest master) Qt : 5.5.1

What is the problem

Compiler breaks complaining about libtorrent

compiling base/bittorrent/infohash.cpp
base/bittorrent/infohash.cpp: In constructor ‘BitTorrent::InfoHash::InfoHash(const sha1_hash&)’:
base/bittorrent/infohash.cpp:43:45: error: invalid operands of types ‘std::size_t() noexcept {aka long unsigned int() noexcept}’ and ‘int’ to binary ‘operator*’
     char out[(libtorrent::sha1_hash::size * 2) + 1];
                                             ^
base/bittorrent/infohash.cpp:44:5: error: ‘to_hex’ is not a member of ‘libtorrent’
     libtorrent::to_hex(reinterpret_cast<const char*>(&m_nativeHash[0]), li
     ^
base/bittorrent/infohash.cpp:44:102: error: ‘out’ was not declared in this scope
 et_cast<const char*>(&m_nativeHash[0]), libtorrent::sha1_hash::size, out);
                                                                      ^
base/bittorrent/infohash.cpp: In constructor ‘BitTorrent::InfoHash::InfoHash(const QString&)’:
base/bittorrent/infohash.cpp:54:19: error: ‘from_hex’ is not a member of ‘libtorrent’
         m_valid = libtorrent::from_hex(raw.constData(), 40, reinterpret_ca
                   ^compiling base/bittorrent/infohash.cpp
base/bittorrent/infohash.cpp: In constructor ‘BitTorrent::InfoHash::InfoHash(const sha1_hash&)’:
base/bittorrent/infohash.cpp:43:45: error: invalid operands of types ‘std::size_t() noexcept {aka long unsigned int() noexcept}’ and ‘int’ to binary ‘operator*’
     char out[(libtorrent::sha1_hash::size * 2) + 1];
                                             ^
base/bittorrent/infohash.cpp:44:5: error: ‘to_hex’ is not a member of ‘libtorrent’
     libtorrent::to_hex(reinterpret_cast<const char*>(&m_nativeHash[0]), li
     ^
base/bittorrent/infohash.cpp:44:102: error: ‘out’ was not declared in this scope
 et_cast<const char*>(&m_nativeHash[0]), libtorrent::sha1_hash::size, out);
                                                                      ^
base/bittorrent/infohash.cpp: In constructor ‘BitTorrent::InfoHash::InfoHash(const QString&)’:
base/bittorrent/infohash.cpp:54:19: error: ‘from_hex’ is not a member of ‘libtorrent’
         m_valid = libtorrent::from_hex(raw.constData(), 40, reinterpret_ca
                   ^
Makefile:2811: recipe for target 'infohash.o' failed

What is the expected behavior

Compilation continues successfully

Steps to reproduce

git pull origin master make clean make

glassez commented 6 years ago

libtorrent 1.2 is unsupported.

shinenelson commented 6 years ago

My bad. I should've looked properly in the wiki for instructions on Compiling qBittorrent on Debian and Ubuntu before opening the issue.

However, tags libtorrent-1_1_{7-1} failed on me complaining : make[1]: *** No rule to make target 'mpi.c', needed by 'mpi.lo'. Stop.

When I tried with libtorrent-1_1, libtorrent-rasterbar compiled successfully. However, the qbittorrent compilation failed with a different complaint with libtorrent :

compiling base/bittorrent/session.cpp
base/bittorrent/session.cpp: In constructor ‘BitTorrent::Session::Session(QObject*)’:
base/bittorrent/session.cpp:428:32: error: ‘generate_fingerprint’ is not a member of ‘libt’
     const std::string peerId = libt::generate_fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
                                ^~~~
base/bittorrent/session.cpp: In member function ‘void BitTorrent::Session::configure(libtorrent::settings_pack&)’:
base/bittorrent/session.cpp:1408:30: error: ‘dht_bootstrap_nodes’ is not a member of ‘libtorrent::settings_pack’
         settingsPack.set_str(libt::settings_pack::dht_bootstrap_nodes, "dht.libtorrent.org:25401,router.bittorrent.com:6881,router.utorrent.com:6881,dht.transmissionbt.com:6881,dht.aelitis.com:6881");
                              ^~~~
base/bittorrent/session.cpp: In instantiation of ‘QSet<QString> {anonymous}::entryListToSetImpl(const Entry&) [with Entry = libtorrent::bdecode_node]’:
base/bittorrent/session.cpp:176:40:   required from here
base/bittorrent/session.cpp:149:55: error: passing ‘const libtorrent::bdecode_node’ as ‘this’ argument discards qualifiers [-fpermissive]
             const QString tag = QString::fromStdString(entry.list_string_value_at(i));
                                 ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../../../.local/include/libtorrent/torrent_info.hpp:47:0,
                 from base/bittorrent/torrentinfo.h:35,
                 from base/bittorrent/session.h:58,
                 from base/bittorrent/session.cpp:30:
../../../../.local/include/libtorrent/bdecode.hpp:291:14: note:   in call to ‘std::__cxx11::string libtorrent::bdecode_node::list_string_value_at(int, const char*)’
  std::string list_string_value_at(int i
              ^~~~~~~~~~~~~~~~~~~~
Makefile:3111: recipe for target 'session.o' failed

What am I missing here this time?

sledgehammer999 commented 6 years ago

However, tags libtorrent-11{7-1} failed on me complaining :

You should use the tarball specifically named "libtorrent something" eg libtorrent-rasterbar-1.1.7.tar.gz The tarball/zipfiles named "Source code" are autocreated by github as a snapshot of the branch at the point of the tag. They aren't a correct release. A release tarball has some extra files created so the source can be build.

When I tried with libtorrent-1_1, libtorrent-rasterbar compiled successfully. However, the qbittorrent compilation failed with a different complaint with libtorrent :

If you re-run qbittorrent's configure it would complain that it didn't find a libtorrrent version >= 1.1.2. You're probably using libtorrent 1.1.1 on your system, which isn't supported by qbittorrent.

You could grab the source deb package of libtorrent from our PPA and build it yourself. (google on how to build from source deb packages). PS: Our wiki instructions might be out of date.

shinenelson commented 6 years ago

You should use the tarball specifically named "libtorrent something" eg libtorrent-rasterbar-1.1.7.tar.gz The tarball/zipfiles named "Source code" are autocreated by github as a snapshot of the branch at the point of the tag. They aren't a correct release. A release tarball has some extra files created so the source can be build.

You could grab the source deb package of libtorrent from our PPA and build it yourself.

Actually, I didn't download the release tarballs at all. I cloned the git repository, checked out to the release tag (which is what I mentioned in the previous comment) and ran the following the commands each time :

make clean
./autotool.sh
./configure --prefix $HOME/.local
make

I did the same steps for each tag from libtorrent-1_1_7, all the way down to libtorrent-1_1_1. and all of them failed at the same point with the same error. libtorrent-1_1 was only the tag that compiled successfully. (I'm guessing that is v1.1.0)

You're probably using libtorrent 1.1.1 on your system, which isn't supported by qbittorrent.

I'm not sure how to check the version of the library as such, but every time I ran configure, I got a different version number listing at the end of the configuration (corresponding to the tag I was on) : Type 'make' to compile libtorrent-rasterbar 1.1.0 (that's from the libtorrent-1_1 tag).

Now, the thing that I missed to mention previously was that I noticed that the file that was complaining and failing to build (src/mpi.c) became a C++ file in commit 2a36f9015. That happened somewhere in between of tags libtorrent-1_1..libtorrent-1_1_1 I'm guessing it was missed to be tagged as a C++ file in the configure script or somewhere else where it should've been changed :thinking: ? (I'm sorry, I'm not well-versed with how make works other than using it to compile source code I pull off of the internet (github, mostly)) This could be why make was complaining that it didn't have a rule to make target mpi.c.

This is sounding more to be an issue with upstream @arvidn/libtorrent than with qbittorrent itself. If someone can confirm that this is indeed the issue, I could file this issue upstream and get it fixed there.

sledgehammer999 commented 6 years ago

It should be

./bootstap.sh
./configure --prefix $HOME/.local
(observe if they finish without error)
make

Or you should look into build_dist.sh too.

As I said you need to use the release tarball of libtorrent. Otherwise, you should seek help on their tracker/mailing list.

Your other problems are directly linked to the libtorrent version used. So I am going to close this.

sledgehammer999 commented 6 years ago

PS: Since I am also able to build on linux from git RC_1_1, then it probably you're doing something wrong in preparing the libtorrent source to be built.