caisan / libtorrent

Automatically exported from code.google.com/p/libtorrent
Other
0 stars 0 forks source link

[patch]: fixed problem with build any software on FreeBSD #355

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If I'll use libtorrent with leechcraft. I've problem with building:

/usr/home/zloidemon/freebsd-ports/leechcraft/work/leechcraft-0.5.75-145-g5f6d720
/src/plugins/bittorrent/core.cpp:2944:55:   instantiated from here
/usr/local/include/libtorrent/bencode.hpp:254:5: error: 'strtoll' was not 
declared in this scope

I've fixed problems in the bencode.hpp and attached patches for 0.15 and 0.16. 
Please add It's in upstream.

Thank you.

Original issue reported on code.google.com by G.Veniamin on 30 Jul 2012 at 8:41

Attachments:

GoogleCodeExporter commented 8 years ago
these patches would break when built on a 32 bit architecture though, wouldn't 
they? where long is just 32 bits.

would it be more appropriate to use the deprecated stroq() on BSD?

Original comment by arvid.no...@gmail.com on 30 Jul 2012 at 3:49

GoogleCodeExporter commented 8 years ago
does this patch work?

Original comment by arvid.no...@gmail.com on 9 Aug 2012 at 10:40

Attachments:

GoogleCodeExporter commented 8 years ago
I'm found the strtoll in the /usr/include/stdlib.h.

And I've tried test with is includes:

#if defined __FreeBSD__
#include <limits.h>
#include <stdlib.h>
#endif

But I have again error:
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1597:54:   instantiated from here
/usr/local/include/libtorrent/bencode.hpp:254:5: error: 'strtoll' was not 
declared in this scope
/usr/local/include/libtorrent/bencode.hpp: In function 'void 
libtorrent::detail::bdecode_recursive(InIt&, InIt, libtorrent::entry&, bool&, 
int) [with InIt = const char*]':
/usr/local/include/libtorrent/bencode.hpp:394:3:   instantiated from 
'libtorrent::entry libtorrent::bdecode(InIt, InIt) [with InIt = const char*]'
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:2944:55:   instantiated from here
/usr/local/include/libtorrent/bencode.hpp:254:5: error: 'strtoll' was not 
declared in this scope
*** Error code 1

Part of conde with strtool function in /usr/include/stdlib.h:

#ifdef __LONG_LONG_SUPPORTED
/* LONGLONG */
typedef struct {
        long long quot;
        long long rem;
} lldiv_t;

/* LONGLONG */
long long
         atoll(const char *);
/* LONGLONG */
long long
         llabs(long long) __pure2;
/* LONGLONG */
lldiv_t  lldiv(long long, long long) __pure2;
/* LONGLONG */
long long
         strtoll(const char * __restrict, char ** __restrict, int);
/* LONGLONG */
unsigned long long
         strtoull(const char * __restrict, char ** __restrict, int);
#endif /* __LONG_LONG_SUPPORTED */

void     _Exit(int) __dead2;
#endif /* __ISO_C_VISIBLE >= 1999 */

Original comment by G.Veniamin on 10 Aug 2012 at 8:13

GoogleCodeExporter commented 8 years ago
I tried your patch:

Making all in include/libtorrent
Making all in src
CXX      web_connection_base.lo
CXX      alert.lo
  CXX      allocator.lo
In file included from allocator.cpp:43:
/usr/include/stdlib.h:291: error: declaration of C function '__int64_t 
strtoq(const char*, char**, int)' conflicts with
/usr/include/stdlib.h:145: error: previous declaration 'long long int 
strtoq(const char*, char**, int)' here
*** Error code 1
1 error
*** Error code 1
1 error
*** Error code 1

Original comment by G.Veniamin on 10 Aug 2012 at 8:19

GoogleCodeExporter commented 8 years ago
It almost looks like __LONG_LONG_SUPPORTED is not defined on your architecture. 
You're not building on an architecture that doesn't have 64 bit math, are you?

Original comment by arvid.no...@gmail.com on 12 Aug 2012 at 7:43

GoogleCodeExporter commented 8 years ago
How about this patch? I realized I include <cstdlib> in bencoding.hpp, which 
may put strtoll() in the std:: namespace. This patch should fix that:

Index: include/libtorrent/bencode.hpp
===================================================================
--- include/libtorrent/bencode.hpp  (revision 7289)
+++ include/libtorrent/bencode.hpp  (working copy)
@@ -64,6 +64,9 @@

 #include <cstdlib>
+#include <string>
+#include <exception>
+#include <iterator> // for distance

 #ifdef _MSC_VER
 #pragma warning(push, 1)
