ubuntu12.10 下安装libtorrent

sudo svn co https://libtorrent.svn.sourceforge.net/svnroot/libtorrent/trunk

sudo apt-get install automake libtool libcppunit-dev

sudo ./autotool.sh

sudo ./configure --enable-dht --enable-test --enable-examples

sudo make

最后,切记

执行: sudo  cp  /usr/local/lib/pkgconfig/libtorrent-rasterbar.pc /usr/lib/pkgconfig/.

例子程序的编译方法:

    g++ -o dump_torrent dump_torrent.cpp $(pkg-config --libs --cflags libtorrent-rasterbar) -lboost_system-mt -lrt -lpthread


下面英文参考:(trunk/docs/building.html)

building with autotools

First of all, you need to install automake and autoconf. Many unix/linux systems comes with these preinstalled.

The prerequisites for building libtorrent are boost.thread, boost.date_time and boost.filesystem. Those are the compiled boost libraries needed. The headers-only libraries needed include (but is not necessarily limited to) boost.bind, boost.ref, boost.multi_index, boost.optional, boost.lexical_cast, boost.integer, boost.iterator, boost.tuple, boost.array, boost.function, boost.smart_ptr, boost.preprocessor, boost.static_assert.

If you want to build the client_test example, you'll also need boost.regex and boost.program_options.

STEP 1: GENERATING THE BUILD SYSTEM

No build system is present if libtorrent is checked out from CVS - it needs to be generated first. If you're building from a released tarball, you may skip directly to Step 2: Running configure.

Execute the following command to generate the build system:

./autotool.sh

STEP 2: RUNNING CONFIGURE

In your shell, change directory to the libtorrent directory and run ./configure. This will look for libraries and C++ features that libtorrent is dependent on. If something is missing or can't be found it will print an error telling you what failed.

The most likely problem you may encounter is that the configure script won't find the boost libraries. Make sure you have boost installed on your system. The easiest way to install boost is usually to use the preferred package system on your platform. Usually libraries and headers are installed in standard directories where the compiler will find them, but sometimes that may not be the case. For example when installing boost on darwin using darwinports (the package system based on BSD ports) all libraries are installed to /opt/local/lib and headers are installed to /opt/local/include. By default the compiler will not look in these directories. You have to set the enviornment variables LDFLAGS and CXXFLAGS in order to make the compiler find those libs. In this example you'd set them like this:

export LDFLAGS=-L/opt/local/lib
export CXXFLAGS=-I/opt/local/include

It was observed on FreeBSD (release 6.0) that one needs to add '-lpthread' to LDFLAGS, as Boost::Thread detection will fail without it, even if Boost::Thread is installed.

If you need to set these variables, it may be a good idea to add those lines to your ~/.profile or ~/.tcshrc depending on your shell.

If the boost libraries are named with a suffix on your platform, you may use the --with-boost-thread= option to specify the suffix used for the thread library in this case. For more information about these options, run:

./configure --help

On gentoo the boost libraries that are built with multi-threading support have the suffix mt.

You know that the boost libraries were found if you see the following output from the configure script:

checking whether the Boost::DateTime library is available... yes
checking for main in -lboost_date_time... yes
checking whether the Boost::Filesystem library is available... yes
checking for main in -lboost_filesystem... yes
checking whether the Boost::Thread library is available... yes
checking for main in -lboost_thread... yes

Another possible source of problems may be if the path to your libtorrent directory contains spaces. Make sure you either rename the directories with spaces in their names to remove the spaces or move the libtorrent directory.

CREATING A DEBUG BUILD

To tell configure to build a debug version (with debug info, asserts and invariant checks enabled), you have to run the configure script with the following option:

./configure --enable-debug=yes

CREATING A RELEASE BUILD

To tell the configure to build a release version (without debug info, asserts and invariant checks), you have to run the configure script with the following option:

./configure --enable-debug=no

The above option make use of -DNDEBUG, which is used throughout libtorrent.

STEP 3: BUILDING LIBTORRENT

Once the configure script is run successfully, you just type make and libtorrent, the examples and the tests will be built.

When libtorrent is built it may be a good idea to run the tests, you do this by running make check.

If you want to build a release version (without debug info, asserts and invariant checks), you have to rerun the configure script and rebuild, like this:

./configure --disable-debug
make clean
make

building with other build systems

If you're building in MS Visual Studio, you may have to set the compiler options "force conformance in for loop scope", "treat wchar_t as built-in type" and "Enable Run-Time Type Info" to Yes.

build configurations

