Closed dessalines closed 9 years ago
Hi @tchoulihan, can you take a look at build_windows.bat? it's a lot more documented, and you can extrapolate the ideas to the linux script. Let me know if some step is not clear.
What I can tell you is that you should not need any system install besides libssl and libcrypto++. Just uncompress boost_1.58 and libtorrent (I work with libtorrent RC_1_0 branch) and point the variables $BOOST_ROOT and $LIBTORRENT_ROOT.
Read this too: https://github.com/frostwire/frostwire-jlibtorrent/issues/18, specially the part about "const static".
There are several directory possibilities for both boost and libtorrent_root that make this difficult. What would work better, is if you could tell me what type of files the installer is looking for.
For boost, the files/folders I find are:
/usr/include/c++/4.8/bits/boost_concept_check.h
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.54.0
/usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.54.0
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0
/usr/share/app-install/desktop/pianobooster:pianobooster.desktop
/usr/share/app-install/icons/pianobooster.png
/usr/share/doc/libboost-python1.54.0
/usr/share/doc/libboost-system1.54.0
/usr/share/doc/libboost-python1.54.0/changelog.Debian.gz
/usr/share/doc/libboost-python1.54.0/copyright
/usr/share/doc/libboost-system1.54.0/changelog.Debian.gz
/usr/share/doc/libboost-system1.54.0/copyright
/usr/share/lintian/overrides/libboost-python1.54.0
/usr/share/lintian/overrides/libboost-system1.54.0
/usr/src/linux-headers-3.13.0-45/scripts/rt-tester/t4-l2-pi-deboost.tst
/usr/src/linux-headers-3.13.0-45/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
/usr/src/linux-headers-3.13.0-45/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
/usr/src/linux-headers-3.13.0-46/scripts/rt-tester/t4-l2-pi-deboost.tst
/usr/src/linux-headers-3.13.0-46/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
/usr/src/linux-headers-3.13.0-46/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
/var/lib/dpkg/info/libboost-python1.54.0:amd64.list
/var/lib/dpkg/info/libboost-python1.54.0:amd64.md5sums
/var/lib/dpkg/info/libboost-python1.54.0:amd64.postinst
/var/lib/dpkg/info/libboost-python1.54.0:amd64.postrm
/var/lib/dpkg/info/libboost-python1.54.0:amd64.shlibs
/var/lib/dpkg/info/libboost-system1.54.0:amd64.list
/var/lib/dpkg/info/libboost-system1.54.0:amd64.md5sums
/var/lib/dpkg/info/libboost-system1.54.0:amd64.postinst
/var/lib/dpkg/info/libboost-system1.54.0:amd64.postrm
/var/lib/dpkg/info/libboost-system1.54.0:amd64.shlibs
For libtorrent, the files/folders i find are:
/usr/lib/libtorrent-rasterbar.so.7
/usr/lib/libtorrent-rasterbar.so.7.0.0
/usr/lib/python2.7/dist-packages/libtorrent.so
/usr/lib/python2.7/dist-packages/python_libtorrent-0.16.13.egg-info
/usr/lib/python2.7/dist-packages/deluge/_libtorrent.py
/usr/lib/python2.7/dist-packages/deluge/_libtorrent.pyc
/usr/share/doc/libtorrent-rasterbar7
/usr/share/doc/python-libtorrent
/usr/share/doc/libtorrent-rasterbar7/AUTHORS
/usr/share/doc/libtorrent-rasterbar7/README.Debian
/usr/share/doc/libtorrent-rasterbar7/changelog.Debian.gz
/usr/share/doc/libtorrent-rasterbar7/copyright
/usr/share/doc/python-libtorrent/changelog.Debian.gz
/usr/share/doc/python-libtorrent/copyright
/var/lib/dpkg/info/libtorrent-rasterbar7.list
/var/lib/dpkg/info/libtorrent-rasterbar7.md5sums
/var/lib/dpkg/info/libtorrent-rasterbar7.postinst
/var/lib/dpkg/info/libtorrent-rasterbar7.postrm
/var/lib/dpkg/info/libtorrent-rasterbar7.shlibs
/var/lib/dpkg/info/python-libtorrent.list
/var/lib/dpkg/info/python-libtorrent.md5sums
Don't use the system installed ones, just grab the source from boost and libtorrent, and uncompress them in one working folder (inside your home).
Oh, so just use the downloaded folder locations? I'll do that and report back
libtorrent_root
is meant to point to your libtorrent source folder.
@tchoulihan Here are some old and detailed instructions I wrote to build on Mac https://gist.github.com/gubatron/dc0e29b9273741c9c14c
They need to be updated to the current state of the script, but it should give you a good idea on how to build for linux.
Once you get to build it, I'd love to hear any questions you may have on how to use the API (as well as some feedback on how to make it better, e.g. you will find that many of the libtorrent functionality is available if you do someClassInstance.getSwig().original_libtorrent_method_signature_here()
, if you find yourself doing that a lot, this is a sign that we need to expose the lower level functionality to the corresponding Java abstraction)
We've been busy coding it and using it, but not so much documenting it, which is IMO a success factor for any API out there. Your feedback will help us prioritize what to document.
I've updated the wiki page to include a link to the mac build instructions.
I installed both boost-58 and libtorrent-rasterbar7, set those 2 environment variables:
export LIBTORRENT_ROOT="/home/tyler/Downloads/libtorrent-rasterbar-1.0.5"
export BOOST_ROOT="/home/tyler/Downloads/boost_1_58_0"
and here's the errors now:
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent/build$ ./run_swig.sh
Unable to find file 'swig/libtorrent.i'.
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent/build$ ./build_linux.sh
g++: error: swig/libtorrent_jni.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
g++: error: libtorrent_jni.o: No such file or directory
g++: error: missing argument to ‘-L’
strip: 'libjlibtorrent.so': No such file
So i went into the script and changed it to look up a directory, and now I'm getting these errors.
./run_swig.sh
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent/build$ ./run_swig.sh
../swig/libtorrent.i:255: Error: Unable to find 'std_auto_ptr.i'
./build_linux.sh
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent/build$ ./build_linux.sh
../swig/libtorrent_jni.cpp:160:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
g++: error: libtorrent_jni.o: No such file or directory
g++: error: missing argument to ‘-L’
strip: 'libjlibtorrent.so': No such file
Run the scripts from the root of frostwire-jlibtorrent. That means: ./build/build_linux.sh
Don't run run_swig.sh unless you are fully familiarized with the swig process. You have all the generated source code already.
I'm not sure if the source code from swig is correct. Here's the error I'm getting:
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent$ sudo ./build/build_linux.sh
swig/libtorrent_jni.cpp:160:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
g++: error: libtorrent_jni.o: No such file or directory
g++: error: missing argument to ‘-L’
strip: 'libjlibtorrent.so': No such file
I also added the jni.h file to the gcc using:
sudo ln -s $JAVA_HOME/include/linux/jni_md.h /usr/lib/jvm/java-8-oracle/include/jni_md.h
sudo gcc $JAVA_HOME/include/jni.h
And the same error still comes up.
build_linux.sh has hardcoded the jvm 8 include paths for openjdk, you are using oracle, you can either change the paths in the script or install the openjdk one.
Thanks, I repointed those two include lines to my java install, and now I'm getting some weird errors with swig:
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent$ sudo ./build/build_linux.sh
In file included from swig/libtorrent_jni.cpp:970:0:
swig/session_extend.h:47:39: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
virtual std::auto_ptr<alert> clone() const \
^
swig/session_extend.h:60:2: note: in expansion of macro ‘TORRENT_DEFINE_ALERT’
TORRENT_DEFINE_ALERT(dht_get_peers_reply_alert, user_alert_id + 100);
^
swig/session_extend.h:47:39: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
virtual std::auto_ptr<alert> clone() const \
^
swig/session_extend.h:84:2: note: in expansion of macro ‘TORRENT_DEFINE_ALERT’
TORRENT_DEFINE_ALERT(set_piece_hashes_alert, user_alert_id + 101);
^
swig/libtorrent_jni.cpp: In function ‘jlong Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_session_1get_1dht_1settings(JNIEnv*, jclass, jlong, jobject)’:
swig/libtorrent_jni.cpp:78201:53: error: ‘const class libtorrent::session’ has no member named ‘get_dht_settings’
result = ((libtorrent::session const *)arg1)->get_dht_settings();
^
swig/libtorrent_jni.cpp: In function ‘jlong Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_session_1pop_1alert(JNIEnv*, jclass, jlong, jobject)’:
swig/libtorrent_jni.cpp:79006:38: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
std::auto_ptr< libtorrent::alert > result;
^
g++: error: libtorrent_jni.o: No such file or directory
g++: error: missing argument to ‘-L’
strip: 'libjlibtorrent.so': No such file
My swig version is 2.0.11 . Should I try swig3?
Did you run run_swig.sh? Revert the changes related to that (I recommend you a clean start).
That's never worked for me, I just get this error:
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent$ ./build/run_swig.sh
swig/libtorrent.i:255: Error: Unable to find 'std_auto_ptr.i'
edit: I also can't locate that file on my file system, after installing swig2.0 and swig3.0 through apt-get
Yes, but in the process, you probably messed up the repo. git status and you will see.
Hrm, for some reason almost all the swig.java files got deleted, I'll clone this again.
And don't run run_swig.sh
Okay, I just did a fresh clone, changed the java source folders, didn't run the run_swig.sh, but am still getting a ton of errors related to that std_auto_ptr.i file:
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent$ ./build/build_linux.sh
In file included from swig/libtorrent_jni.cpp:663:0:
/home/tyler/Downloads/libtorrent-rasterbar-1.0.5/include/libtorrent/alert_types.hpp:117:39: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
virtual std::auto_ptr<alert> clone() const \
^
/home/tyler/Downloads/libtorrent-rasterbar-1.0.5/include/libtorrent/alert_types.hpp:153:3: note: in expansion of macro ‘TORRENT_DEFINE_ALERT’
TORRENT_DEFINE_ALERT(torrent_removed_alert);
^
/home/tyler/Downloads/libtorrent-rasterbar-1.0.5/include/libtorrent/alert_types.hpp:117:39: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
virtual std::auto_ptr<alert> clone() const \
^
/home/tyler/Downloads/libtorrent-rasterbar-1.0.5/include/libtorrent/alert_types.hpp:174:3: note: in expansion of macro ‘TORRENT_DEFINE_ALERT’
TORRENT_DEFINE_ALERT(read_piece_alert);
^
... a lot more
These are warnings, what's at the end?
...
swig/libtorrent_jni.cpp: In function ‘jlong Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_session_1pop_1alert(JNIEnv*, jclass, jlong, jobject)’:
swig/libtorrent_jni.cpp:79006:38: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
std::auto_ptr< libtorrent::alert > result;
^
g++: error: libtorrent_jni.o: No such file or directory
g++: error: missing argument to ‘-L’
strip: 'libjlibtorrent.so': No such file
Did you export LIBTORRENT_LIBS?
I didn't, I just have:
export LIBTORRENT_ROOT="/home/tyler/Downloads/libtorrent-rasterbar-1.0.5"
export BOOST_ROOT="/home/tyler/Downloads/boost_1_58_0"
where should that point to?
If you told me the name of one of the .a files, I could try to locate it.
You need to actually compile boost, libtorrent and all the resulting libraries, put them in a folder (LIBTORRENT_LIBS), I think that's documented in the link @gubatron mentioned.
LIBTORRENT_LIBS
is simply a folder where all the dependency libraries should be available for the linker. It must contain the libtorrent.a file along with all the other boost libraries needed.
looks like you're finally building it all, it just can't link.
I'm building a script to automate most of this BTW, saving everything as I go. I installed boost with this, and it didn't run into any problems:
sudo apt-get install libbz2-dev
cd $BOOST_ROOT
./bootstrap
./b2
$BOOST_ROOT/b2 variant=release link=static --stagedir=linux stage cxxflags="-O2 -fPIC" --with-date_time --with-chrono --with-system --with-random --with-thread
Now the problem I'm running into is from this line script that builds the libtorrent.a file...
cd $LIBTORRENT_ROOT
$BOOST_ROOT/bjam toolset=gcc cxxflags="-O2 -fPIC" cflags="-fPIC" variant=release link=static deprecated-functions=off logging=none encryption=openssl boost=source
Here's the output:
tyler@tyler-ThinkPad-Edge-E545:~/Downloads/libtorrent-rasterbar-1.0.5$ $BOOST_ROOT/bjam toolset=gcc cxxflags="-O2 -fPIC" cflags="-fPIC" variant=release link=static deprecated-functions=off logging=none encryption=openssl boost=source
warning: mismatched versions of Boost.Build engine and core
warning: Boost.Build engine (/home/tyler/Downloads/boost_1_58_0/bjam) is 2014.03.00
warning: Boost.Build core (at /usr/share/boost-build) is 2011.12-svn
BOOST_ROOT = /home/tyler/Downloads/boost_1_58_0
CXXFLAGS = -stdlib=libc++ -std=c++11 -O3 -I/home/tyler/Downloads/boost_1_58_0
LDFLAGS =
OS = LINUX
/usr/share/boost-build/build/feature.jam:139: in feature.feature from module feature
error: unknown attributes: hidden
error: in feature declaration:
error: feature "deduced-address-model" : "32" "64" : "propagated" "optional" "composite" "hidden"
/home/tyler/Downloads/boost_1_58_0/boostcpp.jam:570: in load from module boostcpp
/usr/share/boost-build/kernel/modules.jam:289: in modules.import from module modules
/usr/share/boost-build/build/project.jam:1024: in import from module Jamfile</home/tyler/Downloads/boost_1_58_0>
/home/tyler/Downloads/boost_1_58_0/Jamroot:124: in modules.load from module Jamfile</home/tyler/Downloads/boost_1_58_0>
/usr/share/boost-build/build/project.jam:311: in load-jamfile from module project
/usr/share/boost-build/build/project.jam:64: in load from module project
/usr/share/boost-build/build/project.jam:89: in load-used-projects from module project
/usr/share/boost-build/build/project.jam:75: in load from module project
/usr/share/boost-build/build/project.jam:145: in project.find from module project
/usr/share/boost-build/build-system.jam:535: in load from module build-system
/usr/share/boost-build/kernel/modules.jam:289: in import from module modules
/usr/share/boost-build/kernel/bootstrap.jam:139: in boost-build from module
/usr/share/boost-build/boost-build.jam:8: in module scope from module
where did you get libtorrent, if you're having issues building libtorrent it could be that you're running from the trunk maybe?
LDFLAGS =
this also calls my attention, I believe there should be some link flags there, no @aldenml ?
checking my environment, I have this set for $LDFLAGS
-L/Users/gubatron/src/boost_1_57_0/stage/lib
try adding that to your environment, changing to the corresponding path.
@gubatron No. It's pretty clear for me that he is having a very typical boost conflict:
warning: mismatched versions of Boost.Build engine and core
warning: Boost.Build engine (/home/tyler/Downloads/boost_1_58_0/bjam) is 2014.03.00
warning: Boost.Build core (at /usr/share/boost-build) is 2011.12-svn
@tchoulihan try to avoid the system installed boost (remove it if you can).
will do
Edit: I originally installed both boost and libtorrent in the more traditional apt-get way
oh I see. What has worked best for me @tchoulihan (on Mac) has been simply downloading a binary boost release and pointing paths to their includes/ and linking to their libraries.
me so you to build this!
@gubatron Are you sure?
it's becoming personal, I feel his pain, been there (for all OSes) before.
Dann @aldenml you've been crushing it.
Okay, so now I have all those .a files including libtorrent.a in the $LIBTORRENT_LIBS dir, but I'm still getting this error when running ./build/build_linux.sh:
...
swig/libtorrent_jni.cpp: In function ‘jlong Java_com_frostwire_jlibtorrent_swig_libtorrent_1jni_session_1pop_1alert(JNIEnv*, jclass, jlong, jobject)’:
swig/libtorrent_jni.cpp:79006:38: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
std::auto_ptr< libtorrent::alert > result;
^
g++: error: libtorrent_jni.o: No such file or directory
strip: 'libjlibtorrent.so': No such file
I need to see the error during the compilation, try to look for it inside the entire output. (copy and grep).
grepping for error in the output:
tyler@tyler-ThinkPad-Edge-E545:~/git/frostwire-jlibtorrent$ grep error b.out
TORRENT_DEFINE_ALERT(tracker_error_alert);
TORRENT_DEFINE_ALERT(peer_error_alert);
TORRENT_DEFINE_ALERT(file_error_alert);
TORRENT_DEFINE_ALERT(udp_error_alert);
TORRENT_DEFINE_ALERT(portmap_error_alert);
TORRENT_DEFINE_ALERT(torrent_error_alert);
TORRENT_DEFINE_ALERT(dht_error_alert);
swig/libtorrent_jni.cpp:78201:53: error: ‘const class libtorrent::session’ has no member named ‘get_dht_settings’
g++: error: libtorrent_jni.o: No such file or directory
Ok, the problem is that libtorrent-1.0.5 is a little bit outdated. I'm working with the latest stable branch RC_1_0. Instead of downloading the tar.gz, perform this:
svn checkout svn://svn.code.sf.net/p/libtorrent/code/branches/RC_1_0 libtorrent-RC_1_0
and adjust the paths
okay, will do
Here's the error I have now:
/usr/bin/ld: /home/tyler/LIBTORRENT_LIBS/libboost_system.a(error_code.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/tyler/LIBTORRENT_LIBS/libboost_system.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
strip: 'libjlibtorrent.so': No such file
Which is weird because I compiled boost with that -fPIC flag, like this:
cd $BOOST_ROOT
./bootstrap
./b2
$BOOST_ROOT/b2 variant=release link=static --stagedir=linux stage cxxflags="-O2 -fPIC" --with-date_time --with-chrono --with-system --with-random --with-thread
cp linux/lib/*.a $LIBTORRENT_LIBS
Did you run b2 twice ? If that's the case, try again deleting the bin and linux folders,just to discard any previously generated object file
Just tried this, same error as before.
the error says this: recompile with -fPIC
I know it could be a little rough. I would like to make sure you are right with the boost compilation, do this:
cd $BOOST_ROOT
rm -rf bin*
rm -rf linux
$BOOST_ROOT/b2 variant=release link=static --stagedir=linux stage cxxflags="-O2 -fPIC" --with-date_time --with-chrono --with-system --with-random --with-thread
cp linux/lib/*.a $LIBTORRENT_LIBS
Let me know
@aldenml That did it! I wonder why...
Okay, so I have a working linux pre-install script. I'll post it here. I can either submit a pull request, and add this to the beginning of the build_linux.sh script, or I can leave it to your discretion on how to do this. Its fully automated, including downloading the necessary dependencies.
# Some setup
sudo apt-get install libbz2-dev libssl1.0.0 libcrypto++9 subversion
mkdir $HOME/LIBTORRENT_LIBS
export LIBTORRENT_LIBS="$HOME/LIBTORRENT_LIBS"
#export CXXFLAGS="-stdlib=libc++ -std=c++11 -O3 -I$BOOST_ROOT"
# Download Libtorrent and Boost, and export the home folders
cd $LIBTORRENT_LIBS
wget -O boost_1_58_0.tar.bz2 http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download
tar -xvf boost_1_58_0.tar.bz2
svn checkout svn://svn.code.sf.net/p/libtorrent/code/branches/RC_1_0 libtorrent-RC_1_0
# Set the exports
export LIBTORRENT_ROOT="$LIBTORRENT_LIBS/libtorrent-RC_1_0"
export BOOST_ROOT="$LIBTORRENT_LIBS/boost_1_58_0"
# Build boost and copy the .a files
cd $BOOST_ROOT
sh ./bootstrap.sh
rm -rf bin*
rm -rf linux
$BOOST_ROOT/b2 variant=release link=static --stagedir=linux stage cxxflags="-O2 -fPIC" --with-date_time --with-chrono --with-system --with-random --with-thread
cp linux/lib/*.a $LIBTORRENT_LIBS
# Build and copy the libtorrent .a files
cd $LIBTORRENT_ROOT
$BOOST_ROOT/bjam toolset=gcc cxxflags="-O2 -fPIC" cflags="-fPIC" variant=release link=static deprecated-functions=off logging=none encryption=openssl boost=source
sudo cp bin/gcc-4.8/release/boost-source/deprecated-functions-off/encryption-openssl/link-static/threading-multi/libtorrent.a $LIBTORRENT_LIBS/
# Run the build_linux script....
I rather let @gubatron to take a look at this.
something like this could be part of a ./configure.sh
is what I was thinking yesterday.
would just make it so that all paths and version numbers are configurable variables at the beginning of the script.
So things like this:
LIBTORRENT_VERSION="RC_1_0"
LIBTORRENT_FOLDER_NAME="libtorrent-$LIBTORRENT_VERSION"
LIBTORRENT_SVN_PATH="svn://svn.code.sf.net/p/libtorrent/code/branches/$LIBTORRENT_VERSION $LIBTORRENT_FOLDER_NAME"
...
svn checkout $LIBTORRENT_SVN_PATH
...
@tchoulihan If you submit a very well parametrized script to build/configure.linux.sh
I'll review it and work with you to include it.
The build instructions for linux are a bit unclear, and I'm having some problems.
So i downloaded libtorrent-rasterbar-1.0.5, (had to install boost as well for ubuntu which was unforeseen), ran make and make install, and it installed fine.
The run_swig.sh script didn't work in its directory, and neither did build_linux.sh.
I have no idea where the libtorrent root directories or libtorrent library dirs on my system should be. I'm running ubuntu.