Code Monkey home page Code Monkey logo

compile-monero-09-on-ubuntu-16-04's Introduction

Compile Monero 0.11 on Ubuntu 16.04 x64

The example shows how to compile the current github version of Monero, as of 7 Sep 2017, on Ubuntu 16.04 x64 or 16.10.

Dependencies

Before proceeding with the compilation, the following packages are required:

# update Ubuntu's repository
sudo apt update

#install git to download latest Monero source code from github
sudo apt install git

# install dependencies to be able to compile Monero
sudo apt install build-essential cmake libboost-all-dev miniupnpc libunbound-dev graphviz doxygen libunwind8-dev pkg-config libssl-dev libcurl4-openssl-dev libgtest-dev libreadline-dev libminiupnpc-dev libzmq3-dev


# For Fedora 25
#
# sudo dnf install git
# sudo dnf install make automake cmake gcc-c++ boost-devel miniupnpc-devel graphviz doxygen unbound-devel libunwind-devel pkgconfig openssl-devel libcurl-devel libreadline-dev

Ubuntu's libgtest-dev only includes sources code. You must build the library binary manually. This can be done with the following commands

# sudo apt-get install libgtest-dev # if not already installed from above
cd /usr/src/gtest 
sudo cmake . 
sudo make 
sudo mv libg* /usr/lib/

Compilation

# download the latest Monero source code from github
git clone --recursive https://github.com/monero-project/monero

# go into monero folder
cd monero/

# compile the release version.
make # or make -j number_of_threads, e.g., make -j 2

# alternatively `make release` can be used instead of `make`. This compiles
# the source code without compiling unique tests which is faster, and can
# avid problems if there are compilation errors with compiling the tests

Installation

After successful compilation, the Monero binaries should be located in ./build/release/bin. I usually move the binaries into /opt/monero/ folder. This can be done as follows:

# optional
sudo mkdir -p /opt/monero
sudo mv -v ./build/release/bin/* /opt/monero/

This should result in:

/opt/monero/
├── monero-blockchain-export
├── monero-blockchain-import
├── monerod
└── monero-wallet-cli

Now we can start the Monero daemon, i.e., monerod, and let it download the blockchain and synchronize itself with the Monero network. After that, you can run your the monero-wallet-cli.

# launch the Monero daemon and let it synchronize with the Monero network
/opt/monero/monerod --detach

# launch the Monero wallet
/opt/monero/monero-wallet-cli

Useful aliases (with rlwrap)

monerod and monero-wallet-cli do not have tab-compliton nor history. This problem can be overcome using rlwrap.

# install rlwrap
sudo apt install rlwrap

# download monerod and monero-wallet-cli commands files
wget -O ~/.bitmonero/monerocommands_bitmonerod.txt https://raw.githubusercontent.com/moneroexamples/compile-monero-09-on-ubuntu-16-04/master/monerocommands_bitmonerod.txt

wget -O ~/.bitmonero/monerocommands_simplewallet.txt https://raw.githubusercontent.com/moneroexamples/compile-monero-09-on-ubuntu-16-04/master/monerocommands_simplewallet.txt

# add aliases to .bashrc
echo "alias moneronode='rlwrap -f ~/.bitmonero/monerocommands_bitmonerod.txt /opt/monero/monerod'" >> ~/.bashrc
echo "alias monerowallet='rlwrap -f ~/.bitmonero/monerocommands_simplewallet.txt /opt/monero/monero-wallet-cli'" >> ~/.bashrc

# reload .bashrc
source ~/.bashrc

With this, we can just start the daemon and wallet simply using moneronode and monerowallet commands. rlwrap will provide tab-complition and history for the monero programs.

Example screenshot

Ubuntu Screeshot

Monero C++11 development (optional)

If you want to develop your own C++11 programs on top of Monero 0.9, Monero's static libraries and headers will be needed. Below is shown how they can be setup for use to write your own C++11 programs based on Monero. An example of such a program is access-blockchain-in-cpp.

Monero static libraries

When the compilation finishes, a number of static Monero libraries should be generated. We will need them to link against in our C++11 programs.

Since they are spread out over different subfolders of the ./build/ folder, it is easier to just copy them into one folder. I assume that /opt/monero-dev/libs is the folder where they are going to be copied to.

# create the folder
sudo mkdir -p /opt/monero-dev/libs

# find the static libraries files (i.e., those with extension of *.a)
# and copy them to /opt/monero-dev/libs
# assuming you are still in monero/ folder which you downloaded from
# github
sudo find ./build/ -name '*.a' -exec cp -v {} /opt/monero-dev/libs  \;

This should results in the following file structure:

/opt/monero-dev/libs/
├── libblockchain_db.a
├── libblocks.a
├── libcommon.a
├── libcrypto.a
├── libcryptonote_core.a
├── libcryptonote_protocol.a
├── libdaemonizer.a
├── libgtest.a
├── libgtest_main.a
├── liblmdb.a
├── libminiupnpc.a
├── libmnemonics.a
├── libotshell_utils.a
├── libp2p.a
├── libringct.a
├── librpc.a
└── libwallet.a

Monero headers

Now we need to get Monero headers, as this is our interface to the Monero libraries. Folder /opt/monero-dev/headers is assumed to hold the headers.

# create the folder
sudo mkdir -p /opt/monero-dev/headers

# find the header files (i.e., those with extension of *.h)
# and copy them to /opt/monero-dev/headers.
# but this time the structure of directories is important
# so rsync is used to find and copy the headers files
sudo rsync -zarv --include="*/" --include="*.h" --include="*.hpp" --exclude="*" --prune-empty-dirs ./ /opt/monero-dev/headers

