xlgjjff / libtorrent

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

Failed link libtorrent as shared library with TORRENT_NO_DEPRECATE define #733

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
  Link libtorrent as shared library with TORRENT_NO_DEPRECATE define

What is the expected output? What do you see instead?
  error LNK2019: unresolved external symbol "libtorrent::internal_file_entry::~internal_file_entry(void)" referenced in function "void * libtorrent::internal_file_entry::`scalar deleting destructor'(unsigned int)" 

  error LNK2019: unresolved external symbol "libtorrent::internal_file_entry::internal_file_entry(struct libtorrent::internal_file_entry const &)" referenced in function "public: void std::allocator<struct libtorrent::internal_file_entry>::construct<struct libtorrent::internal_file_entry,struct libtorrent::internal_file_entry &>(struct libtorrent::internal_file_entry *,struct libtorrent::internal_file_entry &)" 

  error LNK2019: unresolved external symbol "struct libtorrent::internal_file_entry & libtorrent::internal_file_entry::operator=(struct libtorrent::internal_file_entry const &)" referenced in function "struct libtorrent::internal_file_entry * std::_Copy_impl<struct libtorrent::internal_file_entry *,struct libtorrent::internal_file_entry *>(struct libtorrent::internal_file_entry *,struct libtorrent::internal_file_entry *,struct libtorrent::internal_file_entry *,struct std::_Nonscalar_ptr_iterator_tag)"

What version of the product are you using? On what operating system?
  libtorrent-rasterbar-1.0.4
  MS VS 2013 update 4
  (Win 8.1 64)

Please provide any additional information below.
  struct internal_file_entry exported only when TORRENT_NO_DEPRECATE undefined

  Following methods implemented in *.cpp:
    internal_file_entry(internal_file_entry const& fe);
      internal_file_entry& operator=(internal_file_entry const& fe);
      ~internal_file_entry();

  But internal_file_entry stored in std::vector:
    class file_storage
       std::vector<std::string> m_symlinks;

  All used defines:
    'TORRENT_DISABLE_GEO_IP'
    'TORRENT_DISABLE_ENCRYPTION'
    'TORRENT_DISABLE_FULL_STATS'
    'TORRENT_NO_DEPRECATE'
    'TORRENT_DISABLE_INVARIANT_CHECKS'
    'TORRENT_NO_ASSERTS'
    'TORRENT_BUILDING_SHARED'
    'TORRENT_DEBUG' // on debug

Original issue reported on code.google.com by rominmai...@gmail.com on 9 Apr 2015 at 9:50

GoogleCodeExporter commented 8 years ago
trying this with the examples I can't reproduce it. I would have expected at 
least the make_torrent example to exercise the file_storage class.

Do you have a small example that can reproduce this?

Original comment by arvid.no...@gmail.com on 10 Apr 2015 at 11:46

GoogleCodeExporter commented 8 years ago
it seems like the default-generated copy constructor may be inlined and require 
some access to internal_file_entry.

Original comment by arvid.no...@gmail.com on 11 Apr 2015 at 12:06

GoogleCodeExporter commented 8 years ago
could you try the patch r10956 to RC_1_0 and see if that fixes it?

Index: src/file_storage.cpp
===================================================================
--- src/file_storage.cpp    (revision 10955)
+++ src/file_storage.cpp    (revision 10956)
@@ -48,6 +48,39 @@

    file_storage::~file_storage() {}

+   // even though this copy constructor and the copy assignment
+   // operator are identical to what the compiler would have
+   // generated, they are put here to explicitly make them part
+   // of libtorrent and properly exported by the .dll.
+   file_storage::file_storage(file_storage const& f)
+       : m_files(f.m_files)
+       , m_file_hashes(m_file_hashes)
+       , m_symlinks(m_symlinks)
+       , m_mtime(m_mtime)
+       , m_file_base(m_file_base)
+       , m_paths(m_paths)
+       , m_name(m_name)
+       , m_total_size(m_total_size)
+       , m_num_pieces(m_num_pieces)
+       , m_piece_length(m_piece_length)
+   {
+   }
+
+   file_storage& file_storage::operator=(file_storage const& f)
+   {
+       m_files = f.m_files;
+       m_file_hashes = m_file_hashes;
+       m_symlinks = m_symlinks;
+       m_mtime = m_mtime;
+       m_file_base = m_file_base;
+       m_paths = m_paths;
+       m_name = m_name;
+       m_total_size = m_total_size;
+       m_num_pieces = m_num_pieces;
+       m_piece_length = m_piece_length;
+       return *this;
+   }
+
    void file_storage::reserve(int num_files)
    {
        m_files.reserve(num_files);
Index: include/libtorrent/file_storage.hpp
===================================================================
--- include/libtorrent/file_storage.hpp (revision 10955)
+++ include/libtorrent/file_storage.hpp (revision 10956)
@@ -237,6 +237,8 @@
        file_storage();
        // hidden
        ~file_storage();
+       file_storage(file_storage const& f);
+       file_storage& operator=(file_storage const&);

        // returns true if the piece length has been initialized
        // on the file_storage. This is typically taken as a proxy

Original comment by arvid.no...@gmail.com on 11 Apr 2015 at 2:29

GoogleCodeExporter commented 8 years ago
That patch is not correct. there are "f." missing in front of most of the 
members that are supposed to be copied.

Original comment by arvid.no...@gmail.com on 11 Apr 2015 at 5:37

GoogleCodeExporter commented 8 years ago
Thanks. Fix works. RC_1_0 (10964) linked successfully.

Original comment by rominmai...@gmail.com on 13 Apr 2015 at 9:47

GoogleCodeExporter commented 8 years ago

Original comment by arvid.no...@gmail.com on 13 Apr 2015 at 12:28