1 | ====== |
---|
2 | JCPUID |
---|
3 | ====== |
---|
4 | |
---|
5 | Windows |
---|
6 | ------- |
---|
7 | Install MS Visual Studio (comminity edition 2015 was last used). |
---|
8 | Import a project from the msvc files. And build a binary. |
---|
9 | |
---|
10 | Cross-compilation using mingw has been attempted with version 4.6.3 and 5.2.1 of mingw, |
---|
11 | but the resulting binaries have not been able to execute on 32-bit windows machines. |
---|
12 | 64-bit machines work fine though. |
---|
13 | |
---|
14 | FreeBSD |
---|
15 | ------- |
---|
16 | Compiled natively, x86 on a 32-bit install and x86_64 on a 64-bit install |
---|
17 | |
---|
18 | To build the 32-bit binaries run something like this: |
---|
19 | BITS=32 ./build.sh |
---|
20 | |
---|
21 | To build the 64-bit binaries run something like this: |
---|
22 | BITS=64 ./build.sh |
---|
23 | |
---|
24 | |
---|
25 | Linux |
---|
26 | ----- |
---|
27 | Compiled natively x86 and x86_64 on a 64-bit install |
---|
28 | |
---|
29 | To build the 32-bit binaries run something like this: |
---|
30 | BITS=32 ./build.sh |
---|
31 | |
---|
32 | To build the 64-bit binaries run something like this: |
---|
33 | BITS=64 ./build.sh |
---|
34 | |
---|
35 | |
---|
36 | OSX |
---|
37 | --- |
---|
38 | Compiled natively on OSX machine |
---|
39 | |
---|
40 | To build the 32-bit binaries run something like this: |
---|
41 | BITS=32 ./build.sh |
---|
42 | |
---|
43 | To build the 64-bit binaries run something like this: |
---|
44 | BITS=64 ./build.sh |
---|
45 | |
---|
46 | |
---|
47 | ===== |
---|
48 | JBIGI |
---|
49 | ===== |
---|
50 | |
---|
51 | |
---|
52 | Dynamic library build |
---|
53 | ===================== |
---|
54 | |
---|
55 | If you have a libgmp.so installed on your system already |
---|
56 | (check in /usr/lib), you can build a dynamically linked libjbigi.so as follows: |
---|
57 | cd jbigi |
---|
58 | build.sh dynamic |
---|
59 | You do, of course, need the gmp headers installed. |
---|
60 | On ubuntu, check for libgmp3 and libgmp3-dev packages. |
---|
61 | This is much easier and faster than building GMP from source. |
---|
62 | |
---|
63 | |
---|
64 | Static library build |
---|
65 | ===================== |
---|
66 | |
---|
67 | Otherwise, the build script build.sh will download the the GMP source, |
---|
68 | unpack and build it. The GMP version and download location are configured |
---|
69 | in jbigi/build.sh, please review it to ensure you download |
---|
70 | and build the desired version. |
---|
71 | |
---|
72 | To build the native jbigi and jcpuid libraries for the current host CPU, |
---|
73 | simply run sh build.sh and the results will be packaged up into jbigi.jar |
---|
74 | and the libjbigi.so library. |
---|
75 | |
---|
76 | To build the native jbigi libraries for all supported CPUs (on the current OS), |
---|
77 | go into jbigi/ and run build-all.sh (the results will be under jbigi/lib/) |
---|
78 | |
---|
79 | |
---|
80 | Build for more than one target at a time |
---|
81 | ======================================== |
---|
82 | |
---|
83 | jbigi/mbuild-all.sh is used to build a whole set of binaries at a time. |
---|
84 | Each run will build a set of binaries for a specific platform. |
---|
85 | |
---|
86 | Linux -> Windows cross-compilation |
---|
87 | ---------------------------------- |
---|
88 | Install ming-w64 (on debian or whichever package that provides i686-w64-mingw32 and x86_64_w64_mingw32). |
---|
89 | |
---|
90 | To build the 32-bit binaries run something like this: |
---|
91 | CC=i686-w64-mingw32-gcc TARGET=windows BITS=32 ./mbuild-all.sh |
---|
92 | |
---|
93 | To build the 64-bit binaries run something like this: |
---|
94 | CC=x86_64-w64-mingw32-gcc TARGET=windows BITS=64 ./mbuild-all.sh |
---|
95 | |
---|
96 | Linux -> FreeBSD cross-compilation |
---|
97 | ---------------------------------- |
---|
98 | Install gcc-multilib (on debian or whichever package that provides the C runtime) |
---|
99 | I used clang3.6 as CC, but gcc or most other things should work too. |
---|
100 | |
---|
101 | To build the 32-bit binaries run something like this: |
---|
102 | TARGET=freebsd BITS=32 ./mbuild-all.sh |
---|
103 | |
---|
104 | To build the 64-bit binaries run something like this: |
---|
105 | TARGET=freebsd BITS=64 ./mbuild-all.sh |
---|
106 | |
---|
107 | OSX Compilation |
---|
108 | --------------- |
---|
109 | No working cross-compilation setup has been found. The gmp6 binaries were produced on an OSX host. |
---|
110 | For more information on OSX compilation, see http://trac.i2p2.i2p/ticket/1865 or |
---|
111 | https://trac.i2p2.de/ticket/1865 |
---|
112 | |
---|
113 | There is no /usr/local/lib/libgmp.so dynamic library for macOS. |
---|
114 | The easiest way to get this is with Macports. |
---|
115 | These commands download, compile, and set Macports gcc as the default compiler |
---|
116 | if you put /opt/local/bin first in the PATH environment variable. |
---|
117 | |
---|
118 | sudo port install gmp |
---|
119 | sudo port select --list gcc |
---|
120 | sudo port select --set gcc mp-gcc6 |
---|
121 | export PATH=/opt/local/bin:$PATH |
---|
122 | gcc --version |
---|
123 | |
---|
124 | Now replace /usr/local/lib with /opt/local/lib in the file core/c/jbigi/build_jbigi.sh. |
---|
125 | |
---|
126 | $ diff build_jbigi.sh build_jbigi.sh.orig |
---|
127 | 81c81 |
---|
128 | < LIBPATH="-L.libs -L/opt/local/lib" |
---|
129 | --- |
---|
130 | > LIBPATH="-L.libs -L/usr/local/lib" |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | Installation and testing |
---|
135 | ======================== |
---|
136 | |
---|
137 | To test, copy jbigi/lib/libjbigi.so (Windows: jbigi.dll; Mac: libjbigi.jnilib) |
---|
138 | to your i2p installation directory ($I2P). |
---|
139 | Copy jcpuid/lib/freenet/support/CPUInformation/libjcpuid-*.so (Windows: jcpuid-*.dll; Mac: libjcpuid-*.jnilib) |
---|
140 | to your i2p installation directory ($I2P) as libjcpuid.so (Windows: jcpuid.dll; Mac: libjcpuid.jnilib) |
---|
141 | You may also copy jbigi.jar to the $I2P/lib/ directory; |
---|
142 | it will be used only if the router fails to load the native library |
---|
143 | from the I2P installation directory. |
---|
144 | |
---|
145 | The build.sh script runs two speed tests, one with your existing |
---|
146 | I2P installation and one with the new libjbigi. |
---|
147 | |
---|
148 | Alternatively, after copying the files to the i2p/ directory, |
---|
149 | to run a speed test comparing the native library to the java library, |
---|
150 | run the shell script below. Adjust the I2P= line as necessary. |
---|
151 | |
---|
152 | ----------------- |
---|
153 | |
---|
154 | #!/bin/sh |
---|
155 | export I2P=~/i2p |
---|
156 | java -cp $I2P/lib/i2p.jar:$I2P/lib/jbigi.jar net.i2p.util.NativeBigInteger |
---|