I am running an Ubuntu Virtualbox, how do I build Bitcoin from source and run it in this environment?

I'm using the build notes from the bitcoin core github and I get the following errors when trying to do make -f makefile.unix bitcoind:

net.cpp:48:15: error: 'pnodeLocalHost' was declared 'extern' and later 'static'
net.h:476:15: error: previous declaration of 'pnodeLocalHost'
net.cpp:51:15: error: 'hListenSocket' was declared 'extern' and later 'static'
net.h:479:15: error: previous declaration of 'hListenSocket'
make: *** [obj/nogui/net.o] Error 1

Any recommendation for how to fix this?

I tried commenting out those lines of code in net.h and now I'm getting:

db.cpp:534: undefined reference to 'AddAddress(CAddress, long long)'
net.cpp:1363: undefined reference to 'AddAddress(CAddress, long long)'
main.cpp:1914: undefined reference to 'AddAddress(CAddress, long long)'
init.cpp:493:  undefined reference to 'AddAddress(CAddress, long long)'

could this be an issue with the libraries I've installed? I followed the doc pretty much verbatim.


1 Answer 1


Basically, you do this:

  1. Download the distribution tarball or repository. You can use the link on the project's GitHub page.

  2. If you used the distribution tarball, unpack it.

  3. Obtain any needed prerequisites. Things you may need include the development packages or source builds of: OpenSSL, Boost, libZ, GLib2, and BerkeleyDB. You should be able to use your distribution's development packages for everything with the possible exception of OpenSSL. I don't know offhand if Ubuntu ships a version that will work with the Bitcoin client (including ECDSA support). If not, rebuild OpenSSL from the source with default options.

  4. Make a copy of the supplied UNIX makefile (called makefile.unix) and call it Makefile.

  5. Adjust the Makefile you created as needed. You may need to: Add include/library paths for the prerequisites if they're not in the usual places. Localize the name of the BerkeleyDB distribution, for example 'db_cxx-5.1' instead of 'db_cxx'. Localize the name of some Boost libraries (on some distributions, most will need '-mt' added to the end).

  6. Type 'make' and hope for the best.

  7. If it didn't work, figure out why and fix it.

One caution: If two builds of the Bitcoin client are linked against different versions of the BerkeleyDB package, they may not be able to read each other's database files (including the wallet.dat file). There is a process to convert the files (dump to text on one version, build from text on another) but it's cumbersome and perilous.

Update: To your two specific issues, the fix is to remove (or comment out) lines 476 and 479 in the net.h file, the extern declarations of pnodeLocalHost and hListenSocket. (Be careful, when you remove one, the line number of the other may change. Identify both changes before you make either.)

  • I'm using virtualbox to build test environments for commits - so no concern about two clients (yet) - thanks for the heads up and info! Sep 2, 2011 at 9:00
  • I had this exact same problem building on Debian 6 "squeeze" and solved it using the exact procedure listed in Mr. Schwartz's update. I haven't tested in any other Linux - is this process specific to Debian-based distros or am I likely to see the problem follow me to Fedora, Arch etc.? Sep 2, 2011 at 15:36
  • I don't know. The removal of those two lines fixes a genuine mistake in the client source. I'm not sure why it sometimes causes a build error and sometimes doesn't though. Frankly, it seems like it should always cause a fatal error. Sep 3, 2011 at 1:39
  • If you're on Debian or Ubuntu, I wrote a script that will install all of the dependencies. Link
    – Nick ODell
    Sep 11, 2014 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.