c++g++libtorrent-rasterbar

libtorrent-rasterbar7: g++ linker unable to find libtorrent/session.hpp


When compiling the libtorrent tutorial 'hello world' with:

g++ main.cpp -o run -ltorrent-rasterbar -lboost_filesystem-mt -L /usr/lib/

=> fatal error: libtorrent/session.hpp: No such file or directory

Despite having libtorrent-rasterbar7 installed (both libtorrent-rasterbar.so.7 and libtorrent-rasterbar.so.7.0.0 exist in /usr/lib/). Also I'm able to run a simple python script that imports and uses libtorrent without issues.

The g++ command I'm using is identical to the solution for a similar issue with version 6 yet still having the error.


Solution

  • You haven't installed the libtorrent-rasterbar header files. The package you are missing is the libtorrent-rasterbar development package. What it is called depends on your distro. (On Debian or Ubuntu it is libtorrent-rasterbar-dev. On Fedora it is libtorrent-rasterbar-devel).

    Whenever you want to write an application that links with a packaged library you need to install not simply the runtime library but the associated development package, which provides both the runtime library and its header files.

    BTW, there is no need to pass -L /usr/lib to the linker as /usr/lib is one of the default linker search directories.