Now the configuration is working fine. I had to export the library path for Berkeley DB properly:
export LD_LIBRARY_PATH="/root/db-6.0.20/build_unix/.libs"
Edit :
The directory build_unix/.libs
contains the necessary libs for OpenLDAP but also lots of other files produced during the Berkeley installation. I rather suggest to use the destination Berkeley lib directory which is created during the installation (it should be equal to PREFIX/lib), because you would remove/update your Berkeley source directory one day, breaking OpenLDAP runtime (see the end of my edit)
You can either export the LD_LIBRARY_PATH variable, or set it only at the configure time of OpenLDAP, this way :
LD_LIBRARY_PATH="/root/db-6.0.20.installed/lib" ./configure
Usually there would be other configuration options, I am omitting them here.
Once installed correctly, OpenLDAP may still fail to start with the following error message in the log :
5d34473d bdb_back_initialize: BDB library version mismatch: expected Berkeley DB 5.3.28: (September 9, 2013), got Berkeley DB 5.3.21: (May 11, 2012)
To solve this issue, the solution is again to force the LD_LIBRARY_PATH variable, this time in the startup script (wherever is yours, /etc/init.d/openldap for example). As we are talking about the runtime, it's important here to note we shouldn't call the build_unix/.libs
directory which is considered temporary, but the created /lib
directory.