Get source and compile
The viewer source is under a big transition. The ways to get and compile the viewer source is different in 1.19, 1.20, and 1.21 series. Some information on this page (and several sub-pages) are based on viewer source 1.19 series and before, while some others are based on 1.20 series or even on the coming 1.21 series. The pages will be consistent when 1.21 series are out and stable. Thank you for your patience.
Even if you don't plan to develop, just the act of downloading and compiling can uncover problems. If the version you download doesn't build on your platform, file a bug.
Getting the source
Download Source Archives (Zipfile/Tarball)
Linden Lab does provide current and past downloads in an archived format, see the source downloads page.
Version Control
Linden Lab also maintains a version control repository. There are some unofficial repositories, too. See the version control repository page and source version control for more details.
Compiling
Cross-platform build instructions:
Old (pre-CMake) Build Instructions
These links currently reflect the "old" (aka pre-CMake) way of building the source. As mentioned on the SL Dev list, there isn't much sense in still learning the old (pre-CMake) build system as the new system (CMake) is completely replacing how things work.
Per platform instructions are available in these topics:
See Common compilation problems if you run into errors while building.
See Improving compilation time for information on how to compile faster
See LLMozLib2 for building LLMozLib2.
Hints on running
Channels and Versions
Channels are just groupings of versions. Linden Lab uses channels to track and supply updates for First Look viewers separately from Release and Release Candidate viewers.
If you get a message while trying to start your compiled viewer that there is a required update, don't panic. All of your work is not lost. You (usually) don't have to apply your changes to a new source release to test your code. That's where channels come in.
On login, the combination of channel plus version is checked against a list. Within each channel, some versions are allowed and some are blocked. Viewers are blocked that are unsafe (security issues), incompatible (the protocol has been changed in some fundamental way), not supported (so old Linden Lab can't afford to provide support resources), or (most relevant here) are in a test channel (Release Candidate, First Look) and Linden Lab only wants test data from the most recent.
Since this is a convenience for the residents and Linden, but (in most cases) not a technical requirement, if the channel/version pair doesn't match, then the viewer is let through.
So: simply change the channel to anything else, e.g. "My Most Excellent SL Viewer" and you won't get blocked.
You can do that in the source code or on the command line. See Setting a Channel and Version for an Open Source Viewer for an explanation of how to do it in the source code.
On the command line, you simply add a parameter
-channel "My Most Excellent SL Viewer"
On Microsoft Windows, you can incorporate this parameter into the desktop icon that you use to start your viewer. Just edit the Properties for the shortcut and add (or change) the parameter in the Target field.
You can also stick command-line arguments in arguments.txt in the applicatoin bundle (.app directory) on MacOS X or in gridargs.dat in the Second Life install directory on Linux.
See Channel and Version Requirements for a detailed explanation and official policy on how Linden Lab deals with channels and versions in Second Life.
Please note, however, if you plan to distribute your viewer binary, changing the channel permanently (i.e., editing the source) is not recommended; if you did so, any security problems found in a future would not be checked by the grid, and residents who received your viewer might use that valnerable version forever.