Difference between revisions of "Compiling instructions"

From Bitmessage Wiki
Jump to navigation Jump to search
(Education, Training, learn,)
m (Typo)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
C Programming Training
+
This page should help novice users run Bitmessage from the source code files.
  
C is a programming language developed at “AT & T’s Bell Laboratories” of USA in 1972 and it was developed by  Dennis Ritchie. Aim of the c language to design the UNIX operating system (which is used on many computers).  C is a powerful programming language than other programming language. C Language spread beyond Bell Labs in very short period. In the late 1970′s C began to replace widespread well-known languages of that time like PL/I, ALGOL etc. Programmers began use C to write all sorts of programs. many organizations began applying their own versions of C with a subtle difference. This was  a serious problem for system developers. To solve this issue, the ANSI (American National Standards Institute) formed a committee in 1983 to establish a standard definition of C. ANSI  approved a version of C in 1989, which is known as ANSI C. With few suggestions, modern C compiler has the ability to adhere to this standard. ANSI C was then approved in 1990 by the  ISO (International Standards Organization) .
+
= setuptools =
  
C Language is named as C , why not something else. C language is so named  because its predecessor Language was called B and  The B programming language was developed by Ken Thompson of Bell Labs.
+
This is now the '''recommended''' and in most cases the easiest procedure for installing PyBitmessage. There is also a helper script to resolve dependencies easily.
  
Now a day’s world of computer programming, there are many high-level languages to choose from, such as Pascal, BASIC, and Java. But C different from all these languages. This is due to its many desirable features. C is a robust language. C have rich set of built-in functions and operators can be used to write any complex logic program. The C language compiler have capabilities of combining low-level language with the features of a high-level language. Therefore, C Language is suitable for writing both system software as well as business packages & other software. Many compilers available in the market written in C Language
+
Go to the directory with PyBitmessage source code and run:
  
Advantages of C Language
+
  python checkdeps.py
  
• Program written in c is very efficient and fast. This is due to variety of data types and powerful operators. C program execution is  many time faster than BASIC. This helps developers to save their valuable time.
+
If there are missing dependencies, it will explain you what is missing and for many Unix-like systems also what you have to do to resolve it. How you then run setuptools depends on whether you want to install it to user's directory or system.
  
• C is a more powerful and flexible language, which helps system developers to deliver complex tasks with ease. C also used for device driver programs for new device , word processors, graphics, spreadsheets, and even compilers for other languages.
+
As normal user:
  
• C is popular among professional and system programmers for programming, as a result, a wide variety of C compilers and helpful accessories are available.
+
  python setup.py install --user
 +
  ~/.local/bin/pybitmessage
  
• C Language is highly portable . This means that a C program written for one computer system (an IBM PC) can be run on another system (a DEC VAX system, perhaps) with little or no modification.
+
or as root:
  
• C’s another striking feature is its ability to extend itself. A C program is a collection of various function supported by C library ( header files). We can also create own function and add to C Library These library functions can be reused in other applications by passing pieces of information to the functions, you can create useful, reusable code.
+
  python setup.py install
 +
  /usr/local/bin/pybitmessage
  
• Writing C program with user-defined functions(UDF) makes program more simple and easy to understand. Breaking a problem in terms of  program debugging, maintenance and testing easier.
+
If it doesn't work out, you can follow the more detailed description below.
http://www.educorporatebridge.com/technology/c-programming-training/
+
 
 +
= Linux =
 +
 
 +
