qbittorrent / qBittorrent

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

linking qbittorrent-nox fails #7394

Closed jrvmedic closed 7 years ago

jrvmedic commented 7 years ago

Please provide the following information

qBittorrent version and Operating System:

VER_MAJOR = 3 VER_MINOR = 4 VER_BUGFIX = 0 VER_BUILD = 0 uname -a: Linux 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

If on linux, libtorrent and Qt version:

LIBTORRENT: version 1.0.7 AND 1.1.4 (both) QT: 5.6.1

What is the problem:

Refuses to link linking qbittorrent-nox session.o: In function BitTorrent::Session::getPendingAlerts(std::vector<libtorrent::alert*, std::allocator<libtorrent::alert*> >&, unsigned long)': /home/jrv/usr/qBittorrent-master/src/base/bittorrent/session.cpp:3792: undefined reference tolibtorrent::session_handle::wait_for_alert(std::chrono::duration<long, std::ratio<1l, 1000000000l> >)' collect2: error: ld returned 1 exit status make[1]: *** [qbittorrent-nox] Error 1

What is the expected behavior:

that 'make' according to the directions found at: https://github.com/qbittorrent/qBittorrent/wiki/Compiling-qbittorrent-nox-for-CentOS-from-source runs to completion and creates an executable

Steps to reproduce:

Near virgin install of Centos 1611 with yum update vanilla build environment per: https://github.com/qbittorrent/qBittorrent/wiki/Compiling-qbittorrent-nox-for-CentOS-from-source

Extra info(if any):

zeule commented 7 years ago

Please check what is the signature of the function in the libtorrent-rasterbar.so. For example, on my system:

$ nm -D /usr/lib/libtorrent-rasterbar.so | grep wait_for_alert | c++filt 
00000000001bb2d0 T libtorrent::session_handle::wait_for_alert(std::chrono::duration<long, std::ratio<1l, 1000000000l> >)
jrvmedic commented 7 years ago

$ nm -D /usr/lib/libtorrent-rasterbar.so | grep wait_for_alert | c++filt 0000000000191780 T libtorrent::session_handle::wait_for_alert(boost::chrono::duration<long, boost::ratio<1l, 1000000000l> >)

that's with libtorrent-rasterbar-1.0.7 - don't have 1.1.4 available at the moment

zeule commented 7 years ago

Your libtorrent was compiled in C++03 mode, while qBittorrent requires C++11 mode enabled. That is why in your .so boost::chrono types are used, but when you compile qBt, it forces C++11 mode and included libtorrent headers switch to std::chrono. You need to built libtorrent with -std=c++11 (or later) compiler flag.

jrvmedic commented 7 years ago

I've never gotten bit by the C++03 vs. C++11 issue before, and it won't happen again. Thank you for the education.

For clarification, if following the wiki instructions for CentOS, then an updated command line for building libtorrent-rasterbar is:

./configure --prefix=/usr CPPFLAGS=-std=c++11

Today this works for both 1.0.7 in the original instructions and 1.1.4 from the current repository.

comrade-meowski commented 7 years ago

Not sure whether to open a new bug for this or comment here as my issue is clearly related.

I'm following jrvmedic's slightly modified instructions here adapted from https://github.com/qbittorrent/qBittorrent/wiki/Compiling-qbittorrent-nox-for-CentOS-from-source.

Details: RHEL 7.4 with kernels 4.13.9-1.el7.elrepo.x86_64 & 3.10.0-693.5.2.el7.x86_64. LIBTORRENT: versions 1.0.7, 1.1.4 & 1.1.5 [via: (https://github.com/arvidn/libtorrent/releases)] QBITTORRENT: 3.4.0 [via: git clone (https://github.com/qbittorrent/qBittorrent.git)] QT: 5.6.2 TOOLCHAINS: gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) and related tools plus the more recent gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC) + tools enabled from devtoolset-6

The target system is likewise a pretty much vanilla RHEL reference instance with all dependencies installed.

No matter which combination of tools and libtorrent versions used, I run into the same linker problem during the final stages of the qBittorrent make. I am passing the amended CPPFLAGS to libtorrent-rasterbar-* like so:

./configure --prefix=/usr CPPFLAGS=-std=c++11

Which gives me:

Build options:
  deprecated functions: yes
  debug build:          no
  invariant checks:     no
  logging support:      yes
  disk statistics:      no

Features:
  encryption support:   yes
  dht support:          yes
  pool allocators:      yes

Extra builds:
  examples:             no
  tests:                no
  python bindings:      no

Pthread library:
  CFlags:               -lpthread
  Libs:                 -lpthread 

Boost libraries:
  version:              
  CPPFlags:             -I/usr/include
  LDFlags:              -L/usr/lib64
  boost.system:         -lboost_system
  boost.chrono:         -lboost_chrono-mt
  boost.random:         -lboost_random-mt

External libraries:
  system libiconv:      no

OpenSSL library:
  OpenSSL Libs:         -lssl -lcrypto  
  OpenSSL LDFlags:       
  OpenSSL Includes:  

libtorrent-rasterbar-* builds and installs fine but the qBittorrent build bombs out in the final stages:

session.o: In function `BitTorrent::Session::getPendingAlerts(std::vector<libtorrent::alert*, std::allocator<libtorrent::alert*> >&, unsigned long)':
/home/ghost/SRC/qbitorrent-v3/qBittorrent/src/base/bittorrent/session.cpp:3842: undefined reference to `libtorrent::session_handle::wait_for_alert(std::chrono::duration<long, std::ratio<1l, 1000000000l> >)'
collect2: error: ld returned 1 exit status

Which looks a lot like the same error as jrvmedic was getting...

Checking "nm -D /usr/lib/libtorrent-rasterbar.so | grep wait_for_alert | c++filt":

$ nm -D /usr/lib/libtorrent-rasterbar.so | grep wait_for_alert | c++filt 
00000000001c1690 T libtorrent::session_handle::wait_for_alert(std::chrono::duration<long, std::ratio<1l, 1000000000l> >)

Which is exactly the same error that passing CPPFLAGS=-std=c++11 should have fixed.

Any ideas please? I can provide any logs and redo builds as requested.