{{fbdoc item="title" value="Compiling a Development Version of FreeBASIC"}}----

The source code of ""FreeBASIC"" is maintained on Sourceforge using the Git version control system, which allows different developers to work on the source code at the same time and later combine their work. It is possible for users to download the ""FreeBASIC"" source code using anonymous read access and compile it using GNU development tools.

Compiling the development version is not recommended for most users. ""FreeBASIC"" is a self-hosting compiler, still in active development, so there will be times when the current development version cannot be compiled by the last official release. Note also that the procedures for building the compiler described here may change with future versions of ""FreeBASIC"".

Essentially, ""FreeBASIC"" consists of two parts:
	1) The ""FreeBASIC"" compiler, written in ""FreeBASIC"" (self-hosting). Compiling this requires a working ""FreeBASIC"" installation.
	1) The ""FreeBASIC"" runtime libraries, written in C. Compiling this requires a C compiler such as gcc, the GNU C compiler (Native gcc on Linux, ""MinGW"" on Windows, DJGPP for DOS).

Generally, when compiling FB, care should be taken to never mix compiler and rtlib of different versions, because they will not necessarily be compatible. fbc's code generation expects a specific libfb version. Thus, an FB setup should always have the proper libfb version in its ##lib/## directory, matching the version of the ##fbc.exe##. When building a new compiler, just like any other FB program, it will be compiled by an existing fbc and thus it must also be linked against the existing fbc's libfb, not against the new libfb. The new libfb belongs into the new compiler's ##lib/## directory, not in that of the existing fbc. Typically this means that the compiler should be built first, before rtlib/gfxlib2, which is also how the FB makefile works by default.  At this point, should have a new working compiler, but it is linked to an older rtlib/gfxlib2.  To get the combination that most users will eventually see, remake the compiler a second time, linking to the newly made rtlib/gfxlib2.

There are two ways to build FB: [[DevNormalVsStandalone|normal or standalone]]. The normal version is intended for integration with an existing gcc toolchain, while the standalone version makes fbc act more like a self-contained tool. Most importantly, the two use slightly different directory layouts. For example, in the normal version the fbc program is located at ##bin/fbc[.exe]##, while in the standalone version, ##fbc[.exe]## is put into the toplevel directory, instead of the ##bin/## directory. Furthermore, the directory layout for include files and libraries differs. Traditionally, the FB-linux release is a normal build, while the FB-win32 and FB-dos builds are standalone versions.

{{fbdoc item="keyword" value="DevGettingTheSourceCode|Getting the source code"}}
{{fbdoc item="keyword" value="DevBuildDos|Compiling FB for DOS"}}
{{fbdoc item="keyword" value="DevBuildLinux|Compiling FB on Linux"}}
{{fbdoc item="keyword" value="DevBuildWindows|Compiling FB on Windows"}}
{{fbdoc item="keyword" value="DevRebuildAfterUpdates|Getting source code updates and recompiling FB"}}
{{fbdoc item="keyword" value="DevDebuggingFb|Debugging FB"}}
{{fbdoc item="keyword" value="DevBuildConfig|FB build configuration options"}}
{{fbdoc item="keyword" value="DevBuildKnownProblems|Known problems when compiling FB"}}
{{fbdoc item="keyword" value="DevGccToolchainChoice|GCC toolchain choice"}}

{{fbdoc item="back" value="DevToc|FreeBASIC Developer Information"}}
{{fbdoc item="back" value="DocToc|Table of Contents"}}