Berkeley DB not found on Fedora 8
来源:互联网 发布:淘宝模特拍摄视频教程 编辑:程序博客网 时间:2024/04/29 06:09
from:http://milan.adamovsky.com/2010/10/berkeley-db-not-found-on-fedora-8.html
My preferred Operating System to work on is FreeBSD, but recently I was working on a project on a Fedora AMI on the Amazon EC2 platform. There are a few differences between the two systems and I have to develop a cross-platform script.
The binary I was trying to compile was the Apache Portable Runtime utility calledapr-util which is needed to compile the Apache web server. As you may already know, one of the prerequisites is Berkeley DB.
Compilation
Whenever developing cross-platforms scripts or applications it is important to rely on tarballs as opposed to native OS package systems such as FreeBSD'sports, Linux'rpm oryum. The main reason for this is that doing manual compilations gives you granular control over the dependencies, patches, and compilation options that may and may not be better suited for cross-platform operations. That is assuming that the goal is to have an identical binary cross-platform.
To compile apr-util we use the following sequential commands:
./configure --with-apr=/usr/local/apr/bin/apr-1-config --with-berkeley-db=/usr/local/BerkeleyDB.4.8
make
make install
The pre-requisite is that apr and Berkeley have already been installed on the system. In the example above we use Berkeley 4.8 but feel free to use the latest version.
Problem
The problem that we encounter when we compile apr-util manually is the following:
checking for Berkeley DB... not found configure: error: Berkeley DB not found.
This error message indicates that the linker was unable to find Berkeley DB libraries to compile against. This gives us enough information to immediately figure out that the problem lies with a tool calledldconfig.
Solution
The solution involves calibrating the linker to be aware of where the Berkeley DB libraries can be found, and this is exactly what we will do.
It may at first seem that we should focus on fixing something in the files ofapr-util but the real solution lies with Berkeley DB.
When Berkeley DB is compiled we simply need to expose the various paths to the linker.
echo /usr/local/BerkeleyDB.4.8/lib > /etc/ld.so.confldconfigexport CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include"export LD_LIBRARY_PATH="/usr/local/BerkeleyDB.4.8/lib/"export LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib"
I normally extrapolate the path into a variable such as $BERKELEY_PREFIX but for sake of clarity I've avoided that in the examples. Feel free to do so however since it makes your code more manageable and flexible. Doing so the code would look like this:
export BERKELEY_PREFIX=/usr/local/BerkeleyDB.4.8echo $BERKELEY_PREFIX/lib >> /etc/ld.so.confldconfigexport CPPFLAGS="-I$BERKELEY_PREFIX/include"export LD_LIBRARY_PATH="$BERKELEY_PREFIX/lib/"export LDFLAGS="-L$BERKELEY_PREFIX/lib"
Just a little bonus.
Continuing with our solution, what we accomplish with the above is adding the path of where Berkeley DB libraries can be found to the linker configuration file (ld.so.conf). Be very careful toappend the path to the ld.so.conf as not to overwrite any existing contents of the file. This is simply done by ensuring you use '>>' as opposed to '>' as shown above. Consider this a word of caution.
Once the path is in your ld.so.conf you will simply need to run the linkerldconfig to make it aware of the changes. This will suck in all libraries. We can then verify that they have taken effect by listing all the libraries that ldconfig is aware of.
[root@server ~]# ldconfig -p | grep libdb
libdbus-1.so.3 (libc6,x86-64) => /lib64/libdbus-1.so.3
libdbus-1.so.3 (libc6) => /lib/libdbus-1.so.3
libdbus-glib-1.so.2 (libc6,x86-64) => /usr/lib64/libdbus-glib-1.so.2
libdbus-glib-1.so.2 (libc6) => /usr/lib/libdbus-glib-1.so.2
libdb-4.8.so (libc6,x86-64) => /usr/local/BerkeleyDB.4.8/lib/libdb-4.8.so
libdb-4.6.so (libc6,x86-64) => /lib64/libdb-4.6.so
libdb-4.6.so (libc6,x86-64) => /usr/lib64/libdb-4.6.so
libdb-4.6.so (libc6) => /lib/libdb-4.6.solibdb-4.6.so (libc6) => /usr/lib/libdb-4.6.so
We can see from the above output that we have two Berkeley DBs installed on the system. One of them is version 4.6 and one of them is our new version 4.8. If you choose to install any other version your output would reflect an entry with the selected version respectively.
FreeBSD listing
In FreeBSD the ldconfig switch to see the listing above is-r instead of-p. You would thus run the command below:
[root@server ~]# ldconfig -r | grep Berkeley
Though in FreeBSD the libraries may not even be listed at all if we simply add the path of Berkeley DB to the search path as such:
ldconfig -m /usr/local/BerkeleyDB.4.8/lib
However as long as it is in the search path the linker will find the libraries at compilation.
Automation
At this point you should already have fixed the problem. You do not need to do anything anymore. The information below is just a little extra.
You can take it a step further by doing a conditional check ensuring you do not clutter your /etc/ld.so.conf file by not appending the path if it already exists.
export BERKELEY_PREFIX=/usr/local/BerkeleyDB.4.8if [[ "$(grep $BERKELEY_PREFIX/lib /etc/ld.so.conf)" =~ 'lib' ]]; then echo $BERKELEY_PREFIX/lib >> /etc/ld.so.conf ldconfigfiexport CPPFLAGS="-I$BERKELEY_PREFIX/include"export LD_LIBRARY_PATH="$BERKELEY_PREFIX/lib/"export LDFLAGS="-L$BERKELEY_PREFIX/lib"
The above would usually be put in an automation bash script.
- Berkeley DB not found on Fedora 8
- centos下configure: error: Berkeley DB not found.的解决办法
- error: Berkeley DB with 1.85 compatibility not found
- A beginner's note on berkeley db
- Berkeley DB
- Berkeley DB
- Berkeley DB
- Berkeley DB
- Berkeley DB
- Berkeley DB
- Berkeley DB
- Berkeley DB
- Berkeley DB
- Berkeley DB (DB)介绍
- Berkeley DB -- DB Environment
- Berkeley DB -- DB Environment
- berkeley db DB->close()
- Berkeley DB DB数据库
- Hibernate性能调优
- MTK HTTP 协议之内存分配
- Android BOOT Time 优化
- RedHat5.5_X64 Linux安装oracle 11.2.0.3 报错
- android resultCode 一直为0问题解决
- Berkeley DB not found on Fedora 8
- HTML 5应用创意:使用NFC来猜拳
- 十个你可能没用过的Linux命令
- MTK HTTP 协议之文件操作
- 学WORD-替换换行符
- 常用的webservice接口
- 云计算标准化以及互操作性方面的标准
- [技术分享]20120628TMG 日志队列突然增长怎么办
- WCHAR and wchar_t 的区别 (zz)