source: core/c/README @ c030852

i2p-0.9.34
Last change on this file since c030852 was 484a390, checked in by zzz <zzz@…>, 4 years ago

Build: Fix typo in jcpuid build.sh for Mac (ticket #1865)
Doc updates for Mac copied from that ticket

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