This should results in the following file structure:

# ... only part shown to save some space
├── src
│   ├── blockchain_db
│   │   ├── berkeleydb
│   │   ├── blockchain_db.h
│   │   ├── db_types.h
│   │   └── lmdb
│   ├── blockchain_utilities
│   │   ├── blockchain_utilities.h
│   │   ├── blocksdat_file.h
│   │   ├── bootstrap_file.h
│   │   ├── bootstrap_serialization.h
│   │   └── fake_core.h
│   ├── blocks
│   │   └── blocks.h

Compilation and setup of libraries and header files in one command.

Add this to your .bashrc:

compilemonero() {

	local no_threads=1;

	[[ -n $1 ]] && no_threads=$1;

	echo "Compiling with $no_threads threads";

	make -j $no_threads;
	sudo mkdir -p /opt/monero/
	sudo mv -v ./build/release/bin/* /opt/monero/;
	sudo rm -rvf /opt/monero-dev/libs;
	sudo mkdir -p /opt/monero-dev/libs;
	sudo find ./build/ -name '*.a' -exec cp -v {} /opt/monero-dev/libs  \;
	sudo rm -rvf  -p /opt/monero-dev/headers
	sudo rsync -zarv --include="*/" --include="*.h" --include="*.hpp" --exclude="*" --prune-empty-dirs ./ /opt/monero-dev/headers;
}

and then, for example:

source .bashrc
cd monero
compilemonero 2 

Applying Monero pull requests

Often when working with development version of Monero, it is necessery to patch the source code with pull requests, for testing or to quickly fix something without waiting for when they get officially marged into master brunch. Doing this all the time manually can be time consuming. However, the following function can simply it. Just add it to your .bashrc

myapply() {
	curl -L https://github.com/monero-project/monero/pull/$1.patch | git apply -v -
}

And then, inside Monero folder, execte it as follows:

myapply 1689

where 1689 is example pull request number.

Other examples

Other examples can be found on github. Please know that some of the examples/repositories are not finished and may not work as intended.

How can you help?

Constructive criticism, code and website edits are always good. They can be made through github.

compile-monero-09-on-ubuntu-16-04's People

Contributors

