How do I build Bitcoin from source in Linux? 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.
Basically, you do this:


Download the distribution tarball or repository. You can use the link on the project's GitHub page.
If you used the distribution tarball, unpack it.
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.
Make a copy of the supplied UNIX makefile (called makefile.unix) and call it Makefile.
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).
Type 'make' and hope for the best.
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.)