<p>Basically, you do this:</p>

<ol>
<li><p>Download the distribution tarball or repository. You can use the link on the project's <a href="https://github.com/bitcoin/bitcoin" rel="nofollow">GitHub</a> page.</p></li>
<li><p>If you used the distribution tarball, unpack it.</p></li>
<li><p>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.</p></li>
<li><p>Make a copy of the supplied UNIX makefile (called <code>makefile.unix</code>) and call it <code>Makefile</code>.</p></li>
<li><p>Adjust the <code>Makefile</code> 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).</p></li>
<li><p>Type 'make' and hope for the best.</p></li>
<li><p>If it didn't work, figure out why and fix it.</p></li>
</ol>

<p>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 <code>wallet.dat</code> 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.</p>

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

CC BY-SA 3.0
2014-09-11T03:45:08.380Z
If you're on Debian or Ubuntu, I wrote a script that will install all of the dependencies. [Link](https://github.com/nickodell/build_bitcoin/)
Nick ODell
CC BY-SA 3.0
2011-09-02T09:00:13.493Z
I'm using virtualbox to build test environments for commits - so no concern about two clients (yet) - thanks for the heads up and info!
Alex Waters
CC BY-SA 3.0
2011-09-02T15:36:49.007Z
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.?
David Perry
CC BY-SA 3.0
2011-09-03T01:39:50.697Z
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.
David Schwartz
CC BY-SA 3.0
2011-09-02T07:21:24.937Z
2011-09-02T09:31:54.413Z
2011-09-02T09:31:54.413Z
David Schwartz
<p>I am running an Ubuntu Virtualbox, how do I build Bitcoin from source and run it in this environment?</p>

<p>I'm using the <a href="https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.txt#LNaN">build notes</a> from the bitcoin core github and I get the following errors when trying to do <code>make -f makefile.unix bitcoind</code>:</p>

<pre><code>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
</code></pre>

<p>Any recommendation for how to fix this?</p>

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

<pre><code>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)'
</code></pre>

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

CC BY-SA 3.0
2011-09-02T13:52:41.207Z
I have added the issue to the github issue tracker: https://github.com/bitcoin/bitcoin/issues/485
Alex Waters
<ubuntu>
How do I build Bitcoin from source in Linux?
Alex Waters
# How do I build Bitcoin from source in Linux?

(Asked by: username_0 on 2011-09-02)

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.

**Tags:** ubuntu

> **Comments:**
> **username_0**: I have added the issue to the github issue tracker: https://github.com/bitcoin/bitcoin/issues/485  

---

## 1 answers

### Answer by username_1 on 2011-09-02. Score: 8 | Accepted answer

Basically, you do this:

1. Download the distribution tarball or repository. You can use the link on the project's [GitHub](https://github.com/bitcoin/bitcoin) 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.)

> **Comments:**
> **username_0**: I'm using virtualbox to build test environments for commits - so no concern about two clients (yet) - thanks for the heads up and info!  
> **username_3**: 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.?  
> **username_1**: 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.  
> **username_2**: If you're on Debian or Ubuntu, I wrote a script that will install all of the dependencies. [Link](https://github.com/nickodell/build_bitcoin/)  

---