== Resolve dependencies ==
 +
{| class="wikitable" border="1" width="80%"
 +
|-
 +
! Distribuion
 +
! Instructions
 +
|-
 +
! scope="row"| Debian-based
 +
(Ubuntu, Raspbian, PiBang, others)
 +
| <small>''Note for Debian Squeeze (6.0) users: Debian Squeeze does not offer packages (like Python, OpenSSL) in versions that are needed for Bitmessage. You can still try to [https://github.com/Bitmessage/PyBitmessage/issues/47#issuecomment-17774377 work around these problems]. Debian 7 "wheezy" works without problems.''</small>
 +
  sudo apt-get install python openssl libssl-dev git python-msgpack python-qt4
 +
|-
 +
! scope="row"| Arch Linux
 +
|
 +
  sudo pacman -S python2 openssl git python2-pyqt4
 +
|-
 +
! scope="row"| Fedora
 +
| <small>''Fedora and RHEL6 do not support EC in OpenSSL. Therefore we need [http://linux.ringingliberty.com/bitcoin/ Ringing Liberty's bitcoin repository] to get a compatible library.''
 +
</small>
 +
  su -c 'yum install -y http://linux.ringingliberty.com/bitcoin/f18/x86_64/bitcoin-release-1-4.noarch.rpm'
 +
  su -c 'yum install -y python python-qt4 git openssl-compat-bitcoin-libs'
 +
 
 +
Tell your system where to look for the library:
 +
  echo 'LD_LIBRARY_PATH="/opt/openssl-compat-bitcoin/lib/"' >> ~/.bashrc && source ~/.bashrc
 +
Note for Fedora 20 users: Due to inconsistent behavior encountered by declaring the above variable globally, the following "wrapper script" will declare the LD_LIBRARY_PATH variable correctly and only when running bitmessage.  Name the script something like "bitmessage", mark it as executable (probably something like 755) and put it in /usr/bin so it's accessible without the full path.
 +
  export LD_LIBRARY_PATH="/opt/openssl-compat-bitcoin/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
 +
  /home/<yourusername>/PyBitmessage/src/bitmessagemain.py > /dev/null 2>&1 &
 +
|-
 +
! scope="row"| Red Hat Enterprise Linux (RHEL)
 +
| <small>''Fedora and RHEL6 do not support EC in OpenSSL. Therefore we need [http://linux.ringingliberty.com/bitcoin/ Ringing Liberty's bitcoin repository] to get a compatible library.''
 +
</small>
 +
  su -c 'yum install -y http://linux.ringingliberty.com/bitcoin/el6/x86_64/bitcoin-release-1-4.noarch.rpm'
 +
  su -c 'yum install -y python python-qt4 git openssl-compat-bitcoin-libs'
 +
Tell your system where to look for the library:
 +
  echo 'LD_LIBRARY_PATH="/opt/openssl-compat-bitcoin/lib/"' >> ~/.bashrc && source ~/.bashrc
 +
|-
 +
! scope="row"| GNU Guix
 +
|
 +
  guix package -i python2-msgpack python2-pyqt@4.11.4 python2-sip openssl
 +
 
 +
For the C PoW in addition
 +
 
 +
  guix package -i gcc binutils make linux-libre-headers gcc-toolchain
 +
 
 +
For the OpenCL PoW in addition to both of the above, and drivers for your GPU:
 +
 
 +
  guix package -i libffi;pip2 install pyopencl
 +
|}
 +
 
 +
== Download and run PyBitmessage ==
 +
# Download the source code from github:<br /><code>git clone <nowiki>https://github.com/Bitmessage/PyBitmessage $HOME/PyBitmessage</nowiki></code>
 +
# Run PyBitmessage:<br /><code>~/PyBitmessage/src/bitmessagemain.py</code>
 +
Check the wiki for more information on how to run Bitmessage [https://bitmessage.org/wiki/Daemon as a daemon].
 +
 
 +
<small>If you receive a warning that you need to use python 2.7.3 or greater, and have followed the above instructions to upgrade it, your system may be attemping to run PyBitmessage with python 3. In this case, run <code>python2 ~/PyBitmessage/src/bitmessagemain.py</code></small>
 +
 
 +
== Upgrading ==
 +
To upgrade Bitmessage run the following commands:
 +
:<code>cd $HOME/PyBitmessage</code>
 +
:<code>git pull</code>
 +
 
 +
= OS X =
 +
== With Homebrew package manager ==
 +
; Setup
 +
First, make sure you have not already installed Macports. Having both macports and homebrew on the same system is a recipe for disaster.
 +
Install Homebrew:
 +
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
 +
 
 +
; Update Python:
 +
brew install python
 +
 
 +
; Install dependencies:
 +
brew install pyqt openssl
 +
 
 +
; Download and run
 +
cd ~/Desktop
 +
git clone git://github.com/Bitmessage/PyBitmessage.git
 +
cd PyBitmessage
 +
python src/bitmessagemain.py
 +
 
 +
== With macports package manager ==
 +
First, make sure you have not already installed Homebrew. Having both macports and homebrew on the same system is a recipe for disaster.
 +
Installing with macports or homebrew essentially has the same effect. Homebrew does some things better than ports, and ports does some things better than brew. If old-school floats your boat, these instructions are for you.
 +
 
 +
; Select the macports installation that is right for your version of osx
 +
Read the instructions or take this as a reminder: Apple's XCode and their Command Line Tools are a prerequiste for Macports, go: https://www.macports.org/install.php
 +
 
 +
; Install dependencies and needed tools
 +
sudo port install python27 py27-pyqt4 openssl
 +
sudo port install git-core +svn +doc +bash_completion +gitweb
 +
 
 +
; Download and run
 +
cd ~/Desktop
 +
git clone git://github.com/Bitmessage/PyBitmessage.git
 +
cd PyBitmessage
 +
python2.7 src/bitmessagemain.py
 +
 
 +
= Windows =
 +
# Download and install the latest revision of Python 2.7 (currently Python 2.7.10 from [https://www.python.org/downloads/ here]). The ''Windows x86 MSI Installer'' is the right choice for most people. (64-bit users may want the 64-bit version).
 +
## Test that it installed:
 +
### Open a command prompt by going to Start > Run. Type 'cmd' then press enter.
 +
### type 'python'. If python is installed, you should see the python version and the prompt: '>>>'
 +
### If you see a message such as: "'Python is not recognized as an internal or external command..." then you must add the python path to your path environmental variable:
 +
#### Find the location where Python was installed (in particular, the location where python.exe exists). It might simply be in c:\Python2.7
 +
#### Follow [http://www.computerhope.com/issues/ch000549.htm these directions] to add the Python path to your path variable.
 +
#### Close the command prompt window and reopen it.
 +
### Try running 'python' again.
 +
###Press Ctrl-Z to exit Python.
 +
# Download PyQt from [http://www.riverbankcomputing.com/software/pyqt/download here].  ''PyQt is one of Bitmessage's two dependencies.'' Look for the links to downloads under the heading labeled "Binary Package;" the binary package versions are already compiled for you. Select the version for Python 2.7 (look for "Py2.7" in the file name). Install PyQt.
 +
# Download OpenSSL from [http://slproweb.com/products/Win32OpenSSL.html here]. ''OpenSSL is the second of Bitmessage's two dependencies.''  Install OpenSSL.  If an error message appears during installation of OpenSSL, download and install Visual C++ 2008.  A link is provided on the OpenSSL download page.
 +
# Download the source code for PyBitmessage from GitHub. If it is in a zip file, you will need to extract it. There should be a few files and a few folders where one of the folders is 'src'.
 +
# To run Bitmessage, navigate into the 'src' folder and then double click on the bitmessagemain.py file, or in a command prompt, change directories to the 'src' directory which holds bitmessagemain.py and type 'python bitmessagemain.py'.
 +
 
 +
== If you change user interface files ==
 +
You can use Qt's Designer application to modify the user interface. After you do this, you will need to 'compile' .ui files into .py files.
 +
# In a command prompt, change directories to the directory of your .ui file.
 +
# Run 'pyuic4 example.ui > example.py' If you get a message similar to 'pyuic4 is not recognized as an internal or external command' then you must add the PyQt directory to your system's path variable. This directory should hold pyuic4.bat. It might be in C:\Python27\Lib\site-packages\PyQt4. Remember to close the command window and reopen it after you change your path variable.
 +
 
 +
If you add icons to bitmessage_icons.qrc, then you must run this command:
 +
pyrcc4 bitmessage_icons.qrc -o bitmessage_icons_rc.py
 +
 
 +
== Optional: Compile into a stand-alone EXE ==
 +
# Download and install PyWin32
 +
# Download [http://www.pyinstaller.org/ PyInstaller].
 +
# Copy Bitmessage's 'src' directory to the PyInstaller directory (which contains pyinstaller.py).
 +
# Run 'pyinstaller.py --onefile --noconsole --icon="src\images\can-icon.ico" src\bitmessagemain.py'
 +
This won't include the OpenSSL DLL file in the EXE; if you send it to someone who doesn't have OpenSSL installed, it will not run. To include the DLL file in the EXE, you must follow these steps:
 +
# After following the steps above, you will see that pyinstaller created a folder called bitmessagemain. In that folder is a file: bitmessagemain.spec. Open it with a text editor.
 +
# Below the line "a.datas," add this line: <code>a.binaries + [('libeay32.dll', 'c:\\windows\\system32\\libeay32.dll', 'BINARY')],</code>
 +
# Optionally also include the translations by modifying this file further by adding the lines shown in [[Example_pyinstaller_spec_file|this]] example file.
 +
# Save and close
 +
# Run this command: pyinstaller.py bitmessagemain/bitmessagemain.spec
 +
 
 +
If you do not have the libeay32.dll you can download it here. http://www.dll-files.com/dllindex/dll-files.shtml?libeay32

Latest revision as of 05:47, 27 December 2017

This page should help novice users run Bitmessage from the source code files.

setuptools

This is now the recommended and in most cases the easiest procedure for installing PyBitmessage. There is also a helper script to resolve dependencies easily.

Go to the directory with PyBitmessage source code and run:

 python checkdeps.py

If there are missing dependencies, it will explain you what is missing and for many Unix-like systems also what you have to do to resolve it. How you then run setuptools depends on whether you want to install it to user's directory or system.

As normal user:

 python setup.py install --user
 ~/.local/bin/pybitmessage

or as root:

 python setup.py install
 /usr/local/bin/pybitmessage

If it doesn't work out, you can follow the more detailed description below.

Linux

Resolve dependencies

Distribuion Instructions
Debian-based

(Ubuntu, Raspbian, PiBang, others)

Note for Debian Squeeze (6.0) users: Debian Squeeze does not offer packages (like Python, OpenSSL) in versions that are needed for Bitmessage. You can still try to work around these problems. Debian 7 "wheezy" works without problems.
 sudo apt-get install python openssl libssl-dev git python-msgpack python-qt4
Arch Linux
 sudo pacman -S python2 openssl git python2-pyqt4
Fedora Fedora and RHEL6 do not support EC in OpenSSL. Therefore we need Ringing Liberty's bitcoin repository to get a compatible library.

 su -c 'yum install -y http://linux.ringingliberty.com/bitcoin/f18/x86_64/bitcoin-release-1-4.noarch.rpm'
 su -c 'yum install -y python python-qt4 git openssl-compat-bitcoin-libs'

Tell your system where to look for the library:

 echo 'LD_LIBRARY_PATH="/opt/openssl-compat-bitcoin/lib/"' >> ~/.bashrc && source ~/.bashrc

Note for Fedora 20 users: Due to inconsistent behavior encountered by declaring the above variable globally, the following "wrapper script" will declare the LD_LIBRARY_PATH variable correctly and only when running bitmessage. Name the script something like "bitmessage", mark it as executable (probably something like 755) and put it in /usr/bin so it's accessible without the full path.

 export LD_LIBRARY_PATH="/opt/openssl-compat-bitcoin/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
 /home/<yourusername>/PyBitmessage/src/bitmessagemain.py > /dev/null 2>&1 &
Red Hat Enterprise Linux (RHEL) Fedora and RHEL6 do not support EC in OpenSSL. Therefore we need Ringing Liberty's bitcoin repository to get a compatible library.

 su -c 'yum install -y http://linux.ringingliberty.com/bitcoin/el6/x86_64/bitcoin-release-1-4.noarch.rpm'
 su -c 'yum install -y python python-qt4 git openssl-compat-bitcoin-libs'

Tell your system where to look for the library:

 echo 'LD_LIBRARY_PATH="/opt/openssl-compat-bitcoin/lib/"' >> ~/.bashrc && source ~/.bashrc
GNU Guix
 guix package -i python2-msgpack python2-pyqt@4.11.4 python2-sip openssl

For the C PoW in addition

 guix package -i gcc binutils make linux-libre-headers gcc-toolchain

For the OpenCL PoW in addition to both of the above, and drivers for your GPU:

 guix package -i libffi;pip2 install pyopencl

Download and run PyBitmessage

  1. Download the source code from github:
    git clone https://github.com/Bitmessage/PyBitmessage $HOME/PyBitmessage
  2. Run PyBitmessage:
    ~/PyBitmessage/src/bitmessagemain.py

Check the wiki for more information on how to run Bitmessage as a daemon.

If you receive a warning that you need to use python 2.7.3 or greater, and have followed the above instructions to upgrade it, your system may be attemping to run PyBitmessage with python 3. In this case, run python2 ~/PyBitmessage/src/bitmessagemain.py

Upgrading

To upgrade Bitmessage run the following commands:

cd $HOME/PyBitmessage
git pull

OS X

With Homebrew package manager

Setup

First, make sure you have not already installed Macports. Having both macports and homebrew on the same system is a recipe for disaster. Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Update Python
brew install python
Install dependencies
brew install pyqt openssl
Download and run
cd ~/Desktop
git clone git://github.com/Bitmessage/PyBitmessage.git
cd PyBitmessage
python src/bitmessagemain.py

With macports package manager

First, make sure you have not already installed Homebrew. Having both macports and homebrew on the same system is a recipe for disaster. Installing with macports or homebrew essentially has the same effect. Homebrew does some things better than ports, and ports does some things better than brew. If old-school floats your boat, these instructions are for you.

Select the macports installation that is right for your version of osx

Read the instructions or take this as a reminder: Apple's XCode and their Command Line Tools are a prerequiste for Macports, go: https://www.macports.org/install.php

Install dependencies and needed tools
sudo port install python27 py27-pyqt4 openssl
sudo port install git-core +svn +doc +bash_completion +gitweb
Download and run
cd ~/Desktop
git clone git://github.com/Bitmessage/PyBitmessage.git
cd PyBitmessage
python2.7 src/bitmessagemain.py

Windows

  1. Download and install the latest revision of Python 2.7 (currently Python 2.7.10 from here). The Windows x86 MSI Installer is the right choice for most people. (64-bit users may want the 64-bit version).
    1. Test that it installed:
      1. Open a command prompt by going to Start > Run. Type 'cmd' then press enter.
      2. type 'python'. If python is installed, you should see the python version and the prompt: '>>>'
      3. If you see a message such as: "'Python is not recognized as an internal or external command..." then you must add the python path to your path environmental variable:
        1. Find the location where Python was installed (in particular, the location where python.exe exists). It might simply be in c:\Python2.7
        2. Follow these directions to add the Python path to your path variable.
        3. Close the command prompt window and reopen it.
      4. Try running 'python' again.
      5. Press Ctrl-Z to exit Python.
  2. Download PyQt from here. PyQt is one of Bitmessage's two dependencies. Look for the links to downloads under the heading labeled "Binary Package;" the binary package versions are already compiled for you. Select the version for Python 2.7 (look for "Py2.7" in the file name). Install PyQt.
  3. Download OpenSSL from here. OpenSSL is the second of Bitmessage's two dependencies. Install OpenSSL. If an error message appears during installation of OpenSSL, download and install Visual C++ 2008. A link is provided on the OpenSSL download page.
  4. Download the source code for PyBitmessage from GitHub. If it is in a zip file, you will need to extract it. There should be a few files and a few folders where one of the folders is 'src'.
  5. To run Bitmessage, navigate into the 'src' folder and then double click on the bitmessagemain.py file, or in a command prompt, change directories to the 'src' directory which holds bitmessagemain.py and type 'python bitmessagemain.py'.

If you change user interface files

You can use Qt's Designer application to modify the user interface. After you do this, you will need to 'compile' .ui files into .py files.

  1. In a command prompt, change directories to the directory of your .ui file.
  2. Run 'pyuic4 example.ui > example.py' If you get a message similar to 'pyuic4 is not recognized as an internal or external command' then you must add the PyQt directory to your system's path variable. This directory should hold pyuic4.bat. It might be in C:\Python27\Lib\site-packages\PyQt4. Remember to close the command window and reopen it after you change your path variable.

If you add icons to bitmessage_icons.qrc, then you must run this command: pyrcc4 bitmessage_icons.qrc -o bitmessage_icons_rc.py

Optional: Compile into a stand-alone EXE

  1. Download and install PyWin32
  2. Download PyInstaller.
  3. Copy Bitmessage's 'src' directory to the PyInstaller directory (which contains pyinstaller.py).
  4. Run 'pyinstaller.py --onefile --noconsole --icon="src\images\can-icon.ico" src\bitmessagemain.py'

This won't include the OpenSSL DLL file in the EXE; if you send it to someone who doesn't have OpenSSL installed, it will not run. To include the DLL file in the EXE, you must follow these steps:

  1. After following the steps above, you will see that pyinstaller created a folder called bitmessagemain. In that folder is a file: bitmessagemain.spec. Open it with a text editor.
  2. Below the line "a.datas," add this line: a.binaries + [('libeay32.dll', 'c:\\windows\\system32\\libeay32.dll', 'BINARY')],
  3. Optionally also include the translations by modifying this file further by adding the lines shown in this example file.
  4. Save and close
  5. Run this command: pyinstaller.py bitmessagemain/bitmessagemain.spec

If you do not have the libeay32.dll you can download it here. http://www.dll-files.com/dllindex/dll-files.shtml?libeay32