Sometimes, compiling the wallets can be a problem. Especially when you see an error like this:
libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality
Now, there could be many reasons for this. The most common is that we are missing libdb4.8-dev and libdb4.8++-dev. However, there are cases, when you have these versions installed, and the same error is appearing. This is most likely because the code you are attempting to compile is attempting to use a different version, than allow you to use the one you have installed.
So there are two ways around the problem. The first, you can install the version that you need for the code to compile successfully. This is fine, but then if you have a wallet file that is in Berkeley DB format 4.x and you are now attempting to use 5.x or 6.x then there will be problems. It just won't work like that. Now, if you don't have a wallet, then that's fine. If you do though that is in an older format, you are not going to be able to read it or potentially corrupt it and lose anything that you have in that wallet. The second could depend on the codebase you are using, check to see if you have a zcutil directory. If you do, then this means you don't use the usual compile methods like some coins, but you have to use ./zcutil/build.sh to compile everything this way.
The third solution if zcutil doesn't exist, or you wish to force using an older version is to edit build-aux/m4/bitcoin_find_bdb.m4 and let it utilise the version that you have installed. Once that has been done, you can then compile the wallet successfully using an older version of Berkeley DB. Ideally it would be better for the devs that maintain the code, to allow for multiple versions to be used in the first place, rather than hard-coding it to a newer version that will cause problems. Then the user compiling can decide whether they use 4.8, 5.x or 6.x during compilation. I found this recently with a particular coin, that had forked code from a particular codebase.
I wouldn't suggest that just "anyone" edit the file, you will need to know what lines to edit, the majority though is just the versioning, but you can do this simply by comparing the one that you have problems with, to another that does work with the older Berkeley DB libraries. You can then take these version numbers and edit accordingly in the one you have issues with, and then compile. Problem solved!