Compiling Bitcoin on Ubuntu 10.04 (Lucid)

August 19th, 2010 | Categories: Technology, Tutorials | Tags: , , , ,

In case you don’t know, Bitcoin is a decentralized crypto-currency or as the site says a “peer-to-peer network based digital currency”. While most people have been content to use the pre-compiled binaries available, some of us prefer to compile the client from source, for various reasons. Personally, I maintain a repository on github because I like using a number of patches that various programmers have put forth in the Bitcoin community. Whatever your reason for compiling from source, you have likely run into issues with compiling the graphical client since it requires the development version of wxWidgets. After a whole lot of failed attempts to compile the Bitcoin client I finally found a working configuration.

I have tested this process only on Ubuntu 10.04 (Lucid), both 64 and 32bit. From what I can tell earlier versions of Ubuntu and Debian should work just fine, but with a different set of packages. Specifically the “libboost-all-dev” package appears to only be available in Ubuntu 10.04, but the “libboost-dev” package may work for earlier versions and/or Debian.

First you need to install the proper packages:

sudo apt-get install build-essential libgtk2.0-dev libssl-dev libdb4.7-dev libdb4.7++-dev libboost-all-dev checkinstall subversion git-core

Next, you will need to download the 2.9 version of wxWidgets from their SourceForge project. I suggest creating a folder in your home directory called “src”, where we can compile wxWidgets and Bitcoin. Once the folder has been created we can download the 2.9 version of wxWidgets from their SourceForge project, and extract it. I’ve written out example steps below:

cd ~
mkdir src
cd src
wget "http://downloads.sourceforge.net/project/wxwindows/wxAll/2.9.0/wxWidgets-2.9.0.tar.gz?r=&ts=1282200132&mirror=surfnet"
tar -zxvf wxWidgets-2.9.0.tar.gz
cd wxWidgets-2.9.0/

Now that wxWidgets is extracted, you are ready to begin compiling it. First, create a build directory and change to it.

mkdir buildgtk
cd buildgtk

Now configure and build wxWidgets:

../configure --with-gtk --enable-debug --disable-shared --enable-monolithic
make

We could just run “sudo make install”, but that would put a bunch of wxWidget files all throughout your filesystem with no way to easily remove them. Luckily, the checkinstall program allows you to create a Debian package on the fly! This allows you to quickly and easily remove the files installed by wxWidgets. Let’s get started:

sudo checkinstall

You’ll probably be prompted to “create a default set of package docs”, just go ahead and hit enter. When it prompts you for the package description, just put “wxwidgets” without the quotes and hit enter twice. You should have a screen that looks like this:

*****************************************
**** Debian package creation selected ***
*****************************************
This package will be built according to these values:
0 -  Maintainer: [ root@ubuntu ]
1 -  Summary: [ wxwidgets ]
2 -  Name:    [ build ]
3 -  Version: [  ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ i386 ]
8 -  Source location: [ build ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ build ]
Enter a number to change any of them or press ENTER to continue:

Select “3″ for version, then put “2.9″ as the version number. Once you are back at the package creation menu, hit enter again to install wxWidgets and build the package. Once it’s done, you will need to run the following command:

sudo ldconfig

Now you are ready to download the Bitcoin source and compile the client! Change back to the “src” directory we created earlier:

cd ~/src

If you want to download the latest version of Bitcoin from the official subversion repository, run the following:

svn co https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk bitcoin-trunk

Optionally you can download the source code for a different version of the Bitcoin client, such as from my git repository (with various community patches I’ve added):

git clone git://github.com/aceat64/bitcoin-patchwork.git

Once the source code has been downloaded you will need to change to the directory of whichever version you picked. Once there you only need to run one command to compile the Bitcoin graphical client:

make -f makefile.unix bitcoin

If you want to compile the bitcoin daemon, the command is:

make -f makefile.unix bitcoind

If everything went well there will be a file called “bitcoin” in the current directory. I suggest copying the file to “/usr/local/bin” and making sure it’s owned as root with the permissions 755 so that no one but root can modify it.