@@ -248,11 +251,10 @@
                ++in; // 'e' 
                ret = entry(entry::int_t);
                char* end_pointer;
-#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW
-               ret.integer() = _strtoi64(val.c_str(), &end_pointer, 10);
-#else
+               // strtoll may live in std:: or
+               // it may be a macro (on windows)
+               using namespace std;
                ret.integer() = strtoll(val.c_str(), &end_pointer, 10);
-#endif
 #ifdef TORRENT_DEBUG
                ret.m_type_queried = false;
 #endif

Original comment by arvid.no...@gmail.com on 14 Aug 2012 at 1:02

GoogleCodeExporter commented 8 years ago
I use just amd64. I don't have x86 at now, but anyway I'll test in virtualbox.
Patch doesn't work:

[ 83%] Building CXX object 
plugins/bittorrent/CMakeFiles/leechcraft_bittorrent.dir/core.cpp.o
In file included from 
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:47:0:
/usr/local/include/libtorrent/bencode.hpp: In function 'void 
libtorrent::detail::bdecode_recursive(InIt&, InIt, libtorrent::entry&, bool&, 
int)':
/usr/local/include/libtorrent/bencode.hpp:257:58: error: there are no arguments 
to 'strtoll' that depend on a template parameter, so a declaration of 'strtoll' 
must be available [-fpermissive]
/usr/local/include/libtorrent/bencode.hpp:257:58: note: (if you use 
'-fpermissive', G++ will accept your code, but allowing the use of an 
undeclared name is deprecated)
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::DoDelayedInit()':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:213:31: warning: 'bool 
libtorrent::session::listen_on(const std::pair<int, int>&, const char*, int)' 
is deprecated (declared at /usr/local/include/libtorrent/session.hpp:342) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:229:40: warning: 'void 
libtorrent::session::set_max_uploads(int)' is deprecated (declared at 
/usr/local/include/libtorrent/session.hpp:442) [-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:231:44: warning: 'void 
libtorrent::session::set_max_connections(int)' is deprecated (declared at 
/usr/local/include/libtorrent/session.hpp:444) [-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:239:35: warning: 'void 
libtorrent::session::load_state(const libtorrent::entry&)' is deprecated 
(declared at /usr/local/include/libtorrent/session.hpp:304) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'int 
LeechCraft::Plugins::BitTorrent::Core::AddMagnet(const QString&, const 
QString&, const QStringList&, LeechCraft::TaskParameters)':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:830:11: warning: 
'libtorrent::torrent_handle libtorrent::add_magnet_uri(libtorrent::session&, 
const string&, libtorrent::add_torrent_params)' is deprecated (declared at 
/usr/local/include/libtorrent/magnet_uri.hpp:62) [-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::SetOverallDownloadRate(int)':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1030:66: warning: 'void 
libtorrent::session::set_download_rate_limit(int)' is deprecated (declared at 
/usr/local/include/libtorrent/session.hpp:440) [-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::SetOverallUploadRate(int)':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1036:64: warning: 'void 
libtorrent::session::set_upload_rate_limit(int)' is deprecated (declared at 
/usr/local/include/libtorrent/session.hpp:438) [-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::SetDesiredRating(double)':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1063:56: warning: 'void 
libtorrent::torrent_handle::set_ratio(float) const' is deprecated (declared at 
/usr/local/include/libtorrent/torrent_handle.hpp:284) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::SetTorrentDesiredRating(double)':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1110:70: warning: 'void 
libtorrent::torrent_handle::set_ratio(float) const' is deprecated (declared at 
/usr/local/include/libtorrent/torrent_handle.hpp:284) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'bool 
LeechCraft::Plugins::BitTorrent::Core::IsTorrentManaged() const':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1277:67: warning: 'bool 
libtorrent::torrent_handle::is_auto_managed() const' is deprecated (declared at 
/usr/local/include/libtorrent/torrent_handle.hpp:294) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'bool 
LeechCraft::Plugins::BitTorrent::Core::IsTorrentSequentialDownload() const':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1294:74: warning: 'bool 
libtorrent::torrent_handle::is_sequential_download() const' is deprecated 
(declared at /usr/local/include/libtorrent/torrent_handle.hpp:296) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'bool 
LeechCraft::Plugins::BitTorrent::Core::IsTorrentSuperSeeding() const':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1310:65: warning: 'bool 
libtorrent::torrent_handle::super_seeding() const' is deprecated (declared at 
/usr/local/include/libtorrent/torrent_handle.hpp:300) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::Export(const QString&, bool, bool) 
const':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1416:44: warning: 'bool 
libtorrent::torrent_handle::is_sequential_download() const' is deprecated 
(declared at /usr/local/include/libtorrent/torrent_handle.hpp:296) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 
'libtorrent::torrent_handle 
LeechCraft::Plugins::BitTorrent::Core::RestoreSingleTorrent(const QByteArray&, 
const QByteArray&, const boost::filesystem3::path&, bool, bool)':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:2009:43: warning: 'int 
libtorrent::lazy_bdecode(const char*, const char*, libtorrent::lazy_entry&, 
int, int)' is deprecated (declared at 
/usr/local/include/libtorrent/lazy_entry.hpp:65) [-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::queryLibtorrentForWarnings()':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:2534:41: warning: 'auto_ptr' is 
deprecated (declared at 
/usr/local/lib/gcc46/include/c++/backward/auto_ptr.h:87) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::tcpPortRangeChanged()':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:2599:87: warning: 'bool 
libtorrent::session::listen_on(const std::pair<int, int>&, const char*, int)' 
is deprecated (declared at /usr/local/include/libtorrent/session.hpp:342) 
[-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::maxUploadsChanged()':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:2612:39: warning: 'void 
libtorrent::session::set_max_uploads(int)' is deprecated (declared at 
/usr/local/include/libtorrent/session.hpp:442) [-Wdeprecated-declarations]
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp: In member function 'void 
LeechCraft::Plugins::BitTorrent::Core::maxConnectionsChanged()':
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:2618:43: warning: 'void 
libtorrent::session::set_max_connections(int)' is deprecated (declared at 
/usr/local/include/libtorrent/session.hpp:444) [-Wdeprecated-declarations]
In file included from 
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:47:0:
/usr/local/include/libtorrent/bencode.hpp: In function 'void 
libtorrent::detail::bdecode_recursive(InIt&, InIt, libtorrent::entry&, bool&, 
int) [with InIt = char*]':
/usr/local/include/libtorrent/bencode.hpp:396:3:   instantiated from 
'libtorrent::entry libtorrent::bdecode(InIt, InIt) [with InIt = char*]'
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:1597:54:   instantiated from here
/usr/local/include/libtorrent/bencode.hpp:257:5: error: 'strtoll' was not 
declared in this scope
/usr/local/include/libtorrent/bencode.hpp: In function 'void 
libtorrent::detail::bdecode_recursive(InIt&, InIt, libtorrent::entry&, bool&, 
int) [with InIt = const char*]':
/usr/local/include/libtorrent/bencode.hpp:396:3:   instantiated from 
'libtorrent::entry libtorrent::bdecode(InIt, InIt) [with InIt = const char*]'
/usr/home/zloidemon/Repos/zloidemon/misc/leechcraft/work/leechcraft-0.5.75-145-g
5f6d720/src/plugins/bittorrent/core.cpp:2944:55:   instantiated from here
/usr/local/include/libtorrent/bencode.hpp:257:5: error: 'strtoll' was not 
declared in this scope