By default libtorrent is built In debug mode, and will have pretty expensive invariant checks and asserts built into it. If you want to disable such checks (you want to do that in a release build) you can see the table below for which defines you can use to control the build.

macro description
NDEBUG If you define this macro, all asserts, invariant checks and general debug code will be removed. Since there is quite a lot of code in in header files in libtorrent, it may be important to define the symbol consistently across compilation units, including the clients files. Potential problems is different compilation units having different views of structs and class layouts and sizes.
TORRENT_LOGGING This macro will enable logging of the session events, such as tracker announces and incoming connections (as well as blocked connections).
TORRENT_DISABLE_GEO_IP This is defined by default by the Jamfile. It disables the GeoIP features, and avoids linking against LGPL:ed code.
TORRENT_VERBOSE_LOGGING If you define this macro, every peer connection will log its traffic to a log file as well as the session log.
TORRENT_STORAGE_DEBUG This will enable extra expensive invariant checks in the storage, including logging of piece sorting.
TORRENT_UPNP_LOGGING Generates a "upnp.log" file with the UPnP traffic. This is very useful when debugging support for various UPnP routers. support for various UPnP routers.
TORRENT_DISK_STATS This will create a log of all disk activity which later can parsed and graphed using parse_disk_log.py.
TORRENT_STATS This will generate a log with transfer rates, downloading torrents, seeding torrents, peers, connecting peers and disk buffers in use. The log can be parsed and graphed with parse_session_stats.py.
UNICODE If building on windows this will make sure the UTF-8 strings in pathnames are converted into UTF-16 before they are passed to the file operations.
TORRENT_DISABLE_POOL_ALLOCATOR Disables use of boost::pool<>.
TORRENT_LINKING_SHARED If this is defined when including the libtorrent headers, the classes and functions will be tagged with__declspec(dllimport) on msvc and default visibility on GCC 4 and later. Set this in your project if you're linking against libtorrent as a shared library. (This is set by the Jamfile when link=shared is set).
TORRENT_BUILDING_SHARED If this is defined, the functions and classes in libtorrent are marked with __declspec(dllexport) on msvc, or with default visibility on GCC 4 and later. This should be defined when building libtorrent as a shared library. (This is set by the Jamfile when link=shared is set).
TORRENT_DISABLE_DHT If this is defined, the support for trackerless torrents will be disabled.
TORRENT_DHT_VERBOSE_LOGGING This will enable verbose logging of the DHT protocol traffic.
TORRENT_DISABLE_ENCRYPTION This will disable any encryption support and the dependencies of a crypto library. Encryption support is the peer connection encrypted supported by clients such as uTorrent, Azureus and KTorrent. If this is not defined, either TORRENT_USE_OPENSSL or TORRENT_USE_GCRYPT must be defined.
_UNICODE On windows, this will cause the file IO use wide character API, to properly support non-ansi characters.
TORRENT_DISABLE_RESOLVE_COUNTRIES Defining this will disable the ability to resolve countries of origin for peer IPs.
TORRENT_DISABLE_INVARIANT_CHECKS This will disable internal invariant checks in libtorrent. The invariant checks can sometime be quite expensive, they typically don't scale very well. This option can be used to still build in debug mode, with asserts enabled, but make the resulting executable faster.
TORRENT_EXPENSIVE_INVARIANT_CHECKS This will enable extra expensive invariant checks. Useful for finding particular bugs or for running before releases.
TORRENT_NO_DEPRECATE This will exclude all deprecated functions from the header files and cpp files.
TORRENT_PRODUCTION_ASSERTS Define to either 0 or 1. Enables assert logging in release builds.
TORRENT_NO_ASSERTS Disables all asserts.
TORRENT_USE_SYSTEM_ASSERTS Uses the libc assert macro rather then the custom one.

If you experience that libtorrent uses unreasonable amounts of cpu, it will definitely help to define NDEBUG, since it will remove the invariant checks within the library.

building openssl for windows

To build openssl for windows with Visual Studio 7.1 (2003) execute the following commands in a command shell:

perl Configure VC-WIN32 --prefix="c:/openssl
call ms\do_nasm
call "C:\Program Files\Microsoft Visual Studio .NET 2003\vc7\bin\vcvars32.bat"
nmake -f ms\nt.mak
copy inc32\openssl "C:\Program Files\Microsoft Visual Studio .NET 2003\vc7\include\"
copy out32\libeay32.lib "C:\Program Files\Microsoft Visual Studio .NET 2003\vc7\lib"
copy out32\ssleay32.lib "C:\Program Files\Microsoft Visual Studio .NET 2003\vc7\lib"

This will also install the headers and library files in the visual studio directories to be picked up by libtorrent.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值