cyclenerd avatar knoxcard avatar moneroexamples avatar ps88 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

compile-monero-09-on-ubuntu-16-04's Issues

Compile error

I've been following the tutorial on Ubuntu 16.04 but get this error:

make[3]: Entering directory '/root/monero/build/release'
make[3]: Leaving directory '/root/monero/build/release'
make[3]: Entering directory '/root/monero/build/release'
-- You are currently on commit 8d511f3
-- The most recent tag was at fda88c8
-- You are ahead of or behind a tagged release
make[3]: Leaving directory '/root/monero/build/release'
[  0%] Built target genversion
make[3]: Entering directory '/root/monero/build/release'
make[3]: Leaving directory '/root/monero/build/release'
[  2%] Built target lmdb
make[3]: Entering directory '/root/monero/build/release'
make[3]: Leaving directory '/root/monero/build/release'
[  4%] Built target easylogging
make[3]: Entering directory '/root/monero/build/release'
make[3]: Leaving directory '/root/monero/build/release'
[ 19%] Built target obj_cncrypto
make[3]: Entering directory '/root/monero/build/release'
make[3]: Leaving directory '/root/monero/build/release'
[ 20%] Built target cncrypto
make[3]: Entering directory '/root/monero/build/release'
make[3]: Leaving directory '/root/monero/build/release'
make[3]: Entering directory '/root/monero/build/release'
[ 21%] Building CXX object contrib/epee/src/CMakeFiles/epee.dir/http_auth.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
contrib/epee/src/CMakeFiles/epee.dir/build.make:86: recipe for target 'contrib/epee/src/CMakeFiles/epee.dir/http_auth.cpp.o' failed
make[3]: *** [contrib/epee/src/CMakeFiles/epee.dir/http_auth.cpp.o] Error 4
make[3]: Leaving directory '/root/monero/build/release'
CMakeFiles/Makefile2:340: recipe for target 'contrib/epee/src/CMakeFiles/epee.dir/all' failed
make[2]: *** [contrib/epee/src/CMakeFiles/epee.dir/all] Error 2
make[2]: Leaving directory '/root/monero/build/release'
Makefile:138: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/root/monero/build/release'
Makefile:55: recipe for target 'release' failed
make: *** [release] Error 2

This is the point where it fails. I've double checked if all dependencies are installed and all looks fine to me.

Coding while drunk: opps my bad

These are the two alias for a ton of commands that you are appending to ~/.bashrc

echo "alias moneronode='rlwrap -f ~/.bitmonero/monerocommands_simplewallet.txt /opt/bitmonero/bitmonerod'" >> ~/.bashrc

echo "alias monerowallet='rlwrap -f ~/.bitmonero/monerocommands_bitmonerod.txt /opt/bitmonero/simplewallet'" >> ~/.bashrc

Mixed up the bitmonerod.txt file with the simplewallet.txt file

Here is the fix you can just copy and paste it in

echo "alias moneronode='rlwrap -f ~/.bitmonero/monerocommands_bitmonerod.txt /opt/bitmonero/bitmonerod'" >> ~/.bashrc

echo "alias monerowallet='rlwrap -f ~/.bitmonero/monerocommands_simplewallet.txt /opt/bitmonero/simplewallet'" >> ~/.bashrc

Sorry if this is the coding equivalent of being a grammar troll. Everyone whose anyone would catch the mistake. Maybe it's just a fun joke and i'm being too serious

Build error Ubuntu 16.04

Build fails at

[ 96%] Linking CXX executable ../../bin/monerod
...
:(.text+0x7f92): undefined reference to `nOT::nUtils::gLoggerGuardDepth_Get()'
collect2: error: ld returned 1 exit status
src/daemon/CMakeFiles/daemon.dir/build.make:266: recipe for target 'bin/monerod' failed
make[3]: *** [bin/monerod] Error 1

All dependencies were installed with apt-gt. Building with 'make release'. Any idea whats causing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.