Original comment by G.Veniamin on 14 Aug 2012 at 7:39

GoogleCodeExporter commented 8 years ago
Maybe strtoll is a C-only function, and only available in stdlib.h, and not 
cstdlib. In that case, this patch may work:

Index: include/libtorrent/bencode.hpp
===================================================================
--- include/libtorrent/bencode.hpp  (revision 7310)
+++ include/libtorrent/bencode.hpp  (working copy)
@@ -63,7 +63,10 @@

-#include <cstdlib>
+#include <stdlib.h>
+#include <string>
+#include <exception>
+#include <iterator> // for distance

 #ifdef _MSC_VER
 #pragma warning(push, 1)
@@ -248,11 +251,7 @@
                ++in; // 'e' 
                ret = entry(entry::int_t);
                char* end_pointer;
-#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW
-               ret.integer() = _strtoi64(val.c_str(), &end_pointer, 10);
-#else
                ret.integer() = strtoll(val.c_str(), &end_pointer, 10);
-#endif
 #ifdef TORRENT_DEBUG
                ret.m_type_queried = false;
 #endif
@@ -354,7 +353,7 @@
                    }
                    TORRENT_ASSERT(*in == ':');
                    ++in; // ':'
-                   int len = std::atoi(len_s.c_str());
+                   int len = atoi(len_s.c_str());
                    ret = entry(entry::string_t);
                    read_string(in, end, len, ret.string(), err);
                    if (err)

Original comment by arvid.no...@gmail.com on 14 Aug 2012 at 4:09