If this article helped you out, please send some Bitcoins to the Bitcoin Faucet and help spread the word about Bitcoin.

  1. memento
    October 3rd, 2010 at 13:12
    Reply | Quote | #1

    Hello !

    I precisely followed your tutorial and finnally got this error wile launching bitcoin bin :

    “An assertion failed !

    ../src/gtk/settings.cpp(276): assert “font.IsOk() && wxFontEnumerator::IsValidFacename(font.GetFaceName())” failed in GetFont().”

    I’ve got quite the same from the console :
    “19:51:51: Debug: ../src/gtk/settings.cpp(276): assert “font.IsOk() && wxFontEnumerator::IsValidFacename(font.GetFaceName())” failed in GetFont().”

    Apparently, this comes from the “wxWidgets-2.9.0/src/gtk” source.

    Ok, I know debugging is not what you intended to do while writting this tuto, but I’m quite stuck right now.

    I must say too that I got the same mistake with the official compiling&executing from the official source.

    Greetings from France.
    Hope you could help me.
    I really believe in this project !

  2. kevin@ecu
    October 12th, 2010 at 12:50
    Reply | Quote | #2

    Thanks bro, works like a charm

  3. h
    May 21st, 2011 at 06:32
    Reply | Quote | #3

    h@ubuntu:~/src/bitcoin-trunk$ make -f makefile.unix bitcoin
    make: wx-config: Command not found
    g++ -c -O2 -Wno-invalid-offsetof -Wformat -g -D__WXDEBUG__ -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -DUSE_UPNP=0 -DGUI -o obj/util.o util.cpp
    In file included from util.cpp:5:0:
    headers.h:30:19: fatal error: wx/wx.h: No such file or directory
    compilation terminated.
    make: *** [obj/util.o] Error 1

  4. May 22nd, 2011 at 01:20
    Reply | Quote | #4

    @h
    This guide is probably outdated now but your error seems to indicate that wxwidgets either isn’t installed or isn’t in your path.

  5. watchpocket
    May 22nd, 2011 at 21:55
    Reply | Quote | #5

    FYI: Ubuntu 10.04 is Lucid Lynx.
    Ubuntu 9.10 is Karmic Koala.

    I’m still running the real Karmic — v. 9.10. Will this tutorial work for Ubuntu version 9.10? For 64-bit 9.10?

  6. May 22nd, 2011 at 23:19
    Reply | Quote | #6

    @watchpocket
    Good catch, I’ve fixed the post to say Lucid. I haven’t tried it, but it should work on 9.10 as well.

  7. watchpocket
    May 23rd, 2011 at 00:41
    Reply | Quote | #7

    Everything was going beautifully until the end, when did not have a file “bitcoin” in the ~/src/bitcoin-patchwork directory, and when I got this:

    /usr/bin/ld: cannot find -lboost_system
    collect2: ld returned 1 exit status
    make: *** [bitcoin] Error 1
    make -f makefile.unix bitcoin 84.83s user 4.22s system 98% cpu 1:30.26 total

    I’m running Ubuntu 9.10, 64-bit. I installed libboost-dev. After seeing the error message above, I tried to install libboost-all-dev, and got this:

    “E: Couldn’t find package libboost-all-dev”

    I then tried to install libboost-dev again, got this:

    “libboost-dev is already the newest version.”

    So: my problem appears to be that

    “/usr/bin/ld: cannot find -lboost_system”

    and I frankly have no clue what to do about that.

    I did see this post on the Bitcoin forum, but I don’t really know what it means for me, or what I might do about it.

    “Title: Re: 0.3 almost ready
    Post by: satoshi on June 24, 2010, 05:40:05 pm
    Here’s RC1 for linux for testing:
    (link removed, see below)

    It contains both 32-bit and 64-bit binaries.

    Recent changes:

    build-unix.txt:
    - Added instructions for building wxBase, which is needed to compile bitcoind.
    - The package libboost-dev doesn’t install anything anymore, you need to get libboost-all-dev.
    - Updated version numbers.

    makefile.unix:
    - The libboost libraries have removed the “-mt” from their filenames in 1.40. If you’re compiling with Boost 1.38 or lower, like on Ubuntu Karmic, you would need to change it back to boost_system-mt and boost_filesystem-mt.”

    But exactly where & how would I add the “-mt”?

    I did see this at the end of a huge bunch of stuff thrown onto my screen:

    “. . . -Bstatic -l boost_system -l boost_filesystem -l boost_program_options -l boost_thread -l db_cxx -l crypto -Wl,-Bdynamic -l gthread-2.0
    /usr/bin/ld: cannot find -lboost_system
    collect2: ld returned 1 exit status
    make: *** [bitcoin] Error 1″

    [The latter part being a repeat of what I quoted above.]

    I get the feeling I’m an inch away from successful installation, & hoping some clues are provided for anyone who can parse them & make a suggestion.

    Thanks,
    watchpocket

  8. watchpocket
    May 23rd, 2011 at 00:45
    Reply | Quote | #8

    Thanks, by the way, for this detailed tutorial as it is. I never expected it to even go as well as it did for me. Now if I can only somehow resolve the libboost catch-22. . . .

    Thanks again, great help to have this. I tried last week w the PPA & got nowhere within a few seconds.

  9. watchpocket
    May 23rd, 2011 at 00:58
    Reply | Quote | #9

    Btw I did not get to the command:

    “make -f makefile.unix bitcoind”

    The error message I got came at the end of running
    “make -f makefile.unix bitcoin”

    Looking now to see if I already have the Boost program anywhere in the src dir or wxWidgets-2.9.0 subdir or the bitcoin-patchwork subdir, and if I do, what version it might be.

    Or does the error message mean the Boost program itself was not installed? There’s got to be a way. . . .

  10. watchpocket
    May 23rd, 2011 at 01:32

    I definitely have Boost v. 1.38. I just don’t know how to “change it back to boost_system-mt and boost_filesystem-mt.”

  11. watchpocket
    May 23rd, 2011 at 02:43

    Btw you should also change “karmic” to “lucid” in your URL.

  12. watchpocket
    May 24th, 2011 at 01:04

    Got it up & running, thanks. I just went into makefile.unix and added the “-mt” onto the four boost libs.

  13. eriz
    August 1st, 2011 at 13:12

    Hi!

    I’ve followed the guide, but it seems like it’s not up to date anymore with trunk.

    After installing everything, I get this:
    eriz@eriz-laptop:~/Development/bitcoin/src$ make -f makefile.unix
    g++ -c -O2 -Wno-invalid-offsetof -Wformat -g -D__WXDEBUG__ -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -DUSE_UPNP=0 -I/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -D__WXDEBUG__ -D__WXGTK__ -pthread -DGUI -o obj/util.o util.cpp
    g++ -c -O2 -Wno-invalid-offsetof -Wformat -g -D__WXDEBUG__ -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -DUSE_UPNP=0 -I/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -D__WXDEBUG__ -D__WXGTK__ -pthread -DGUI -o obj/script.o script.cpp
    g++ -c -O2 -Wno-invalid-offsetof -Wformat -g -D__WXDEBUG__ -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -DUSE_UPNP=0 -I/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -D__WXDEBUG__ -D__WXGTK__ -pthread -DGUI -o obj/db.o db.cpp
    g++ -c -O2 -Wno-invalid-offsetof -Wformat -g -D__WXDEBUG__ -DNOPCH -DFOURWAYSSE2 -DUSE_SSL -DUSE_UPNP=0 -I/usr/local/lib/wx/include/gtk2-unicode-debug-static-2.9 -I/usr/local/include/wx-2.9 -D_FILE_OFFSET_BITS=64 -D__WXDEBUG__ -D__WXGTK__ -pthread -DGUI -o obj/net.o net.cpp
    net.cpp:22:32: error: miniupnpc/miniwget.h: No such file or directory
    net.cpp:23:33: error: miniupnpc/miniupnpc.h: No such file or directory
    net.cpp:24:36: error: miniupnpc/upnpcommands.h: No such file or directory
    net.cpp:25:34: error: miniupnpc/upnperrors.h: No such file or directory
    net.cpp: In function ‘void ThreadMapPort2(void*)’:
    net.cpp:1084: error: ‘upnpDiscover’ was not declared in this scope
    net.cpp:1086: error: aggregate ‘UPNPUrls urls’ has incomplete type and cannot be defined
    net.cpp:1087: error: aggregate ‘IGDdatas data’ has incomplete type and cannot be defined
    net.cpp:1090: error: ‘UPNP_GetValidIGD’ was not declared in this scope
    net.cpp:1098: error: ‘UPNP_AddPortMapping’ was not declared in this scope
    net.cpp:1103: error: ‘UPNPCOMMAND_SUCCESS’ was not declared in this scope
    net.cpp:1105: error: ‘strupnperror’ was not declared in this scope
    net.cpp:1111: error: ‘UPNP_DeletePortMapping’ was not declared in this scope
    net.cpp:1113: error: ‘freeUPNPDevlist’ was not declared in this scope
    net.cpp:1114: error: ‘FreeUPNPUrls’ was not declared in this scope
    net.cpp:1121: error: ‘freeUPNPDevlist’ was not declared in this scope
    net.cpp:1123: error: ‘FreeUPNPUrls’ was not declared in this scope
    make: *** [obj/net.o] Error 1

  14. Jader
    September 3rd, 2011 at 13:19

    In Natty, when I sudo checkinstall, after changing the version and hitting enter it doesn’t build the package because of

    /usr/bin/install -c -d /usr/local/lib/wx/config
    /usr/bin/install: cannot create directory `/usr/local/lib/wx’: No such file or directory
    make: *** [install-wxconfig] Error 1

    **** Installation failed. Aborting package creation.

    Cleaning up…OK

    Bye.