Ethereum: How to Install Berkeley DB 4.8 on Linux
As a developer working with Ethereum smart contracts, you have probably had the need to store data in a structured format such as JSON or binary. In this article, we will walk you through the process of installing Berkeley DB 4.8 on your Linux system.
What is Berkeley DB?
Berkeley Database (Berkeley DB) is an open-source relational database management system that allows you to store and query structured data in a flexible, self-contained format. It is widely used for various applications, including databases, caching, and data storage.
Why do I need Berkeley DB 4.8 on Linux?
To install Ethereum, you will likely be working with JSON-based data structures or binary files stored in the “wallet” directory. However, some older versions of Ethereum (before 1.3) required a specific version of Berkeley DB 4.6 to function properly.
Fortunately, a newer version of Berkeley DB has been released: 4.8. We will show you how to install it on your Linux system.
Installing Berkeley DB 4.8 on Linux
Ubuntu and Debian (with libdb-dev packages)
If you are using Ubuntu or Debian, you can easily install the required libdb-dev
package with Berkeley DB 4.8:
sudo apt-get install libdb-dev libdb++-dev
Once installed, you will need to link to the Berkeley DB library for your specific project:
g++ -o example example.cpp -I/usr/include/berkeley-db
Alternative method using Docker
For a more convenient and reproducible experience, consider using Docker. You can create a Docker image with Berkeley DB 4.8 and its dependencies installed:
FROM ubuntu:latest
RUN apt-get update && apt-get install -y libdb-dev libdb++-dev
WORKCARD /app
COPY . /application/
CMD ["g++", "-o", "example", "example.cpp"]
Once the image is created, you can extract it and run your project:
docker pull berkeley-db-4.8-image
docker run -it berkeley-db-4.8-image example
Installing Berkeley DB 4.8 on a non-standard Linux distribution
If you are using a different Linux distribution (e.g. Fedora, CentOS) or you have not installed the libdb-dev
package, you will need to manually install Berkeley DB 4.8:
- Download the Berkeley DB 4.8 source code from the official website: <
- Extract the zip file using
tar xzf bdb-4.8.tar.gz
- Create a new directory for your project and navigate to it:
mkdir myproject
cd myproject
- Place the extracted Berkeley DB 4.8 source code in your current working directory.
- Use the following command to build Berkeley DB 4.8:
code bdb-4.8
./configure --prefix=/usr/local/bdb-4.8
Do
sudo make install
- Verify that Berkeley DB 4.8 is installed by checking for its presence in the
/usr/bin
andlib/
directories.
You are now ready to use Berkeley DB 4.8 with your Ethereum smart contract project!