w00t-labs / libtorrent

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

simple_client.cpp compilation errors #739

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Just can't understand how to build simple_client.cpp separately.

What is the expected output? 

I expect to get a file to execute.

What do you see instead?

gcc -o simple_client simple_client.cpp
In file included from /usr/local/include/libtorrent/entry.hpp:68:0,
                 from simple_client.cpp:34:
/usr/local/include/libtorrent/config.hpp:58:2: error: #error you must define 
either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO_DYN_LINK in your project 
in order for asios declarations to be correct. If you are linking dynamically 
against libtorrent, define BOOST_ASIO_DYN_LINK otherwise 
BOOST_ASIO_SEPARATE_COMPILATION. You can also use pkg-config or boost build, to 
automatically apply these defines
 #error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO_DYN_LINK in your project in \
  ^
In file included from simple_client.cpp:38:0:
/usr/include/boost/asio/ssl/impl/src.hpp:19:3: error: #error Do not compile 
Asio library source with BOOST_ASIO_HEADER_ONLY defined
 # error Do not compile Asio library source with BOOST_ASIO_HEADER_ONLY defined
   ^
^C

And I added BOOST_ASIO_SEPARATE_COMPILATION:

grep "SEPAR" -b3 simple_client.cpp 
1605-#include "libtorrent/session.hpp"
1639-#include <boost/asio/impl/src.hpp>
1674-#include "boost/asio/ssl/impl/src.hpp"
1713:#define BOOST_ASIO_SEPARATE_COMPILATION 
1754-
1755-int main(int argc, char* argv[])
1788-{

What version of the product are you using? 

libtorrent-rasterbar-1.0.4

On what operating system?

cat /proc/version
Linux version 3.16.0-31-generic (buildd@toyol) (gcc version 4.8.2 (Ubuntu 
4.8.2-19ubuntu1) ) #43~14.04.1-Ubuntu SMP Tue Mar 10 20:13:38 UTC 2015

Please provide any additional information below.

Original issue reported on code.google.com by sergibondarenko@gmail.com on 23 Apr 2015 at 5:05

GoogleCodeExporter commented 8 years ago
thanks, fixed in RC_1_0.

Original comment by arvid.no...@gmail.com on 24 Apr 2015 at 6:08

GoogleCodeExporter commented 8 years ago
Hi.
I downloaded a newest version from http://sourceforge.net/. Installed it.
But nevertheless I can't compile simple_client.cpp separately:

sergibondarenko@serg11bondarenko:~/Development/libtorrent-rasterbar-1.0.4/exampl
es$ gcc -o simple_client simple_client.cpp
In file included from /usr/local/include/libtorrent/entry.hpp:68:0,
                 from simple_client.cpp:34:
/usr/local/include/libtorrent/config.hpp:58:2: error: #error you must define 
either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO_DYN_LINK in your project 
in order for asios declarations to be correct. If you are linking dynamically 
against libtorrent, define 
BOOST_ASIO_DYN_LINK otherwise BOOST_ASIO_SEPARATE_COMPILATION. You can also use 
pkg-config or boost build, to automatically apply these defines
 #error you must define either BOOST_ASIO_SEPARATE_COMPILATION or BOOST_ASIO_DYN_LINK in your project in \
  ^
In file included from simple_client.cpp:37:0:
/usr/local/include/boost/asio/impl/src.hpp:19:3: error: #error Do not compile 
Asio library source with BOOST_ASIO_HEADER_ONLY defined
 # error Do not compile Asio library source with BOOST_ASIO_HEADER_ONLY defined
   ^
In file included from simple_client.cpp:38:0:
/usr/local/include/boost/asio/ssl/impl/src.hpp:19:3: error: #error Do not 
compile Asio library source with BOOST_ASIO_HEADER_ONLY defined
 # error Do not compile Asio library source with BOOST_ASIO_HEADER_ONLY defined

grep -nH "SEPA" -b3 simple_client.cpp 
simple_client.cpp-37-1639-#include <boost/asio/impl/src.hpp>
simple_client.cpp-38-1674-#include <boost/asio/ssl/impl/src.hpp>
simple_client.cpp-39-1713-
simple_client.cpp:40:1714:#define BOOST_ASIO_SEPARATE_COMPILATION
simple_client.cpp-41-1754-
simple_client.cpp-42-1755-int main(int argc, char* argv[])
simple_client.cpp-43-1788-{

Original comment by sergibondarenko@gmail.com on 24 Apr 2015 at 8:43

GoogleCodeExporter commented 8 years ago
yes. download it from the RC_1_0 branch of the subversion repository instead.

https://sourceforge.net/p/libtorrent/code/HEAD/tree/

Original comment by arvid.no...@gmail.com on 24 Apr 2015 at 10:20

GoogleCodeExporter commented 8 years ago
Hi Arvid.

First of all, thank you for taking your time to answer these questions. 

I tried the suggested branch, installed it and got a new errors during 
simple_client.cpp compilation.

I downloaded RC_1_0 branch from subversion and installed it like in the 
following way:

./bootstrap.sh
./configure
sudo make && sudo make install

Tried to compile simple_client.cpp and had got the following errors:

g++ -o simple_client simple_client.cpp

/tmp/ccuMfuvM.o: In function `main':
simple_client.cpp:(.text+0x9a): undefined reference to 
`libtorrent::settings_pack::set_str(int, std::string)'
simple_client.cpp:(.text+0x16c): undefined reference to 
`libtorrent::default_storage_constructor(libtorrent::storage_params const&
)'
simple_client.cpp:(.text+0x369): undefined reference to 
`libtorrent::session::add_torrent(libtorrent::add_torrent_params const&, 
boost::system::error_code&)'
simple_client.cpp:(.text+0x427): undefined reference to 
`libtorrent::session::~session()'
simple_client.cpp:(.text+0x534): undefined reference to 
`libtorrent::session::~session()'
/tmp/ccuMfuvM.o: In function `__static_initialization_and_destruction_0(int, 
int)':
simple_client.cpp:(.text+0x587): undefined reference to 
`boost::system::generic_category()'
simple_client.cpp:(.text+0x593): undefined reference to 
`boost::system::generic_category()'
simple_client.cpp:(.text+0x59f): undefined reference to 
`boost::system::system_category()'
/tmp/ccuMfuvM.o: In function `boost::system::error_code::error_code()':
simple_client.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10erro
r_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
/tmp/ccuMfuvM.o: In function `boost::asio::error::get_system_category()':
simple_client.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4a
sio5error19get_system_categoryEv]+0x5): undefined reference to 
`boost::system::system_category()'
/tmp/ccuMfuvM.o: In function 
`libtorrent::session::session(libtorrent::settings_pack const&, int)':
simple_client.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_13settings_packEi[_ZN10l
ibtorrent7sessionC5ERKNS_13settings_packEi]+0x2d): undefined reference to 
`libtorrent::ipv6_deprecated_()'
simple_client.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_13settings_packEi[_ZN10l
ibtorrent7sessionC5ERKNS_13settings_packEi]+0x39): undefined reference to 
`libtorrent::session::init()'
simple_client.cpp:(.text._ZN10libtorrent7sessionC2ERKNS_13settings_packEi[_ZN10l
ibtorrent7sessionC5ERKNS_13settings_packEi]+0x4e): undefined reference to 
`libtorrent::session::start(int, libtorrent::settings_pack const&)'
/tmp/ccuMfuvM.o: In function 
`boost::detail::sp_if_not_array<libtorrent::torrent_info>::type 
boost::make_shared<libtorrent::torrent_info, std::string, 
boost::reference_wrapper<boost::system::error_code>, int>(std::string const&, 
boost::reference_wrapper<boost::system::error_code> const&, int const&)':
simple_client.cpp:(.text._ZN5boost11make_sharedIN10libtorrent12torrent_infoESsNS
_17reference_wrapperINS_6system10error_codeEEEiEENS_6detail15sp_if_not_arrayIT_E
4typeERKT0_RKT1_RKT2_[_ZN5boost11make_sharedIN10libtorrent12torrent_infoESsNS_17
reference_wrapperINS_6system10error_codeEEEiEENS_6detail15sp_if_not_arrayIT_E4ty
peERKT0_RKT1_RKT2_]+0x93): undefined reference to 
`libtorrent::torrent_info::torrent_info(std::string const&, 
boost::system::error_code&, int)'
/tmp/ccuMfuvM.o: In function 
`boost::detail::sp_ms_deleter<libtorrent::torrent_info>::destroy()':
simple_client.cpp:(.text._ZN5boost6detail13sp_ms_deleterIN10libtorrent12torrent_
infoEE7destroyEv[_ZN5boost6detail13sp_ms_deleterIN10libtorrent12torrent_infoEE7d
estroyEv]+0x2b): undefined reference to 
`libtorrent::torrent_info::~torrent_info()'
collect2: error: ld returned 1 exit status

My OS:

cat /proc/version
Linux version 3.13.0-49-generic (buildd@akateko) (gcc version 4.8.2 (Ubuntu 
4.8.2-19ubuntu1) ) #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015

My compiler:

g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.2-19ubuntu1' 
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs 
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr 
--program-suffix=-4.8 --enable-shared --enable-linker-build-id 
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix 
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls 
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug 
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap 
--enable-plugin --with-system-zlib --disable-browser-plugin 
--enable-java-awt=gtk --enable-gtk-cairo 
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home 
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar 
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic 
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu 
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) 

Original comment by sergibondarenko@gmail.com on 27 Apr 2015 at 2:52

GoogleCodeExporter commented 8 years ago
what happens if you add arguments to link against libtorrent?

g++ -o simple_client simple_client.cpp -llibtorrent

You may need to link against some boost library too, like boost_system

Original comment by arvid.no...@gmail.com on 27 Apr 2015 at 9:50

GoogleCodeExporter commented 8 years ago
Happens this:

g++ -o simple_client simple_client.cpp -llibtorrent
/usr/bin/ld: cannot find -llibtorrent
collect2: error: ld returned 1 exit status

My libtorrent lib:

ls /usr/local/lib/ |grep libtorrent
libtorrent-rasterbar.a
libtorrent-rasterbar.la
libtorrent-rasterbar.so
libtorrent-rasterbar.so.9
libtorrent-rasterbar.so.9.0.0

My boost lib:

ls /usr/local/lib/ | grep boost
libboost_atomic.a
libboost_atomic.so
libboost_atomic.so.1.58.0
libboost_chrono.a
libboost_chrono.so
libboost_chrono.so.1.58.0
libboost_container.a
libboost_container.so
libboost_container.so.1.58.0
libboost_context.a
libboost_context.so
libboost_context.so.1.58.0
libboost_coroutine.a
libboost_coroutine.so
libboost_coroutine.so.1.58.0
libboost_date_time.a
libboost_date_time.so
libboost_date_time.so.1.58.0
libboost_exception.a
libboost_filesystem.a
libboost_filesystem.so
libboost_filesystem.so.1.58.0
libboost_graph.a
libboost_graph.so
libboost_graph.so.1.58.0
libboost_iostreams.a
libboost_iostreams.so
libboost_iostreams.so.1.58.0
libboost_locale.a
libboost_locale.so
libboost_locale.so.1.58.0
libboost_log.a
libboost_log_setup.a
libboost_log_setup.so
libboost_log_setup.so.1.58.0
libboost_log.so
libboost_log.so.1.58.0
libboost_math_c99.a
libboost_math_c99f.a
libboost_math_c99f.so
libboost_math_c99f.so.1.58.0
libboost_math_c99l.a
libboost_math_c99l.so
libboost_math_c99l.so.1.58.0
libboost_math_c99.so
libboost_math_c99.so.1.58.0
libboost_math_tr1.a
libboost_math_tr1f.a
libboost_math_tr1f.so
libboost_math_tr1f.so.1.58.0
libboost_math_tr1l.a
libboost_math_tr1l.so
libboost_math_tr1l.so.1.58.0
libboost_math_tr1.so
libboost_math_tr1.so.1.58.0
libboost_prg_exec_monitor.a
libboost_prg_exec_monitor.so
libboost_prg_exec_monitor.so.1.58.0
libboost_program_options.a
libboost_program_options.so
libboost_program_options.so.1.58.0
libboost_python.a
libboost_python.so
libboost_python.so.1.58.0
libboost_random.a
libboost_random.so
libboost_random.so.1.58.0
libboost_regex.a
libboost_regex.so
libboost_regex.so.1.58.0
libboost_serialization.a
libboost_serialization.so
libboost_serialization.so.1.58.0
libboost_signals.a
libboost_signals.so
libboost_signals.so.1.58.0
libboost_system.a
libboost_system.so
libboost_system.so.1.58.0
libboost_test_exec_monitor.a
libboost_thread.a
libboost_thread.so
libboost_thread.so.1.58.0
libboost_timer.a
libboost_timer.so
libboost_timer.so.1.58.0
libboost_unit_test_framework.a
libboost_unit_test_framework.so
libboost_unit_test_framework.so.1.58.0
libboost_wave.a
libboost_wave.so
libboost_wave.so.1.58.0
libboost_wserialization.a
libboost_wserialization.so
libboost_wserialization.so.1.58.0

Original comment by sergibondarenko@gmail.com on 28 Apr 2015 at 6:30

GoogleCodeExporter commented 8 years ago
My boost version is 1.58. 

Original comment by sergibondarenko@gmail.com on 28 Apr 2015 at 6:33

GoogleCodeExporter commented 8 years ago
ok, so say: "-llibtorrent-rasterbar" instead

Original comment by arvid.no...@gmail.com on 28 Apr 2015 at 2:55

GoogleCodeExporter commented 8 years ago
Still doesn't work:

g++ -o simple_client simple_client.cpp -llibtorrent-rasterbar

/usr/bin/ld: cannot find -llibtorrent-rasterbar
collect2: error: ld returned 1 exit status

Original comment by sergibondarenko@gmail.com on 29 Apr 2015 at 7:33