Recently, I want to see what's the early-aged Wesnoth like, so I downloaded the old version's source code from Sourceforge. However, I failed to compile all the versions before 1.10.

Let me take v1.5.14 as an example. V1.5.14 is the last version of v1.5 series which has two ways to compile -- the "./configure" way and "scons" way. I failed in both of them.

Firstly, I downloaded the source code of v1.5.14 and I unzipped it. I tried to run "./configure" but it reported an error:checking for the Boost iostreams library... configure: error: Cannot compile a test that uses Boost iostreams
However, I'm sure that I have installed all the lastest boost libraries. I also uninstalled them and compile and reinstall them, but the problem was still there. I ran "apt list libboost*1.65*"and it shows this:

If you have Windows, it's easier to run old versions, as it's not necessary to compile anything - the old Windows binaries seem to still run even on newer versions of Windows. (I have a bunch of old versions of Wesnoth running on Windows 10, going back as far as Wesnoth 0.9.7.)

I have not tried this, but for compiling old versions, it might be better to use a branch from the Git repository instead of a released version - a Git branch will sometimes receive bug fixes even when there are no more releases from that branch. For example, the 1.8 branch appears to have a number of bug fixes made in 2014 and 2015, even though the last release of the 1.8.x series was in 2011.

It's probably folly to try to run ancient source code with modern libraries.

I'd suggest firing off a new VM, installing the ancient version of Linux, and the various tool chains, and compiling the ancient source on that. Otherwise, you're probably going to be faced with being forced to modify the source to work with your modern tools; which seems to violate the goal of comparing the ancient version, as it was, to the modern one.

Personally, I'd hit the archives (SourceForge and the Wayback Machine would be a good starting points) and try to locate ancient pre-compiled binaries.

If you want to compile from source:
1. Clone the Git repo
2. Re-read Tad's comment and ask yourself how much time you're prepared to spend on this
3. As the error is in src/foreach.hpp, run gitk --all -- src/foreach.hpp to see what's happened to that file
4. Read Tad's comment again and ask yourself how much time you're prepared to spend on this

Instead of trying to build the last 1.5.x development version you might prefer to try the 1.6 branch from Git like it was pointed out above, not only because we sometimespush changes to make old branches buildable on newer (but not necessarily the newest) platforms depending on need/interest, but also because the last development version for any given series is a release candidate for the next stable series, so unless you are testing them out of historical interest you’ll find it more convenient to stick with stable series in general.

Bear in mind that this does not guarantee that the binaries will work correctly or that the packages will be installed without errors due to missing/changed dependencies, as well as distribution incompatibilities (apt-based ≠ compatible with whatever version of Debian the packages were originally built for).

Also, failing all that, you can try installing and running old Windows builds from SF.net using Wine. They are pretty much guaranteed to work (although not necessarily work correctly — see also the whole userdata-in-install-dir debacle on Windows Vista and later) since they ship with all their dependencies.

1.8 can still be built using the version from the repository, as compiler related patches have been pushed.
One needs to have Lua version 5.1 installed for it, and in my case I had to temporarily remove the current version of Lua, there was some problem to detect Lua 5.1 correctly.

1.6 needs as well the version from the repository with additional patches. It will by default compile assuming the C++11 standard, one must add '-ansi' to the CFLAGS and CXXFLAGS.

1.4… I have not much hope… maybe with an old compiler, and possibly additional fixes like the one at the top of the 1.6 and 1.8 branch.