-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when compiling C++ #1
Comments
Hello,
On Tue, Nov 21, 2017 at 07:22:09PM +0000, mcaron1234 wrote:
I am getting an error when I try compiling the
C++ version. Can you spot my mistake?
I'm sorry, I hasn't read my email for about a
month. I see that you have deprecation warnings
about session() constructor, set_settings(),
pop_alerts() and get_torrent_info(). Which version
of libtorrent-rasterbar do you use? I use (on a
stable Devuan system which is roughly equivalent
to oldstable Debian):
* libtorrent-rasterbar-dev 0.16.18-1
* libboost1.55-dev 1.55.0+dfsg-3
* gcc/g++ 4:4.9.2-2
Then, the real problem is during linking phase:
"undefined reference to ..session_settings(...)"
and to a lot of other funcions... Typically this
is a problem with linker flags and IIRC with
-DBOOST_ASIO_SEPARATE_COMPILATION vs
-DBOOST_ASIO_DYN_LINK, but you have
"-DBOOST_ASIO_DYN_LINK" and "-ltorrent-rasterbar"
all right...
I think I have to check it with more recent
versions of boost, libtorrent-rasterbar and gcc.
I'll try it on Gentoo and write to you.
…--
With best regards,
Alexander
|
A followup:
On Tue, Nov 21, 2017 at 07:22:09PM +0000, mcaron1234 wrote:
I am getting an error when I try compiling the
C++ version. Can you spot my mistake?
***@***.***:~/Downloads/dev/mag2tor$ sudo make
g++ -std=c++11 -DBOOST_ASIO_DYN_LINK -lstdc++ -lboost_system -ltorrent-rasterbar mag2tor.cpp -o mag2tor
I tried building mag2tor on fresh Gentoo system
and got the next results:
1. all of the same deprecation warnings as you had
2. building with -DBOOST_ASIO_DYN_LINK resulted in
3 undefined references
3. -DBOOST_ASIO_SEPARATE_COMPILATION resulted in
the same 3 unresolved references
4. building with neiher -DBOOST_ASIO_DYN_LINK nor
-DBOOST_ASIO_SEPARATE_COMPILATION succeded.
So my recommendation is the next: edit Makefile
and try building with
a) CXXFLAGS=-std=c++11
or
b) CXXFLAGS=-std=c++11 -DBOOST_ASIO_SEPARATE_COMPILATION
And of course try building as ordinary user, not
root (sudo is not necessary).
I suspect that your libboost and
libtorrent-rasterbar might have been built with
different c++ "standard". On Gentoo, -std=c++14
will be used by default with new 17.0 system
profiles. Maybe you should also try:
c) CXXFLAGS=-std=c++14
d) CXXFLAGS=-std=c++14 -DBOOST_ASIO_DYN_LINK
e) CXXFLAGS=-std=c++14 -DBOOST_ASIO_SEPARATE_COMPILATION
On my Gentoo both a) and c) work OK and look the
same though...
…--
With best regards,
Alexander
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am getting an error when I try compiling the C++ version. Can you spot my mistake?
matt@apollo:~/Downloads/dev/mag2tor$ sudo make g++ -std=c++11 -DBOOST_ASIO_DYN_LINK -lstdc++ -lboost_system -ltorrent-rasterbar mag2tor.cpp -o mag2tor mag2tor.cpp: In function ‘int main(int, char**)’: mag2tor.cpp:94:36: warning: ‘libtorrent::session::session(const libtorrent::fingerprint&, int, uint32_t)’ is deprecated [-Wdeprecated-declarations] lt::session::add_default_plugins); ^ In file included from mag2tor.cpp:16:0: /usr/include/libtorrent/session.hpp:205:3: note: declared here session(fingerprint const& print ^~~~~~~ mag2tor.cpp:95:24: warning: ‘void libtorrent::session_handle::set_settings(const libtorrent::session_settings&)’ is deprecated [-Wdeprecated-declarations] sess.set_settings(sset); ^ In file included from /usr/include/libtorrent/session.hpp:53:0, from mag2tor.cpp:16: /usr/include/libtorrent/session_handle.hpp:808:8: note: declared here void set_settings(session_settings const& s); ^~~~~~~~~~~~ mag2tor.cpp:114:26: warning: ‘void libtorrent::session_handle::pop_alerts(std::deque<libtorrent::alert*>*)’ is deprecated [-Wdeprecated-declarations] sess.pop_alerts(&alerts); ^ In file included from /usr/include/libtorrent/session.hpp:53:0, from mag2tor.cpp:16: /usr/include/libtorrent/session_handle.hpp:916:8: note: declared here void pop_alerts(std::deque<alert*>* alerts); ^~~~~~~~~~ mag2tor.cpp:126:27: warning: ‘const libtorrent::torrent_info& libtorrent::torrent_handle::get_torrent_info() const’ is deprecated [-Wdeprecated-declarations] torh.get_torrent_info(); ^ In file included from /usr/include/libtorrent/alert_types.hpp:38:0, from mag2tor.cpp:12: /usr/include/libtorrent/torrent_handle.hpp:920:23: note: declared here const torrent_info& get_torrent_info() const; ^~~~~~~~~~~~~~~~ /tmp/cciTCjJL.o: In function
main':mag2tor.cpp:(.text+0x1ab): undefined reference to
libtorrent::session_settings::session_settings(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' mag2tor.cpp:(.text+0x1dc): undefined reference to
libtorrent::default_storage_constructor(libtorrent::storage_params const&)'mag2tor.cpp:(.text+0x43d): undefined reference to
libtorrent::session_handle::set_settings(libtorrent::session_settings const&)' mag2tor.cpp:(.text+0x467): undefined reference to
libtorrent::disabled_storage_constructor(libtorrent::storage_params const&)'mag2tor.cpp:(.text+0x4ae): undefined reference to
libtorrent::session_handle::add_torrent(libtorrent::add_torrent_params const&)' mag2tor.cpp:(.text+0x501): undefined reference to
libtorrent::session_handle::pop_alerts(std::deque<libtorrent::alert*, std::allocatorlibtorrent::alert* >)'mag2tor.cpp:(.text+0x665): undefined reference to
libtorrent::torrent_handle::status(unsigned int) const' mag2tor.cpp:(.text+0x67b): undefined reference to
libtorrent::torrent_status::~torrent_status()'mag2tor.cpp:(.text+0x692): undefined reference to
libtorrent::session_handle::pause()' mag2tor.cpp:(.text+0x6a1): undefined reference to
libtorrent::torrent_handle::get_torrent_info() const'mag2tor.cpp:(.text+0x6b6): undefined reference to
libtorrent::torrent_info::torrent_info(libtorrent::torrent_info const&)' mag2tor.cpp:(.text+0x7b6): undefined reference to
libtorrent::create_torrent::create_torrent(libtorrent::torrent_info const&)'mag2tor.cpp:(.text+0x7cf): undefined reference to
libtorrent::create_torrent::generate() const' mag2tor.cpp:(.text+0x810): undefined reference to
libtorrent::entry::~entry()'mag2tor.cpp:(.text+0x81f): undefined reference to
libtorrent::create_torrent::~create_torrent()' mag2tor.cpp:(.text+0x84c): undefined reference to
libtorrent::session_handle::remove_torrent(libtorrent::torrent_handle const&, int)'mag2tor.cpp:(.text+0x86b): undefined reference to
libtorrent::torrent_info::~torrent_info()' mag2tor.cpp:(.text+0x910): undefined reference to
libtorrent::session::~session()'mag2tor.cpp:(.text+0x92e): undefined reference to
libtorrent::session_settings::~session_settings()' mag2tor.cpp:(.text+0x9ca): undefined reference to
libtorrent::entry::~entry()'mag2tor.cpp:(.text+0x9de): undefined reference to
libtorrent::create_torrent::~create_torrent()' mag2tor.cpp:(.text+0xa06): undefined reference to
libtorrent::torrent_info::~torrent_info()'mag2tor.cpp:(.text+0xa42): undefined reference to
libtorrent::session::~session()' mag2tor.cpp:(.text+0xa6a): undefined reference to
libtorrent::session_settings::~session_settings()'/tmp/cciTCjJL.o: In function
__static_initialization_and_destruction_0(int, int)': mag2tor.cpp:(.text+0xae7): undefined reference to
boost::system::generic_category()'mag2tor.cpp:(.text+0xaf3): undefined reference to
boost::system::generic_category()' mag2tor.cpp:(.text+0xaff): undefined reference to
boost::system::system_category()'mag2tor.cpp:(.text+0xb17): undefined reference to
boost::asio::error::get_netdb_category()' mag2tor.cpp:(.text+0xb23): undefined reference to
boost::asio::error::get_addrinfo_category()'mag2tor.cpp:(.text+0xb2f): undefined reference to
boost::asio::error::get_misc_category()' /tmp/cciTCjJL.o: In function
boost::asio::error::get_system_category()':mag2tor.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to
boost::system::system_category()' /tmp/cciTCjJL.o: In function
libtorrent::session::session(libtorrent::fingerprint const&, int, unsigned int)':mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0x83): undefined reference to
libtorrent::ipv6_deprecated_()' mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0xac): undefined reference to
libtorrent::settings_pack::set_int(int, int)'mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0xda): undefined reference to
libtorrent::settings_pack::set_str(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0x10c): undefined reference to
libtorrent::settings_pack::set_bool(int, bool)'mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0x125): undefined reference to
libtorrent::settings_pack::set_bool(int, bool)' mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0x13e): undefined reference to
libtorrent::settings_pack::set_bool(int, bool)'mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0x157): undefined reference to
libtorrent::settings_pack::set_bool(int, bool)' mag2tor.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_11fingerprintEij[_ZN10libtorrent7sessionC5ERKNS_11fingerprintEij]+0x178): undefined reference to
libtorrent::session::start(int, libtorrent::settings_pack const&, boost::asio::io_service)'/tmp/cciTCjJL.o: In function
int libtorrent::detail::bencode_recursive<std::ostream_iterator<char, char, std::char_traits<char> > >(std::ostream_iterator<char, char, std::char_traits<char> >&, libtorrent::entry const&)': mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x2f): undefined reference to
libtorrent::entry::type() const'mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x78): undefined reference to
libtorrent::entry::integer() const' mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0xb3): undefined reference to
libtorrent::entry::stringabi:cxx11 const'mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0xed): undefined reference to
libtorrent::entry::string[abi:cxx11]() const' mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x128): undefined reference to
libtorrent::entry::listabi:cxx11 const'mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x140): undefined reference to
libtorrent::entry::list[abi:cxx11]() const' mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x1c9): undefined reference to
libtorrent::entry::dictabi:cxx11 const'mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x1e1): undefined reference to
libtorrent::entry::dict[abi:cxx11]() const' mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x2d3): undefined reference to
libtorrent::entry::preformatted() const'mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x2ea): undefined reference to
libtorrent::entry::preformatted() const' mag2tor.cpp:(.text._ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE[_ZN10libtorrent6detail17bencode_recursiveISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_RKNS_5entryE]+0x317): undefined reference to
libtorrent::entry::preformatted() const'/tmp/cciTCjJL.o: In function
int libtorrent::detail::write_integer<std::ostream_iterator<char, char, std::char_traits<char> > >(std::ostream_iterator<char, char, std::char_traits<char> >&, long)': mag2tor.cpp:(.text._ZN10libtorrent6detail13write_integerISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_l[_ZN10libtorrent6detail13write_integerISt16ostream_iteratorIccSt11char_traitsIcEEEEiRT_l]+0x37): undefined reference to
libtorrent::detail::integer_to_str(char*, int, long)'collect2: error: ld returned 1 exit status
: recipe for target 'mag2tor' failed
make: *** [mag2tor] Error 1
`
The text was updated successfully, but these errors were encountered: