正確姿勢是(autotool構(gòu)建,非cmake,不用build boost first!!!!)
1,./autotool.sh
2,./configure --enable-python-binding
3,make
4,make install (也會安裝python包的)
副作用,其中client_test.cpp編譯不通過,貌似依賴基于boost編譯的libtorrent庫
第一次 安裝deb
apt-get install libtorrent-dev
這個不好使(不能編譯成功libtorrent源碼中的example),切記!
第二次 源碼cmake構(gòu)建
1,下載
https://github.com/arvidn/libtorrent/archive/libtorrent-1_0_10.tar.gz
2,cmake
3,make
4,make install
5,sudo ldconfig (因?yàn)榘惭b到/usr/local/lib下,刷新)
libtorrent中的示例可以構(gòu)建了,但出現(xiàn)了新問題(python無法使用):
sudo apt-get install python-libtorrent
python -c "import libtorrent" 出錯!
第三次 源碼autotool構(gòu)建
有了之前的教訓(xùn),這回查了python使用libtorrent的相關(guān)資料,依賴boost,so big problem!,因?yàn)橹皥D省事,系統(tǒng)已經(jīng)apt get install 一堆boost的子模塊了,再重新編譯boost,太麻煩了,看到 http://libtorrent.org/building.html 有用autotool構(gòu)建python binding的方式,嘗試之
1,./autotool.sh
2,./configure --enable-python-binding
3,make
4,cd binding/python
5,python setup.py build
6,python setup install
python -c "import libtorrent" 出錯!,和上次出錯信息一樣:
undefined symbol: _ZN10libtorrent7versionEv
然后對/usr/local/lib/python2.7/dist-packages/libtorrent一通分析:
nm libtorrent.so 確實(shí)看到了這個符號
ldd libtorrent.so 發(fā)現(xiàn)了對 /usr/local/lib/libtorrent-rasterbar.so.8 的引用,然而這個是上次cmake構(gòu)建的,所以問題就在這(舊的libtorrent-rasterbar.so.8).