Revision history for DevBuild


Revision [22561]

Last edited on 2019-02-09 07:22:18 by JeffMarshall [Remake compiler to link to newly created rtlib/gfxllib2]
Additions:
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.
Deletions:
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.


Revision [19974]

Edited on 2016-02-10 15:47:50 by DkLwikki [Update link format]
Additions:
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.
Deletions:
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.


Revision [17240]

Edited on 2014-09-06 09:23:17 by DkLwikki [Link to DevGccToolchainChoice]
Additions:
{{fbdoc item="keyword" value="DevGccToolchainChoice|GCC toolchain choice"}}


Revision [17239]

Edited on 2014-09-06 09:22:45 by DkLwikki [Explain that compiler should be built before rtlib]
Additions:
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.


Revision [17186]

Edited on 2014-08-28 13:27:28 by DkLwikki [Overhaul]
Additions:
{{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.
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).
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"}}
Deletions:
{{fbdoc item="title" value="Getting the FreeBASIC source code and compiling it"}}----
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 this source code using anonymous read access and compile it using GNU development tools.
On Windows, ""MinGW""/""MSYS"" is used to compile ""FreeBASIC"". Linux users will usually have the required development tools installed on their system already. The Cygwin build may be useful for Windows users wishing to access Linux libraries in windows. The DOS build is normally compiled on Windows using DJGPP. Advanced users may be able to cross-compile between other builds, but the correct development tools and libraries would be needed, and it has not been widely tested.
**{{anchor name="PreviousGuides|Previous guides (for compiling FB 0.23 and earlier)"}}**
**{{anchor name="GettingTheSource|Getting the current source code"}}**
**{{anchor name="DjgppBuild|Compiling for DOS using DJGPP on Win32"}}**
**{{anchor name="Linux32Build|Compiling on x86 GNU/Linux"}}**
**{{anchor name="Linux64Build|Compiling for x86 GNU/Linux on x86_64 GNU/Linux"}}**
**{{anchor name="TdmgccBuild|Compiling on Win32 using TDM-GCC and MSYS"}}**
**{{anchor name="MingwBuild|Compiling on Win32 using MinGW/MSYS, for installation into the MinGW tree"}}**
**{{anchor name="RecompileAfterUpdates|Getting source code updates and recompiling"}}**
**{{anchor name="Debugging|Debugging FB"}}**
**{{anchor name="MakefileCommands|Makefile commands"}}**
**{{anchor name="MakefileConfig|Makefile configuration (variables to set on the make command line or inside config.mk)"}}**
**{{anchor name="CompilerSourceConfig|Compiler source code configuration (FBCFLAGS)"}}**
**{{anchor name="RtlibSourceConfig|rtlib and gfxlib2 source code configuration (CFLAGS)"}}**
**{{anchor name="KnownProblems|Known problems and pitfalls"}}**
{{anchor name="PreviousGuides"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 [versions on or before September 20, 2011] and earlier)"}}
{{fbdoc item="keyword" value="SVNCygwin|Compiling from SVN for Cygwin"}}
{{fbdoc item="keyword" value="SVNWin32MSYS|Compiling from SVN for Win32, using MSYS on Win32"}}
{{fbdoc item="keyword" value="SVNLinux|Compiling from SVN for Linux"}}
{{fbdoc item="keyword" value="SVNDOSWin32|Compiling from SVN for DOS on Win32"}}
{{fbdoc item="keyword" value="SVNFreeBSD|Compiling from SVN for FreeBSD"}}
{{anchor name="GettingTheSource"}}{{fbdoc item="section" value="Getting the current source code"}}
The current source (""FreeBASIC"" 0.24+ [versions after September 20, 2011]) is available from these Git repositories:
- main repository at Sourceforge:
Git clone URL: ##""git://git.code.sf.net/p/fbc/code""##
Web view: http://sourceforge.net/p/fbc/code/
- Github mirror:
Git clone URL: ##""https://github.com/freebasic/fbc.git""##
Web view: https://github.com/freebasic/fbc
If you need help with installing or using Git, search the web or check out the few [[Git Git tips here]].
(Typical usage after installation: "git clone git://...")
{{anchor name="DjgppBuild"}}{{fbdoc item="section" value="Compiling for DOS using DJGPP on Win32"}}
1) The DOS version of ""FreeBASIC"" is typically compiled on a Windows system with DJGPP and a DOS version of ""FreeBASIC"" installed. Download the latest ""FreeBASIC-dos"" release from the [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20DOS/ FreeBASIC's download site]]. It should be extracted somewhere like ##""C:\FBDOS""##. We'll use it to bootstrap the new FB compiler.


1) The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/beta/v2/ beta/v2/]]##), but for the others it should be ok to use the ones from DJGPP 2.03 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/current/v2gnu/ current/v2gnu/]]##). Setup DJGPP by extracting everything into ##""C:\DJGPP""## and adding an environment variable named "DJGPP", set to ##""C:\DJGPP\djgpp.env""##.


- ##binutils## (##bnu*b.zip##, ##bnu*a.zip##)
- ##bash## (##bsh*.zip##)
- ##djdev## (##djdev*.zip##) - //pick up djdev204.zip or later from the ##beta/## directory//
- ##fileutils## (##fil*.zip##)
- ##gcc## (##gcc*b.zip##)
- ##gpp## (##gpp*b.zip##)
- ##make## (##mak*b.zip##)
- ##shellutils## (##shl*b.zip##)
- ##textutils## (##txt*b.zip##)

It can be useful (especially when working in parallel with ""MinGW"") to use a batch script to launch a terminal with the DJGPP tools in its PATH environment variable, instead of modifying the system's global PATH environment variable:

%%set DJGPP=C:\DJGPP\djgpp.env
set PATH=C:\DJGPP\bin;%PATH%
set PATH=C:\FBDOS;%PATH%
cd C:\
cmd%%
1) After having installed DJGPP and opened a command prompt with ##""C:\DJGPP\bin""## in its path, running gcc should run the DJGPP gcc:


%%> gcc --version
gcc.exe (GCC) 4.7.1
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%%
1) The traditional FB-dos setup is a standalone setup, so we will use ENABLE_STANDALONE for the new build.


Assuming the ""FreeBASIC"" sources are located at ##""C:\fbc-dos""##, create a ##""C:\fbc-dos\config.mk""## file containing something like the following:

%%ENABLE_STANDALONE := YesPlease
%%
1) Then, run "make" from a cmd.exe prompt and let it compile FB:


%%> cd C:\fbc-dos
> make
%%
1) Copy these files to ##""C:\fbc-dos\bin\dos""##:

-##""C:\DJGPP\bin\{ar,as,ld}.exe""##

1) Copy these files to ##""C:\fbc-dos\lib\dos""##:

-##""C:\DJGPP\lib\{crt0,gcrt0}.o""##
-##""C:\DJGPP\lib\lib{emu,m}.a""##
-##""C:\DJGPP\lib\gcc\djgpp\[version]\lib{gcc,supcxx}.a""##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
-##""C:\FBDOS\lib\dos\libc.a""## //- this should be the modified ##libc.a## from the latest ""FreeBASIC"" release. To use the libc.a from DJGPP, the _main.o it contains needs to be replaced with the one compiled from ##""contrib/djgpp/libc/crt0/_main.c""## from the fbc source code, to fix a bug in the original version from DJGPP.//
-and any additional libraries you want to use

1) Rename ##""C:\fbc-dos\fbc-new.exe""## to ##""C:\fbc-dos\fbc.exe""##, if wanted


1) The newly built FB setup can be tested right from the source tree, or you can copy it somewhere else. Make sure to copy all of the following files and directories:
- ##""fbc.exe""##
- ##""bin/dos/""##
- ##""inc/""##
- ##""lib/dos/""##
{{anchor name="Linux32Build"}}{{fbdoc item="section" value="Compiling on x86 GNU/Linux"}}
1) First, we'll need a working FB setup to bootstrap the new FB compiler. Download the latest ""FreeBASIC-linux"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Linux/ FreeBASIC's download site]], then extract and install it:


%%$ tar zxf FreeBASIC-X.XX.X-linux.tar.gz
$ cd FreeBASIC-X.XX.X-linux
$ sudo ./install.sh -i
%%
1) The following DEB packages plus dependencies are needed (with RPM names in parentheses):


- ##gcc##
- ##""g++""## (##""gcc-c++""##)
- ##binutils##
- ##make##
- ##libncurses5-dev## (##ncurses-devel##)
- ##libx11-dev## (##libX11-devel##)
- ##libxext-dev## (##libXext-devel##)
- ##libxpm-dev## (##libXpm-devel##)
- ##libxrandr-dev## (##libXrandr-devel##)
- ##libxrender-dev## (##libXrender-devel##)
- ##libgpm-dev## (##gpm-devel##)
- ##libgl1-mesa-dev##, ##libglu1-mesa-dev## (##Mesa-devel##) - //""OpenGL"" development files//
- ##libffi-dev## (##ffi-devel##) - //foreign function interface for ##[[KeyPgThreadcall ThreadCall]]##//

1) The traditional FB-linux setup is a normal FB setup that uses the system's tools and libraries. Usually it's not necessary to put anything inside config.mk.


1) Assuming the ""FreeBASIC"" sources are located at ##""~/fbc""##, run "make" there and let it compile FB:


%%$ cd ~/fbc
$ make
%%
1) Optionally, install the newly built into the path specified by the ##prefix## variable (defaults to /usr/local):


%%$ make install
%%
{{anchor name="Linux64Build"}}{{fbdoc item="section" value="Compiling for x86 GNU/Linux on x86_64 GNU/Linux"}}
1) Currently, FB only supports 32bit, and there is no 64bit port yet, but it is still possible to run and compile 32bit FB on a 64bit system. Just like with the 32bit GNU/Linux build, we'll need a working FB setup to bootstrap the new FB compiler. Download the latest ""FreeBASIC-linux"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Linux/ FreeBASIC's download site]], then extract and install it:


%%$ tar zxf FreeBASIC-X.XX.X-linux.tar.gz
$ cd FreeBASIC-X.XX.X-linux
$ sudo ./install.sh -i
%%
1) The following DEB packages plus dependencies are needed:


- ##libc6-dev-i386##
- ##binutils##
- ##gcc-multilib##
- ##""g++-multilib""##
- ##lib32ncurses5-dev##
- ##make##
- ##libx11-dev## - //for the X11 headers//
- ##libxext-dev##
- ##libxpm-dev##
- ##libxrandr-dev##
- ##libxrender-dev##
- ##libgl1-mesa-dev## - //for the ""OpenGL"" headers//
- ##libglu1-mesa-dev##
- ##libgpm-dev## - //for the GPM headers//
- ##ia32-libs-dev## - //for 32bit X11 and ""OpenGL"" development libraries on Debian//
- ##lib32ffi-dev##

1) Assuming the ""FreeBASIC"" sources are located at ##""~/fbc""##, create a ##""~/fbc/config.mk""## file with the following content:


%%CC := gcc -m32
TARGET_ARCH := x86
%%
This tells the FB makefile to use ##gcc -m32## instead of ##gcc##, which causes all C code to be compiled for x86 rather than x86_64. Furthermore, explicitly setting the TARGET_ARCH to x86 is necessary to get the makefile to select the proper x86 rtlib/gfxlib2 modules, because otherwise the makefile would rely on the output of ##uname -m##, which happens to be x86_64. But since we want to compile for 32bit, we need to override that.

1) Run "make" and let it compile FB:


%%$ cd ~/fbc
$ make
%%
1) Optionally, install the newly built into the path specified by the ##prefix## variable (defaults to /usr/local):


%%$ make install
%%
{{anchor name="TdmgccBuild"}}{{fbdoc item="section" value="Compiling on Win32 using TDM-GCC and MSYS"}}
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.


1) The ""Win32"" version of ""FreeBASIC"" is typically compiled on ""Win32"" using TDM-GCC (SJLJ -- setjump/longjump exception handling mode). Grab the TDM-GCC installer from [[http://tdm-gcc.tdragon.net/download]] and install the recommended TDM-GCC C and ""C++"" packages into ##""C:\TDM-GCC""##.


1) The needed MSYS packages can be downloaded and extracted by using the latest version of the [[http://sourceforge.net/projects/mingw/files/Installer/mingw-get/ mingw-get program]]. It can be extracted into the same directory as TDM-GCC; then it would install the MSYS files into ##""C:\TDM-GCC\msys\1.0""##, and as long as you do not use it to intall ""MinGW"" packages, there should be no conflict with the TDM-GCC files.


- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/ msys-findutils]]## (xargs for running the test suite)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/make/ msys-make]]##

1) After installing MSYS, you can open the MSYS bash by running ##""C:\TDM-GCC\msys\1.0\msys.bat""##. You have to make sure the FB makefile will find the fbc and gcc programs; in order to do this typically the ##""C:\TDM-GCC\bin""## and ##""C:\FB-win32""## directories are added to the PATH environment variable. In order to avoid modifying the system-wide PATH, you may use a .bat script like the following to open an MSYS bash with the needed PATH setting, everytime you need it:


%%set PATH=%PATH%;C:\TDM-GCC\bin
set PATH=%PATH%;C:\FB-win32
C:\TDM-GCC\msys\1.0\msys.bat
%%
1) The rtlib source code additionally depends on [[http://sourceware.org/libffi/ libffi]] headers (##ffi.h## and ##ffitarget.h##) to be available in ##""C:\TDM-GCC\include""##. Furthermore, the ##libffi.a## library will be needed later when compiling FB programs that use [[KeyPgThreadCall ThreadCall]]. Prebuilt versions of libffi are available from the [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/Libraries/ fbc downloads area]].


1) In order to compile ""FreeBASIC""'s gfxlib2, ""DirectX"" headers are needed in ##""C:\TDM-GCC\include""##, specifically ##ddraw.h## and ##dinput.h##. You can get the headers from here: [[http://alleg.sourceforge.net/files/dx80_mgw.zip]]


1) The traditional FB-win32 setup is a standalone setup, so we will use ENABLE_STANDALONE for the new build.


Assuming the ""FreeBASIC"" sources are located at ##""C:\fbc""##, create a ##""C:\fbc\config.mk""## file containing something like the following:

%%# FB-win32 typically is built as standalone
ENABLE_STANDALONE := YesPlease
# For TDM-GCC which doesn't have libgcc_eh, unlike MinGW.org
FBCFLAGS := -d ENABLE_TDMGCC
%%
1) Run "make" (from inside the MSYS bash) and let it compile FB:


%%$ cd /c/fbc
$ make
%%
1) Copy to ##""C:\fbc\bin\win32""##:
- ##""C:\TDM-GCC\bin\{ar,as,dlltool,ld}.exe""##
- ##""GoRC.exe""## (from [[http://www.godevtool.com/]] or the previous ""FreeBASIC"" release)

1) Copy to ##""C:\fbc\lib\win32""##:
- ##""C:\TDM-GCC\lib\{crt2,dllcrt2,gcrt2}.o""##
- ##""C:\TDM-GCC\lib\lib{gmon,mingw32,mingwex,moldname}.a""##
- ##""C:\TDM-GCC\lib\gcc\mingw32\[version]\{crtbegin,crtend}.o""##
- ##""C:\TDM-GCC\lib\gcc\mingw32\[version]\lib{gcc,supc++}.a""##
- ##""C:\TDM-GCC\lib\lib{advapi32,gdi32,kernel32,msvcrt,user32,winmm,winspool}.a""## //(rename to ##lib*.dll.a##)//
- ##""C:\TDM-GCC\lib\libffi.a""##
- and any additional libraries you want to use

1) Rename ##""C:\fbc\fbc-new.exe""## to ##""C:\fbc\fbc.exe""##, if wanted


1) The newly built FB setup can be tested right from the source tree, or you can copy it somewhere else. Make sure to copy all of the following files and directories:
- ##""fbc.exe""##
- ##""bin/win32/""##
- ##""inc/""##
- ##""lib/win32/""##
{{anchor name="MingwBuild"}}{{fbdoc item="section" value="Compiling on Win32 using MinGW/MSYS, for installation into the MinGW tree"}}
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.


1) To install [[http://www.mingw.org MinGW/MSYS]], download the latest version of the [[http://sourceforge.net/projects/mingw/files/Installer/mingw-get/ mingw-get program]] and extract it into ##""C:\MinGW""##. After that open a command prompt (cmd.exe) and run:


%%> C:\MinGW\bin\mingw-get.exe update
> C:\MinGW\bin\mingw-get.exe install <package-names>
%%
The following packages need to be installed via ##mingw-get install## (or by downloading & extracting them manually):

- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-g++]]## (only needed to get ""libsupc++.a"")
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/ binutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/ w32api]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/ msys-findutils]]## (xargs for running the test suite)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/make/ msys-make]]##

1) After installing MSYS, you can open the MSYS bash by running ##""C:\MinGW\msys\1.0\msys.bat""##. You have to make sure the FB makefile will find the fbc and gcc programs; in order to do this, typically the ##""C:\MinGW\bin""## and ##""C:\FB-win32""## directories are added to the PATH environment variable. In order to avoid modifying the system-wide PATH, you may use a .bat script like the following to open an MSYS bash with the needed PATH setting, everytime you need it:


%%set PATH=%PATH%;C:\MinGW\bin
set PATH=C:\FB-win32;%PATH%
C:\MinGW\msys\1.0\msys.bat
%%
It is also possible to use ""MinGW/MSYS"" programs from the cmd.exe command prompt, if you prefer. For that it may be worth it to add ##""C:\MinGW\bin""##, ##""C:\MinGW\msys\1.0\bin""## and ##""C:\FB-win32""## to the system's global PATH environment variable.

1) The rtlib source code additionally depends on [[http://sourceware.org/libffi/ libffi]] headers (##ffi.h## and ##ffitarget.h##) to be available in ##""C:\MinGW\include""##. Furthermore, the ##libffi.a## library will be needed later when compiling FB programs that use [[KeyPgThreadCall ThreadCall]]. Prebuilt versions of libffi are available from the [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/Libraries/ fbc downloads area]].


1) In order to compile ""FreeBASIC""'s gfxlib2, ""DirectX"" headers are needed in ##""C:\MinGW\include""##, specifically ##ddraw.h## and ##dinput.h##. You can get the headers from here: [[http://alleg.sourceforge.net/files/dx80_mgw.zip]]


1) This fbc build for ""MinGW"" will be a normal build, with the same directory structure as on Linux. Normally it is not necessary to put anything into config.mk, except perhaps the proper ##prefix## setting.


Assuming the ""FreeBASIC"" sources are located at ##""C:\fbc""##, create a ##""C:\fbc\config.mk""## file containing something like the following:

%%prefix := C:/MinGW
%%
1) Run "make" (from inside the MSYS bash) and let it compile FB:


%%$ cd /c/fbc
$ make
%%
1) Optionally, install the newly built FB into the path specified by the ##prefix## variable:


%%$ make install
%%
{{anchor name="RecompileAfterUpdates"}}{{fbdoc item="section" value="Getting source code updates and recompiling"}}
To download updates made available in the fbc Git repository, you can do a pull, either using your preferred graphical Git tool, or in a terminal:

%%git pull
%%
To take a look at incoming changes //before// applying them, do this:

%%# Update remote branches
git fetch
# Take a look
gitk --all
# Everything looks ok? Then merge the remote branch into the current branch to apply the update.
git merge origin/master
%%
Rebuilding is, most of the time, as easy as:

%%make
%%
If compilation options (like ENABLE_STANDALONE) were used for the previous build, it's necessary to specify them again this time, unless they are (still) set in ##config.mk##.

As a special exception, for the DOS build it is necessary to run ##make clean## before ##make## to properly rebuild FB after source modules have been renamed or deleted. The reason for this is that under DOS/DJGPP the makefile uses *.o wildcards to link fbc and archive libfb.a etc., instead of passing the explicit .o file names, because it has to obey the command line length limitation. If ##make clean## is not run, it may use old left-over object files from a previous build.
{{anchor name="Debugging"}}{{fbdoc item="section" value="Debugging FB"}}
For debugging and development it's a good idea to build the compiler with -g and -exx to enable assertions and NULL pointer/array boundary checks. For the rtlib/gfxlib2 code, -DDEBUG enables the assertions. Just update config.mk and (re)build. Example config.mk settings:

%%FBFLAGS := -g -exx
CFLAGS := -g -O0 -DDEBUG
%%
Running fbc inside gdb would typically look something like:

%%gdb --args fbc test.bas
%%
Also note that fbc can be tested right from inside the build tree, without being "installed" somewhere else, which also is a great debugging and development help.
{{anchor name="MakefileCommands"}}{{fbdoc item="section" value="Makefile commands"}}
- none or ##all##
The default - builds everything that needs to be built

- ##compiler##, ##rtlib##, ##gfxlib2##
Used to build a specific component only. For example, this can be used to build an ##rtlib## for a specific target, in order to be able to cross-compile FB programs (such as the ##compiler##) for that target.

- ##clean[-component]##
Used to remove built files. ##make clean## removes all built files, while for example ##make clean-compiler## removes only the files built for the compiler, allowing the compiler to be recompiled more quickly, without the need to rebuild the whole rtlib/gfxlib2 code.

- ##install[-component]##, ##uninstall[-component]##
Used to copy the built files into the directory specified by the ##prefix## variable, or remove them from there. This is most useful to install the normal build into /usr/local on Linux/BSD systems. For the standalone build, ##make install## will also work and copy over or remove the files. However, the standalone build uses an incompatible directory layout and should not be installed into /usr/local or similar directories because of this.

Note that it is fine to run the newly built FB setup right from the directory where it was compiled; ##make install## is not necessary to make it work (unless the prefix path was hard-coded into the compiler via ENABLE_PREFIX).

Additionally there are ##install-includes## and ##uninstall-includes## commands, which copy/remove just the FB includes (header files). Note that there is no ##make includes## or similar command, as the includes do not need to be built.
{{anchor name="MakefileConfig"}}{{fbdoc item="section" value="Makefile configuration (variables to set on the make command line or inside config.mk)"}}
- ##FBFLAGS##, ##FBCFLAGS##, ##FBLFLAGS##
Extra fbc flags to be used when compiling and/or linking the compiler

- ##CFLAGS##
Extra gcc flags to be used when compiling rtlib and gfxlib2

- ##prefix##
Changes the /usr/local prefix to something else. Note: MSYS maps ##/usr/local## to ##C:\msys\1.0\local##.

This is only used...
- by the makefile's ##install## and ##uninstall## commands,
- in the compiler (hard-coded) if ENABLE_PREFIX was used

Note that in combination with bash on ""Win32"" (e.g. from DJGPP or MSYS) it's necessary to use forward slashes instead of backslashes in directory paths, for example: ##""prefix=C:/MinGW""##

- ##TARGET##
This variable can be set to a system triplet in order to cross-compile using that GCC cross-compiler toolchain. The makefile will use ##''fbc -target $(TARGET)''## instead of ##''fbc''##, and ##''$(TARGET)-gcc''## instead of ##''gcc''##.

For example, on a Debian GNU/Linux system with the i686-w64-mingw32 GCC cross-compiler installed, you can build the win32 rtlib like this:

%%# Build the win32 rtlib/gfxlib2
make rtlib gfxlib2 TARGET=i686-w64-mingw32
# Install it into /usr/local/lib/i686-w64-mingw32-freebasic
make install-rtlib install-gfxlib2 TARGET=i686-w64-mingw32
%%
It will supplement the existing fbc installation in /usr/local, like a plugin, and from now on you can cross-compile FB programs for win32 by doing:

%%fbc -target i686-w64-mingw32 ...
%%
- ##FBC##, ##CC##, ##AR##
These variables specify the fbc, gcc and ar programs used during the build. You can specify them to override the defaults, for example:

- ##""make FBC=~/FreeBASIC-0.23.0-linux/fbc""##
- ##make CC="gcc -m32"##

##FBC## affects the ##compiler## source code only, while ##CC## and ##AR## are used for ##rtlib## and ##gfxlib2##.

- ##V##
##V## for verbose. By default, the makefile does not display the full command lines used during compilation, but just prints out the latest tool and file name combination to give a better visual indication of the build progress. It also makes warnings and errors stand out more in the console window. If the variable ##V## is set, the echoing tricks are disabled and full command lines will be shown, as GNU make normally does.

- ##ENABLE_STANDALONE=1##
Build a standalone FB setup instead of the normal Unix-style setup, see also: [[DevNormalVsStandalone the standalone vs. normal comparison]]. This causes the makefile to use the standalone directory layout and to use ##-d ENABLE_STANDALONE## when building the compiler.

- ##ENABLE_PREFIX=1##
This causes the makefile to use ##-d ENABLE_PREFIX=$(prefix)## when building the compiler.

- ##ENABLE_SUFFIX=foo##
This causes the makefile to use ##-d ENABLE_SUFFIX=$(ENABLE_SUFFIX)## when building the compiler, and to append the given suffix string to the fbc executable's and lib/ directories' names.

For example, using ##ENABLE_PREFIX=-0.24## will give you fbc-0.24.exe and a lib/freebasic-0.24/ directory, instead of fbc.exe and lib/freebasic/. This allows installing multiple versions of compiler and runtime in parallel. Note: The include/ directory name is not affected, and the FB headers are always shared by all installed FB versions (FB's headers and their directory layouts are designed to be able to do that). This is only supported for the normal (non-standalone) build.
{{anchor name="CompilerSourceConfig"}}{{fbdoc item="section" value="Compiler source code configuration (FBCFLAGS)"}}
- ##-d ENABLE_STANDALONE##
This makes the compiler behave as a standalone tool that cannot rely on the system to have certain programs or libraries. See [[DevNormalVsStandalone the normal vs. standalone comparison]] for more information.

- ##-d ENABLE_TDMGCC##
This makes the compiler work with TDM-GCC libraries instead of ""MinGW.org"" libraries. Currently the only difference is that under ""MinGW.org"", the compiler has to link in libgcc_eh to satisfy dependencies, while this is not needed under TDM-GCC, which does not even have this library. The difference is caused by the exception handling mechanisms the toolchains are configured to use: TDM-GCC with SJLJ, ""MinGW.org"" with DW2.

- ##-d ENABLE_SUFFIX=foo##
This makes the compiler append the given suffix to the lib/freebasic/ directory name when searching for its own lib/freebasic/ directory. For example, ##-d ENABLE_SUFFIX=-0.24## causes it to look for lib/freebasic-0.24/ instead of lib/freebasic/. This is only supported for the normal (non-standalone) build.

- ##-d ENABLE_PREFIX=/some/path##
This causes the given prefix path to be hard-coded into the compiler. It will no longer use exepath() and be relocatable. This may only be useful if its known that the compiler does not need to be relocatable, or if exepath() does not work.
{{anchor name="RtlibSourceConfig"}}{{fbdoc item="section" value="rtlib and gfxlib2 source code configuration (CFLAGS)"}}
- ##-DDISABLE_X11##
With this, the Unix rtlib/gfxlib2 will not use X11 headers, disabling gfxlib2's X11 graphics driver and some of the rtlib's Linux console functionality (affects multikey() and console mouse handling)

- ##-DDISABLE_GPM##
With this, the Linux rtlib will not use General Purpose Mouse headers (gpm.h), disabling the Linux [[KeyPgGetmouse GetMouse]] functionality.

- ##-DDISABLE_FFI##
With this, the rtlib will not use libffi headers (ffi.h), disabling the [[KeyPgThreadcall ThreadCall]] functionality.

- ##-DDISABLE_OPENGL##
With this, the gfxlib2 will not use ""OpenGL"" headers, disabling the ""OpenGL"" graphics drivers.
{{anchor name="KnownProblems"}}{{fbdoc item="section" value="Known problems and pitfalls"}}
{{fbdoc item="subsect" value="Win32 rtlib compilation error: _controlfp, _PC_64 undeclared"}}

%%CC src/rtlib/obj/hinit.o
src/rtlib/win32/hinit.c: In function 'fb_hInit':
src/rtlib/win32/hinit.c:21:5: warning: implicit declaration of function '_controlfp' [-Wimplicit-function-declaration]
src/rtlib/win32/hinit.c:21:17: error: '_PC_64' undeclared (first use in this function)
%%

Both the ""MinGW runtime"" and ""MinGW GCC"" have a ##float.h## header, and in some setups the GCC one is found before the ""MinGW"" one, causing the above errors. This issue shows up with some ""MinGW"" setups, for example gcc-core-4.6.1 + mingwrt-3.20, while for example gcc-core-4.5.2 + mingwrt-3.18 (a previous installation made with mingw-get) works fine. This problem also shows up with mingw32 cross compiler on Debian (gcc 4.4.4, mingwrt 3.13).

Easiest temporary fix: Append ###include_next <float.h>## to ##""C:\MinGW\lib\gcc\mingw32\""//version//""\include\float.h""##

See also:
- The comments at the top of ##""C:\MinGW\include\float.h""##
- [[https://sourceforge.net/tracker/?func=detail&aid=3414086&group_id=2435&atid=102435 MinGW GCC 4.6.1 bug report]]
- [[https://sourceforge.net/tracker/?func=detail&aid=3011968&group_id=2435&atid=302435 MinGW patch tracker, 2010]]
- http://lists.nongnu.org/archive/html/mingw-cross-env-list/2010-06/msg00038.html
- http://gcc.gnu.org/ml/gcc-patches/2010-01/msg01034.html
- https://sourceforge.net/mailarchive/message.php?msg_id=28122574

{{fbdoc item="subsect" value="MinGW binutils ld versions 2.18 to 2.21"}}

fbc triggers a bug (ld/12614) in the mentioned linker versions causing it to produce broken binaries. It's fixed in binutils 2.21.1 and up.

{{fbdoc item="subsect" value="-lXpm not found on Debian x86_64"}}

The ia32-libs-dev package (for example on Debian 6) for some reason does not contain a /usr/lib32/libXpm.so symlink, even though it does contain those for the other X11 development libraries. This apparently can be fixed by creating the symlink manually:

%%ln -s /usr/lib32/libXpm.so.4 /usr/lib32/libXpm.so
%%
{{fbdoc item="subsect" value="DJGPP: Too many open files"}}

If a DJGPP program fails with a //too many open files// error, this may help to increase the number of available file handles:

- If on ""Win32"": Use ##msconfig## to add ##""PerVMFiles=255""## to the ##""[386Enh]""## section of ##SYSTEM.INI##
- If on ""Win32"": Edit setting in ##""C:\WINDOWS\system32\CONFIG.NT""##: ##files=255##


Revision [17076]

Edited on 2014-05-04 18:55:17 by DkLwikki [Fix formatting]
Additions:
Easiest temporary fix: Append ###include_next <float.h>## to ##""C:\MinGW\lib\gcc\mingw32\""//version//""\include\float.h""##
Deletions:
Easiest temporary fix: Append ###include_next <float.h>## to ##""C:\MinGW\lib\gcc\mingw32\//version//\include\float.h""##


Revision [16992]

Edited on 2014-01-12 12:04:50 by DkLwikki [formatting]
Additions:
- If on ""Win32"": Use ##msconfig## to add ##""PerVMFiles=255""## to the ##""[386Enh]""## section of ##SYSTEM.INI##
- If on ""Win32"": Edit setting in ##""C:\WINDOWS\system32\CONFIG.NT""##: ##files=255##
Deletions:
- If on Win32: Use ##msconfig## to add ##""PerVMFiles=255""## to the ##""[386Enh]""## section of ##SYSTEM.INI##
- If on Win32: Edit setting in ##""C:\WINDOWS\system32\CONFIG.NT""##: ##files=255##


Revision [16991]

Edited on 2014-01-12 12:04:29 by DkLwikki [formatting]
Additions:
- If on Win32: Use ##msconfig## to add ##""PerVMFiles=255""## to the ##""[386Enh]""## section of ##SYSTEM.INI##
- If on Win32: Edit setting in ##""C:\WINDOWS\system32\CONFIG.NT""##: ##files=255##
Deletions:
- If on Win32: Use ##msconfig## to add ##PerVMFiles=255## to the ##[386Enh]## section of ##SYSTEM.INI##
- If on Win32: Edit setting in ##C:\WINDOWS\system32\CONFIG.NT##: ##files=255##


Revision [16990]

Edited on 2014-01-12 12:00:18 by DkLwikki [Add info for increasing available file handles for DJGPP]
Additions:
{{fbdoc item="subsect" value="DJGPP: Too many open files"}}
If a DJGPP program fails with a //too many open files// error, this may help to increase the number of available file handles:
- If on Win32: Use ##msconfig## to add ##PerVMFiles=255## to the ##[386Enh]## section of ##SYSTEM.INI##
- If on Win32: Edit setting in ##C:\WINDOWS\system32\CONFIG.NT##: ##files=255##


Revision [16977]

Edited on 2013-11-17 17:19:28 by CountingPine ['version' should be replaced with version number in paths]
Additions:
-##""C:\DJGPP\lib\gcc\djgpp\[version]\lib{gcc,supcxx}.a""##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
- ##""C:\TDM-GCC\lib\gcc\mingw32\[version]\{crtbegin,crtend}.o""##
- ##""C:\TDM-GCC\lib\gcc\mingw32\[version]\lib{gcc,supc++}.a""##
Easiest temporary fix: Append ###include_next <float.h>## to ##""C:\MinGW\lib\gcc\mingw32\//version//\include\float.h""##
Deletions:
-##""C:\DJGPP\lib\gcc\djgpp\version\lib{gcc,supcxx}.a""##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
- ##""C:\TDM-GCC\lib\gcc\mingw32\version\{crtbegin,crtend}.o""##
- ##""C:\TDM-GCC\lib\gcc\mingw32\version\lib{gcc,supc++}.a""##
Easiest temporary fix: Append ###include_next <float.h>## to ##""C:\MinGW\lib\gcc\mingw32\version\include\float.h""##


Revision [16973]

Edited on 2013-10-27 23:12:21 by CountingPine ["Binaries - Win32" -> "Binaries - Windows"]
Additions:
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.
Deletions:
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Win32/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Win32/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.


Revision [16892]

Edited on 2013-07-15 14:52:16 by DkLwikki [Add notes on libffi for MinGW builds]
Additions:
1) The rtlib source code additionally depends on [[http://sourceware.org/libffi/ libffi]] headers (##ffi.h## and ##ffitarget.h##) to be available in ##""C:\TDM-GCC\include""##. Furthermore, the ##libffi.a## library will be needed later when compiling FB programs that use [[KeyPgThreadCall ThreadCall]]. Prebuilt versions of libffi are available from the [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/Libraries/ fbc downloads area]].
- ##""C:\TDM-GCC\lib\libffi.a""##
1) The rtlib source code additionally depends on [[http://sourceware.org/libffi/ libffi]] headers (##ffi.h## and ##ffitarget.h##) to be available in ##""C:\MinGW\include""##. Furthermore, the ##libffi.a## library will be needed later when compiling FB programs that use [[KeyPgThreadCall ThreadCall]]. Prebuilt versions of libffi are available from the [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Windows/Libraries/ fbc downloads area]].


Revision [16891]

Edited on 2013-07-15 14:40:14 by DkLwikki [Remove __attribute__((packed)) note, rtlib code was adjusted]
Deletions:
{{fbdoc item="subsect" value="MinGW GCC 4.7.0 __attribute__((packed)) broken"}}
The FB rtlib's FB_DATADESC structure which uses ""__attribute__((packed))"" is miscompiled by default under ""MinGW"" GCC 4.7.0, due to the -mms-bitfields option being enabled by default since gcc 4.7.0. See also [[http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 GCC bug 52991]] and [[http://www.freebasic.net/forum/viewtopic.php?f=6&t=20233 this FB forum thread]]. The work-around for now is to compile the rtlib with -mno-ms-bitfields, for example with this in config.mk:
%%# work around new gcc 4.7 default (see gcc bug 52991)
CFLAGS := -O2 -mno-ms-bitfields


Revision [16890]

Edited on 2013-07-15 14:38:40 by DkLwikki [Turn 0.24 into 0.24+, since we're now at 0.90]
Additions:
The current source (""FreeBASIC"" 0.24+ [versions after September 20, 2011]) is available from these Git repositories:
Deletions:
The current source (""FreeBASIC"" 0.24 [versions after September 20, 2011]) is available from these Git repositories:


Revision [16367]

Edited on 2012-10-11 16:15:19 by DkLwikki [Fix camel case links]
Additions:
This makes the compiler work with TDM-GCC libraries instead of ""MinGW.org"" libraries. Currently the only difference is that under ""MinGW.org"", the compiler has to link in libgcc_eh to satisfy dependencies, while this is not needed under TDM-GCC, which does not even have this library. The difference is caused by the exception handling mechanisms the toolchains are configured to use: TDM-GCC with SJLJ, ""MinGW.org"" with DW2.
With this, the Linux rtlib will not use General Purpose Mouse headers (gpm.h), disabling the Linux [[KeyPgGetmouse GetMouse]] functionality.
With this, the rtlib will not use libffi headers (ffi.h), disabling the [[KeyPgThreadcall ThreadCall]] functionality.
With this, the gfxlib2 will not use ""OpenGL"" headers, disabling the ""OpenGL"" graphics drivers.
Deletions:
This makes the compiler work with TDM-GCC libraries instead of MinGW.org libraries. Currently the only difference is that under MinGW.org, the compiler has to link in libgcc_eh to satisfy dependencies, while this is not needed under TDM-GCC, which does not even have this library. The difference is caused by the exception handling mechanisms the toolchains are configured to use: TDM-GCC with SJLJ, MinGW.org with DW2.
With this, the Linux rtlib will not use General Purpose Mouse headers (gpm.h), disabling the Linux GetMouse functionality.
With this, the rtlib will not use libffi headers (ffi.h), disabling the ThreadCall functionality.
With this, the gfxlib2 will not use OpenGL headers, disabling the OpenGL graphics drivers.


Revision [16366]

Edited on 2012-10-11 16:08:17 by DkLwikki [libbfd notes removed]
Additions:
1) The traditional FB-linux setup is a normal FB setup that uses the system's tools and libraries. Usually it's not necessary to put anything inside config.mk.
This tells the FB makefile to use ##gcc -m32## instead of ##gcc##, which causes all C code to be compiled for x86 rather than x86_64. Furthermore, explicitly setting the TARGET_ARCH to x86 is necessary to get the makefile to select the proper x86 rtlib/gfxlib2 modules, because otherwise the makefile would rely on the output of ##uname -m##, which happens to be x86_64. But since we want to compile for 32bit, we need to override that.
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/ binutils]]##
1) This fbc build for ""MinGW"" will be a normal build, with the same directory structure as on Linux. Normally it is not necessary to put anything into config.mk, except perhaps the proper ##prefix## setting.
##FBC## affects the ##compiler## source code only, while ##CC## and ##AR## are used for ##rtlib## and ##gfxlib2##.
Deletions:
- ##gettext## (##gtxt*b.zip##) - //libintl, for libbfd//
- ##zlib## (##zlib*b.zip##) - //zlib, for libbfd, from the ##[[http://www.delorie.com/pub/djgpp/current/v2tk/ current/v2tk/]]## directory//
Additionally, if and only if you are bootstrapping the compiler using an unmodified FB-dos release, use ENABLE_FBBFD=217, because FB-dos releases come with a libbfd.a 2.17. Otherwise, when using DJGPP's libbfd, leave out ENABLE_FBBFD. This happens for example when you're already using a self-built fbc that's using DJGPP's libbfd. If you want to avoid having to worry about which libbfd to link the new compiler against, then use DISABLE_OBJINFO.
ENABLE_FBBFD := 217
# (commented out)
# DISABLE_OBJINFO := YesPlease
-##""C:\DJGPP\lib\lib{bfd,iberty,intl,z}.a""## //(DJGPP's libbfd, for recompiling ""FreeBASIC"" using this tree)//
- ##binutils-dev## (##binutils-devel## or ##binutils-static##) - //libbfd for fbc's objinfo feature//
1) The traditional FB-linux setup is a normal FB setup that uses the system's tools and libraries.
Usually it's not necessary to put anything inside config.mk, unless you know you need it. For example, if your fbc is using its own libbfd.a 2.17 (for example because it is a FB-linux-standalone release) then you have to use ENABLE_FBBFD=217, but if you're using the usual FB-linux release, then your fbc should be using the system's libbfd, and nothing needs to be done. To be safe, you can use DISABLE_OBJINFO.
%%# (commented out)
# prefix := /usr/local
# DISABLE_OBJINFO := YesPlease
DISABLE_OBJINFO := YesPlease
This tells the FB makefile to use ##gcc -m32## instead of ##gcc##, which causes all C code to be compiled for x86 rather than x86_64. Furthermore, explicitly setting the TARGET_ARCH to x86 is necessary to get the makefile to select the proper x86 rtlib/gfxlib2 modules, because otherwise the makefile would rely on the output of ##uname -m##, which happens to be x86_64. But since we want to compile for 32bit, we need to override that. DISABLE_OBJINFO is used here to avoid libbfd problems - for example, a precompiled 32bit libbfd may not be available at all on 64bit GNU/Linux.
Additionally, if and only if you are bootstrapping the compiler using an unmodified FB-win32 release, use ENABLE_FBBFD=217, because FB-win32 releases come with a libbfd.a 2.17. Otherwise, when using TDM-GCC's libbfd, leave out ENABLE_FBBFD. This happens for example when you're already using a self-built fbc that's using TDM-GCC's libbfd. If you want to avoid having to worry about which libbfd to link the new compiler against, then use DISABLE_OBJINFO.
# Only when using TDM-GCC's libbfd, if needed to satisfy its dependencies
# FBLFLAGS := -l iconv -l advapi32
# Only when using libbfd 2.17
ENABLE_FBBFD := 217
# To avoid worrying about libbfd, uncomment this:
# DISABLE_OBJINFO := YesPlease
- ##""C:\TDM-GCC\lib\lib{bfd,iberty,intl,iconv}.a""## //(For recompiling ""FreeBASIC"" using this tree)//
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/ binutils]]## (binutils, and binutils-dev for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gettext/ gettext-dev]]## (libintl for libbfd)
1) This fbc build for ""MinGW"" will be a normal build, with the same directory structure as on Linux.
If and only if you are bootstrapping the compiler using an unmodified FB-win32 release, use ENABLE_FBBFD=217, because FB-win32 releases come with a libbfd.a 2.17. Otherwise, when using ""MinGW's"" libbfd, leave out ENABLE_FBBFD. This happens for example when you're already using a self-built fbc that's using ""MinGW's"" libbfd. If you want to avoid having to worry about which libbfd to link the new compiler against, then use DISABLE_OBJINFO.
# Only when using libbfd 2.17
ENABLE_FBBFD := 217
# To avoid worrying about libbfd, uncomment this:
# DISABLE_OBJINFO := YesPlease
These do not affect the compilation of the compiler's bfd-wrapper.c module.
##FBC## affects the ##compiler## source code only, while ##CC## and ##AR## are used for ##rtlib## and ##gfxlib2##. ##CC## is additionally used for the compilation of the compiler's bfd-wrapper.c module.
- ##DISABLE_OBJINFO=1##
This causes the makefile to use ##-d DISABLE_OBJINFO## when building the compiler, and additionally not to build the compiler's bfd-wrapper.c module.
- ##ENABLE_FBBFD=217##
This causes the makefile to use ##-d ENABLE_FBBFD=217## when building the compiler, and additionally not to build the compiler's bfd-wrapper.c module.
- ##-d DISABLE_OBJINFO##
This disables [[DevObjinfo the compiler's objinfo]] feature, and thus removes the need for libbfd. This is especially useful to avoid problems with libbfd; see the {{anchor name="KnownProblems|libbfd pitfall section under Known Problems"}} for more information.
- ##-d ENABLE_FBBFD=217##
This causes the compiler to use FB headers for libbfd, instead of using the bfd-wrapper.c module. This is what's done at least for FB releases. Please see the {{anchor name="KnownProblems|libbfd pitfall section under Known Problems"}} for more information.
{{fbdoc item="subsect" value="libbfd pitfall"}}
By default the compiler uses bfd-wrapper.c to access libbfd through the bfd.h found by gcc. You have to make sure to link against the proper corresponding libbfd.a/.so, not another one! (due to the unstable libbfd API)
If you know the specific libbfd version the compiler will be linked against, you can use ENABLE_FBBFD=version. Then the makefile will build the compiler with ##-d ENABLE_FBBFD=version##, causing it to use FB libbfd headers for that version, instead of compiling in the version agnostic bfd-wrapper.c.
Careful: the official FB standalone (linux/win32/dos) setups contain a libbfd.a 2.17, which will typically not match the bfd.h/libbfd.a/.so on the system. When boostrapping/building the compiler with such an FB setup you should use ENABLE_FBBFD=217. Here, using the default bfd-wrapper.c (compiling against bfd.h, but linking with an incompatible libbfd.a) is wrong. As an alternative it's possible to overwrite FB's libbfd.a with the one from the system, to make the libbfd.a against which the compiler will be linked match bfd.h.
Normally though, when building the compiler with an FB setup that does not come with its own libbfd.a, it's preferable to use the bfd-wrapper.c to use the system's libbfd. This is the case when bootstrapping/building the compiler using the normal non-standalone FB setup.
The way to avoid all the libbfd trouble is to use DISABLE_OBJINFO.
{{fbdoc item="subsect" value="Newly built fbc crashes inside a bfd_*() function from libbfd"}}
This is typically caused by libbfd header/library version mismatches, see above.
{{fbdoc item="subsect" value="Warning: .drectve ... unrecognized when linking fbc"}}
%%CC src/compiler/obj/bfd-wrapper.o
LINK bin/fbc-new.exe
Warning: .drectve `-aligncomm:"_FB_bfd_format",2 '
Warning: .drectve `-aligncomm:"_FB_bfd_architecture",2' unrecognized
This happens when fbc's C libbfd wrapper module (##bfd-wrapper.c##) is used and compiled with a modern GCC (such as GCC 4.5.x, 2010), and the new fbc.exe is being linked by the old ld 2.15 (2005) from the current ""FreeBASIC-win32"" releases. The old ld complains about not knowing some sections that were added to later binutils.
This is not known to cause any issue besides the warning, and can be solved by replacing the old ld.exe in the ""FreeBASIC-win32"" installation by a newer one from ""MinGW"".


Revision [16364]

Edited on 2012-10-10 16:13:46 by DkLwikki [Update to new Git URL]
Additions:
Git clone URL: ##""git://git.code.sf.net/p/fbc/code""##
Web view: http://sourceforge.net/p/fbc/code/
Deletions:
Git clone URL: ##""git://fbc.git.sourceforge.net/gitroot/fbc/fbc""##
Web view: http://fbc.git.sourceforge.net/git/gitweb.cgi?p=fbc/fbc;a=summary


Revision [16324]

Edited on 2012-08-29 08:45:31 by DkLwikki [Add MinGW GCC 4.7.0 known problem]
Additions:
{{fbdoc item="subsect" value="MinGW GCC 4.7.0 __attribute__((packed)) broken"}}
The FB rtlib's FB_DATADESC structure which uses ""__attribute__((packed))"" is miscompiled by default under ""MinGW"" GCC 4.7.0, due to the -mms-bitfields option being enabled by default since gcc 4.7.0. See also [[http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 GCC bug 52991]] and [[http://www.freebasic.net/forum/viewtopic.php?f=6&t=20233 this FB forum thread]]. The work-around for now is to compile the rtlib with -mno-ms-bitfields, for example with this in config.mk:
%%# work around new gcc 4.7 default (see gcc bug 52991)
CFLAGS := -O2 -mno-ms-bitfields


Revision [16289]

Edited on 2012-08-16 17:18:02 by DkLwikki [Update/overhaul for latest 0.24 changes]
Additions:
**{{anchor name="PreviousGuides|Previous guides (for compiling FB 0.23 and earlier)"}}**
**{{anchor name="GettingTheSource|Getting the current source code"}}**
**{{anchor name="DjgppBuild|Compiling for DOS using DJGPP on Win32"}}**
**{{anchor name="Linux32Build|Compiling on x86 GNU/Linux"}}**
**{{anchor name="Linux64Build|Compiling for x86 GNU/Linux on x86_64 GNU/Linux"}}**
**{{anchor name="TdmgccBuild|Compiling on Win32 using TDM-GCC and MSYS"}}**
**{{anchor name="MingwBuild|Compiling on Win32 using MinGW/MSYS, for installation into the MinGW tree"}}**
**{{anchor name="RecompileAfterUpdates|Getting source code updates and recompiling"}}**
**{{anchor name="Debugging|Debugging FB"}}**
**{{anchor name="MakefileCommands|Makefile commands"}}**
**{{anchor name="MakefileConfig|Makefile configuration (variables to set on the make command line or inside config.mk)"}}**
**{{anchor name="CompilerSourceConfig|Compiler source code configuration (FBCFLAGS)"}}**
**{{anchor name="RtlibSourceConfig|rtlib and gfxlib2 source code configuration (CFLAGS)"}}**
**{{anchor name="KnownProblems|Known problems and pitfalls"}}**
{{anchor name="PreviousGuides"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 [versions on or before September 20, 2011] and earlier)"}}
{{anchor name="GettingTheSource"}}{{fbdoc item="section" value="Getting the current source code"}}
- main repository at Sourceforge:
Git clone URL: ##""git://fbc.git.sourceforge.net/gitroot/fbc/fbc""##
Web view: http://fbc.git.sourceforge.net/git/gitweb.cgi?p=fbc/fbc;a=summary
- Github mirror:
Git clone URL: ##""https://github.com/freebasic/fbc.git""##
Web view: https://github.com/freebasic/fbc
{{anchor name="DjgppBuild"}}{{fbdoc item="section" value="Compiling for DOS using DJGPP on Win32"}}
1) The DOS version of ""FreeBASIC"" is typically compiled on a Windows system with DJGPP and a DOS version of ""FreeBASIC"" installed. Download the latest ""FreeBASIC-dos"" release from the [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20DOS/ FreeBASIC's download site]]. It should be extracted somewhere like ##""C:\FBDOS""##. We'll use it to bootstrap the new FB compiler.
1) The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/beta/v2/ beta/v2/]]##), but for the others it should be ok to use the ones from DJGPP 2.03 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/current/v2gnu/ current/v2gnu/]]##). Setup DJGPP by extracting everything into ##""C:\DJGPP""## and adding an environment variable named "DJGPP", set to ##""C:\DJGPP\djgpp.env""##.
- ##binutils## (##bnu*b.zip##, ##bnu*a.zip##)
- ##bash## (##bsh*.zip##)
- ##djdev## (##djdev*.zip##) - //pick up djdev204.zip or later from the ##beta/## directory//
- ##fileutils## (##fil*.zip##)
- ##gcc## (##gcc*b.zip##)
- ##gpp## (##gpp*b.zip##)
- ##gettext## (##gtxt*b.zip##) - //libintl, for libbfd//
- ##make## (##mak*b.zip##)
- ##shellutils## (##shl*b.zip##)
- ##textutils## (##txt*b.zip##)
- ##zlib## (##zlib*b.zip##) - //zlib, for libbfd, from the ##[[http://www.delorie.com/pub/djgpp/current/v2tk/ current/v2tk/]]## directory//
It can be useful (especially when working in parallel with ""MinGW"") to use a batch script to launch a terminal with the DJGPP tools in its PATH environment variable, instead of modifying the system's global PATH environment variable:
%%set DJGPP=C:\DJGPP\djgpp.env
1) After having installed DJGPP and opened a command prompt with ##""C:\DJGPP\bin""## in its path, running gcc should run the DJGPP gcc:
%%> gcc --version
gcc.exe (GCC) 4.7.1
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1) The traditional FB-dos setup is a standalone setup, so we will use ENABLE_STANDALONE for the new build.
Additionally, if and only if you are bootstrapping the compiler using an unmodified FB-dos release, use ENABLE_FBBFD=217, because FB-dos releases come with a libbfd.a 2.17. Otherwise, when using DJGPP's libbfd, leave out ENABLE_FBBFD. This happens for example when you're already using a self-built fbc that's using DJGPP's libbfd. If you want to avoid having to worry about which libbfd to link the new compiler against, then use DISABLE_OBJINFO.
Assuming the ""FreeBASIC"" sources are located at ##""C:\fbc-dos""##, create a ##""C:\fbc-dos\config.mk""## file containing something like the following:
%%ENABLE_STANDALONE := YesPlease
ENABLE_FBBFD := 217
# (commented out)
# DISABLE_OBJINFO := YesPlease
1) Then, run "make" from a cmd.exe prompt and let it compile FB:
%%> cd C:\fbc-dos
> make
1) Copy these files to ##""C:\fbc-dos\bin\dos""##:
-##""C:\DJGPP\bin\{ar,as,ld}.exe""##
1) Copy these files to ##""C:\fbc-dos\lib\dos""##:
-##""C:\DJGPP\lib\{crt0,gcrt0}.o""##
-##""C:\DJGPP\lib\lib{emu,m}.a""##
-##""C:\DJGPP\lib\gcc\djgpp\version\lib{gcc,supcxx}.a""##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
-##""C:\DJGPP\lib\lib{bfd,iberty,intl,z}.a""## //(DJGPP's libbfd, for recompiling ""FreeBASIC"" using this tree)//
-##""C:\FBDOS\lib\dos\libc.a""## //- this should be the modified ##libc.a## from the latest ""FreeBASIC"" release. To use the libc.a from DJGPP, the _main.o it contains needs to be replaced with the one compiled from ##""contrib/djgpp/libc/crt0/_main.c""## from the fbc source code, to fix a bug in the original version from DJGPP.//
-and any additional libraries you want to use
1) Rename ##""C:\fbc-dos\fbc-new.exe""## to ##""C:\fbc-dos\fbc.exe""##, if wanted
1) The newly built FB setup can be tested right from the source tree, or you can copy it somewhere else. Make sure to copy all of the following files and directories:
- ##""fbc.exe""##
- ##""bin/dos/""##
- ##""inc/""##
- ##""lib/dos/""##
{{anchor name="Linux32Build"}}{{fbdoc item="section" value="Compiling on x86 GNU/Linux"}}
1) First, we'll need a working FB setup to bootstrap the new FB compiler. Download the latest ""FreeBASIC-linux"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Linux/ FreeBASIC's download site]], then extract and install it:
%%$ tar zxf FreeBASIC-X.XX.X-linux.tar.gz
$ cd FreeBASIC-X.XX.X-linux
$ sudo ./install.sh -i
1) The following DEB packages plus dependencies are needed (with RPM names in parentheses):
- ##gcc##
- ##""g++""## (##""gcc-c++""##)
- ##binutils##
- ##binutils-dev## (##binutils-devel## or ##binutils-static##) - //libbfd for fbc's objinfo feature//
- ##make##
- ##libncurses5-dev## (##ncurses-devel##)
- ##libx11-dev## (##libX11-devel##)
- ##libxext-dev## (##libXext-devel##)
- ##libxpm-dev## (##libXpm-devel##)
- ##libxrandr-dev## (##libXrandr-devel##)
- ##libxrender-dev## (##libXrender-devel##)
- ##libgpm-dev## (##gpm-devel##)
- ##libgl1-mesa-dev##, ##libglu1-mesa-dev## (##Mesa-devel##) - //""OpenGL"" development files//
- ##libffi-dev## (##ffi-devel##) - //foreign function interface for ##[[KeyPgThreadcall ThreadCall]]##//
1) The traditional FB-linux setup is a normal FB setup that uses the system's tools and libraries.
Usually it's not necessary to put anything inside config.mk, unless you know you need it. For example, if your fbc is using its own libbfd.a 2.17 (for example because it is a FB-linux-standalone release) then you have to use ENABLE_FBBFD=217, but if you're using the usual FB-linux release, then your fbc should be using the system's libbfd, and nothing needs to be done. To be safe, you can use DISABLE_OBJINFO.
%%# (commented out)
# prefix := /usr/local
# DISABLE_OBJINFO := YesPlease
1) Assuming the ""FreeBASIC"" sources are located at ##""~/fbc""##, run "make" there and let it compile FB:
%%$ cd ~/fbc
$ make
1) Optionally, install the newly built into the path specified by the ##prefix## variable (defaults to /usr/local):
%%$ make install
{{anchor name="Linux64Build"}}{{fbdoc item="section" value="Compiling for x86 GNU/Linux on x86_64 GNU/Linux"}}
1) Currently, FB only supports 32bit, and there is no 64bit port yet, but it is still possible to run and compile 32bit FB on a 64bit system. Just like with the 32bit GNU/Linux build, we'll need a working FB setup to bootstrap the new FB compiler. Download the latest ""FreeBASIC-linux"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Linux/ FreeBASIC's download site]], then extract and install it:
%%$ tar zxf FreeBASIC-X.XX.X-linux.tar.gz
$ cd FreeBASIC-X.XX.X-linux
$ sudo ./install.sh -i
1) The following DEB packages plus dependencies are needed:
- ##libc6-dev-i386##
- ##binutils##
- ##gcc-multilib##
- ##""g++-multilib""##
- ##lib32ncurses5-dev##
- ##make##
- ##libx11-dev## - //for the X11 headers//
- ##libxext-dev##
- ##libxpm-dev##
- ##libxrandr-dev##
- ##libxrender-dev##
- ##libgl1-mesa-dev## - //for the ""OpenGL"" headers//
- ##libglu1-mesa-dev##
- ##libgpm-dev## - //for the GPM headers//
- ##ia32-libs-dev## - //for 32bit X11 and ""OpenGL"" development libraries on Debian//
- ##lib32ffi-dev##
1) Assuming the ""FreeBASIC"" sources are located at ##""~/fbc""##, create a ##""~/fbc/config.mk""## file with the following content:
%%CC := gcc -m32
TARGET_ARCH := x86
DISABLE_OBJINFO := YesPlease
This tells the FB makefile to use ##gcc -m32## instead of ##gcc##, which causes all C code to be compiled for x86 rather than x86_64. Furthermore, explicitly setting the TARGET_ARCH to x86 is necessary to get the makefile to select the proper x86 rtlib/gfxlib2 modules, because otherwise the makefile would rely on the output of ##uname -m##, which happens to be x86_64. But since we want to compile for 32bit, we need to override that. DISABLE_OBJINFO is used here to avoid libbfd problems - for example, a precompiled 32bit libbfd may not be available at all on 64bit GNU/Linux.
1) Run "make" and let it compile FB:
%%$ cd ~/fbc
$ make
1) Optionally, install the newly built into the path specified by the ##prefix## variable (defaults to /usr/local):
%%$ make install
{{anchor name="TdmgccBuild"}}{{fbdoc item="section" value="Compiling on Win32 using TDM-GCC and MSYS"}}
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Win32/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.
1) The ""Win32"" version of ""FreeBASIC"" is typically compiled on ""Win32"" using TDM-GCC (SJLJ -- setjump/longjump exception handling mode). Grab the TDM-GCC installer from [[http://tdm-gcc.tdragon.net/download]] and install the recommended TDM-GCC C and ""C++"" packages into ##""C:\TDM-GCC""##.
1) The needed MSYS packages can be downloaded and extracted by using the latest version of the [[http://sourceforge.net/projects/mingw/files/Installer/mingw-get/ mingw-get program]]. It can be extracted into the same directory as TDM-GCC; then it would install the MSYS files into ##""C:\TDM-GCC\msys\1.0""##, and as long as you do not use it to intall ""MinGW"" packages, there should be no conflict with the TDM-GCC files.
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/ msys-findutils]]## (xargs for running the test suite)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/make/ msys-make]]##
1) After installing MSYS, you can open the MSYS bash by running ##""C:\TDM-GCC\msys\1.0\msys.bat""##. You have to make sure the FB makefile will find the fbc and gcc programs; in order to do this typically the ##""C:\TDM-GCC\bin""## and ##""C:\FB-win32""## directories are added to the PATH environment variable. In order to avoid modifying the system-wide PATH, you may use a .bat script like the following to open an MSYS bash with the needed PATH setting, everytime you need it:
%%set PATH=%PATH%;C:\TDM-GCC\bin
set PATH=%PATH%;C:\FB-win32
C:\TDM-GCC\msys\1.0\msys.bat
1) In order to compile ""FreeBASIC""'s gfxlib2, ""DirectX"" headers are needed in ##""C:\TDM-GCC\include""##, specifically ##ddraw.h## and ##dinput.h##. You can get the headers from here: [[http://alleg.sourceforge.net/files/dx80_mgw.zip]]
1) The traditional FB-win32 setup is a standalone setup, so we will use ENABLE_STANDALONE for the new build.
Additionally, if and only if you are bootstrapping the compiler using an unmodified FB-win32 release, use ENABLE_FBBFD=217, because FB-win32 releases come with a libbfd.a 2.17. Otherwise, when using TDM-GCC's libbfd, leave out ENABLE_FBBFD. This happens for example when you're already using a self-built fbc that's using TDM-GCC's libbfd. If you want to avoid having to worry about which libbfd to link the new compiler against, then use DISABLE_OBJINFO.
Assuming the ""FreeBASIC"" sources are located at ##""C:\fbc""##, create a ##""C:\fbc\config.mk""## file containing something like the following:
%%# FB-win32 typically is built as standalone
ENABLE_STANDALONE := YesPlease
# For TDM-GCC which doesn't have libgcc_eh, unlike MinGW.org
FBCFLAGS := -d ENABLE_TDMGCC
# Only when using TDM-GCC's libbfd, if needed to satisfy its dependencies
# FBLFLAGS := -l iconv -l advapi32
# Only when using libbfd 2.17
ENABLE_FBBFD := 217
# To avoid worrying about libbfd, uncomment this:
# DISABLE_OBJINFO := YesPlease
1) Run "make" (from inside the MSYS bash) and let it compile FB:
%%$ cd /c/fbc
$ make
1) Copy to ##""C:\fbc\bin\win32""##:
- ##""C:\TDM-GCC\bin\{ar,as,dlltool,ld}.exe""##
- ##""GoRC.exe""## (from [[http://www.godevtool.com/]] or the previous ""FreeBASIC"" release)
1) Copy to ##""C:\fbc\lib\win32""##:
- ##""C:\TDM-GCC\lib\{crt2,dllcrt2,gcrt2}.o""##
- ##""C:\TDM-GCC\lib\lib{gmon,mingw32,mingwex,moldname}.a""##
- ##""C:\TDM-GCC\lib\gcc\mingw32\version\{crtbegin,crtend}.o""##
- ##""C:\TDM-GCC\lib\gcc\mingw32\version\lib{gcc,supc++}.a""##
- ##""C:\TDM-GCC\lib\lib{advapi32,gdi32,kernel32,msvcrt,user32,winmm,winspool}.a""## //(rename to ##lib*.dll.a##)//
- ##""C:\TDM-GCC\lib\lib{bfd,iberty,intl,iconv}.a""## //(For recompiling ""FreeBASIC"" using this tree)//
- and any additional libraries you want to use
1) Rename ##""C:\fbc\fbc-new.exe""## to ##""C:\fbc\fbc.exe""##, if wanted
1) The newly built FB setup can be tested right from the source tree, or you can copy it somewhere else. Make sure to copy all of the following files and directories:
- ##""fbc.exe""##
- ##""bin/win32/""##
- ##""inc/""##
- ##""lib/win32/""##
{{anchor name="MingwBuild"}}{{fbdoc item="section" value="Compiling on Win32 using MinGW/MSYS, for installation into the MinGW tree"}}
1) We will need a working FB-win32 installation to bootstrap the new FB compiler. Download the latest ""FreeBASIC-win32"" release from [[http://sourceforge.net/projects/fbc/files/Binaries%20-%20Win32/ FreeBASIC's download site]] and extract/install it somewhere like ##""C:\FB-win32""##.
1) To install [[http://www.mingw.org MinGW/MSYS]], download the latest version of the [[http://sourceforge.net/projects/mingw/files/Installer/mingw-get/ mingw-get program]] and extract it into ##""C:\MinGW""##. After that open a command prompt (cmd.exe) and run:
%%> C:\MinGW\bin\mingw-get.exe update
> C:\MinGW\bin\mingw-get.exe install <package-names>
The following packages need to be installed via ##mingw-get install## (or by downloading & extracting them manually):
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-g++]]## (only needed to get ""libsupc++.a"")
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/ binutils]]## (binutils, and binutils-dev for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/ w32api]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gettext/ gettext-dev]]## (libintl for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/ msys-findutils]]## (xargs for running the test suite)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/make/ msys-make]]##
1) After installing MSYS, you can open the MSYS bash by running ##""C:\MinGW\msys\1.0\msys.bat""##. You have to make sure the FB makefile will find the fbc and gcc programs; in order to do this, typically the ##""C:\MinGW\bin""## and ##""C:\FB-win32""## directories are added to the PATH environment variable. In order to avoid modifying the system-wide PATH, you may use a .bat script like the following to open an MSYS bash with the needed PATH setting, everytime you need it:
%%set PATH=%PATH%;C:\MinGW\bin
set PATH=C:\FB-win32;%PATH%
C:\MinGW\msys\1.0\msys.bat
It is also possible to use ""MinGW/MSYS"" programs from the cmd.exe command prompt, if you prefer. For that it may be worth it to add ##""C:\MinGW\bin""##, ##""C:\MinGW\msys\1.0\bin""## and ##""C:\FB-win32""## to the system's global PATH environment variable.
1) In order to compile ""FreeBASIC""'s gfxlib2, ""DirectX"" headers are needed in ##""C:\MinGW\include""##, specifically ##ddraw.h## and ##dinput.h##. You can get the headers from here: [[http://alleg.sourceforge.net/files/dx80_mgw.zip]]
1) This fbc build for ""MinGW"" will be a normal build, with the same directory structure as on Linux.
If and only if you are bootstrapping the compiler using an unmodified FB-win32 release, use ENABLE_FBBFD=217, because FB-win32 releases come with a libbfd.a 2.17. Otherwise, when using ""MinGW's"" libbfd, leave out ENABLE_FBBFD. This happens for example when you're already using a self-built fbc that's using ""MinGW's"" libbfd. If you want to avoid having to worry about which libbfd to link the new compiler against, then use DISABLE_OBJINFO.
Assuming the ""FreeBASIC"" sources are located at ##""C:\fbc""##, create a ##""C:\fbc\config.mk""## file containing something like the following:
%%prefix := C:/MinGW
# Only when using libbfd 2.17
ENABLE_FBBFD := 217
# To avoid worrying about libbfd, uncomment this:
# DISABLE_OBJINFO := YesPlease
1) Run "make" (from inside the MSYS bash) and let it compile FB:
%%$ cd /c/fbc
$ make
1) Optionally, install the newly built FB into the path specified by the ##prefix## variable:
%%$ make install
{{anchor name="RecompileAfterUpdates"}}{{fbdoc item="section" value="Getting source code updates and recompiling"}}
%%git pull
%%# Update remote branches
Rebuilding is, most of the time, as easy as:
%%make
If compilation options (like ENABLE_STANDALONE) were used for the previous build, it's necessary to specify them again this time, unless they are (still) set in ##config.mk##.
As a special exception, for the DOS build it is necessary to run ##make clean## before ##make## to properly rebuild FB after source modules have been renamed or deleted. The reason for this is that under DOS/DJGPP the makefile uses *.o wildcards to link fbc and archive libfb.a etc., instead of passing the explicit .o file names, because it has to obey the command line length limitation. If ##make clean## is not run, it may use old left-over object files from a previous build.
{{anchor name="Debugging"}}{{fbdoc item="section" value="Debugging FB"}}
For debugging and development it's a good idea to build the compiler with -g and -exx to enable assertions and NULL pointer/array boundary checks. For the rtlib/gfxlib2 code, -DDEBUG enables the assertions. Just update config.mk and (re)build. Example config.mk settings:
%%FBFLAGS := -g -exx
CFLAGS := -g -O0 -DDEBUG
Running fbc inside gdb would typically look something like:
%%gdb --args fbc test.bas
Also note that fbc can be tested right from inside the build tree, without being "installed" somewhere else, which also is a great debugging and development help.
{{anchor name="MakefileCommands"}}{{fbdoc item="section" value="Makefile commands"}}
- none or ##all##
The default - builds everything that needs to be built
- ##compiler##, ##rtlib##, ##gfxlib2##
Used to build a specific component only. For example, this can be used to build an ##rtlib## for a specific target, in order to be able to cross-compile FB programs (such as the ##compiler##) for that target.
- ##clean[-component]##
Used to remove built files. ##make clean## removes all built files, while for example ##make clean-compiler## removes only the files built for the compiler, allowing the compiler to be recompiled more quickly, without the need to rebuild the whole rtlib/gfxlib2 code.
- ##install[-component]##, ##uninstall[-component]##
Used to copy the built files into the directory specified by the ##prefix## variable, or remove them from there. This is most useful to install the normal build into /usr/local on Linux/BSD systems. For the standalone build, ##make install## will also work and copy over or remove the files. However, the standalone build uses an incompatible directory layout and should not be installed into /usr/local or similar directories because of this.
Note that it is fine to run the newly built FB setup right from the directory where it was compiled; ##make install## is not necessary to make it work (unless the prefix path was hard-coded into the compiler via ENABLE_PREFIX).
Additionally there are ##install-includes## and ##uninstall-includes## commands, which copy/remove just the FB includes (header files). Note that there is no ##make includes## or similar command, as the includes do not need to be built.
{{anchor name="MakefileConfig"}}{{fbdoc item="section" value="Makefile configuration (variables to set on the make command line or inside config.mk)"}}
- ##FBFLAGS##, ##FBCFLAGS##, ##FBLFLAGS##
Extra fbc flags to be used when compiling and/or linking the compiler
- ##CFLAGS##
Extra gcc flags to be used when compiling rtlib and gfxlib2
These do not affect the compilation of the compiler's bfd-wrapper.c module.
- ##prefix##
Changes the /usr/local prefix to something else. Note: MSYS maps ##/usr/local## to ##C:\msys\1.0\local##.
This is only used...
- by the makefile's ##install## and ##uninstall## commands,
- in the compiler (hard-coded) if ENABLE_PREFIX was used
Note that in combination with bash on ""Win32"" (e.g. from DJGPP or MSYS) it's necessary to use forward slashes instead of backslashes in directory paths, for example: ##""prefix=C:/MinGW""##
- ##TARGET##
This variable can be set to a system triplet in order to cross-compile using that GCC cross-compiler toolchain. The makefile will use ##''fbc -target $(TARGET)''## instead of ##''fbc''##, and ##''$(TARGET)-gcc''## instead of ##''gcc''##.
For example, on a Debian GNU/Linux system with the i686-w64-mingw32 GCC cross-compiler installed, you can build the win32 rtlib like this:
%%# Build the win32 rtlib/gfxlib2
make rtlib gfxlib2 TARGET=i686-w64-mingw32
# Install it into /usr/local/lib/i686-w64-mingw32-freebasic
make install-rtlib install-gfxlib2 TARGET=i686-w64-mingw32
It will supplement the existing fbc installation in /usr/local, like a plugin, and from now on you can cross-compile FB programs for win32 by doing:
%%fbc -target i686-w64-mingw32 ...
- ##FBC##, ##CC##, ##AR##
These variables specify the fbc, gcc and ar programs used during the build. You can specify them to override the defaults, for example:
- ##""make FBC=~/FreeBASIC-0.23.0-linux/fbc""##
- ##make CC="gcc -m32"##
##FBC## affects the ##compiler## source code only, while ##CC## and ##AR## are used for ##rtlib## and ##gfxlib2##. ##CC## is additionally used for the compilation of the compiler's bfd-wrapper.c module.
- ##V##
##V## for verbose. By default, the makefile does not display the full command lines used during compilation, but just prints out the latest tool and file name combination to give a better visual indication of the build progress. It also makes warnings and errors stand out more in the console window. If the variable ##V## is set, the echoing tricks are disabled and full command lines will be shown, as GNU make normally does.
- ##ENABLE_STANDALONE=1##
Build a standalone FB setup instead of the normal Unix-style setup, see also: [[DevNormalVsStandalone the standalone vs. normal comparison]]. This causes the makefile to use the standalone directory layout and to use ##-d ENABLE_STANDALONE## when building the compiler.
- ##DISABLE_OBJINFO=1##
This causes the makefile to use ##-d DISABLE_OBJINFO## when building the compiler, and additionally not to build the compiler's bfd-wrapper.c module.
- ##ENABLE_FBBFD=217##
This causes the makefile to use ##-d ENABLE_FBBFD=217## when building the compiler, and additionally not to build the compiler's bfd-wrapper.c module.
- ##ENABLE_PREFIX=1##
This causes the makefile to use ##-d ENABLE_PREFIX=$(prefix)## when building the compiler.
- ##ENABLE_SUFFIX=foo##
This causes the makefile to use ##-d ENABLE_SUFFIX=$(ENABLE_SUFFIX)## when building the compiler, and to append the given suffix string to the fbc executable's and lib/ directories' names.
For example, using ##ENABLE_PREFIX=-0.24## will give you fbc-0.24.exe and a lib/freebasic-0.24/ directory, instead of fbc.exe and lib/freebasic/. This allows installing multiple versions of compiler and runtime in parallel. Note: The include/ directory name is not affected, and the FB headers are always shared by all installed FB versions (FB's headers and their directory layouts are designed to be able to do that). This is only supported for the normal (non-standalone) build.
{{anchor name="CompilerSourceConfig"}}{{fbdoc item="section" value="Compiler source code configuration (FBCFLAGS)"}}
- ##-d ENABLE_STANDALONE##
This makes the compiler behave as a standalone tool that cannot rely on the system to have certain programs or libraries. See [[DevNormalVsStandalone the normal vs. standalone comparison]] for more information.
- ##-d DISABLE_OBJINFO##
This disables [[DevObjinfo the compiler's objinfo]] feature, and thus removes the need for libbfd. This is especially useful to avoid problems with libbfd; see the {{anchor name="KnownProblems|libbfd pitfall section under Known Problems"}} for more information.
- ##-d ENABLE_FBBFD=217##
This causes the compiler to use FB headers for libbfd, instead of using the bfd-wrapper.c module. This is what's done at least for FB releases. Please see the {{anchor name="KnownProblems|libbfd pitfall section under Known Problems"}} for more information.
- ##-d ENABLE_TDMGCC##
This makes the compiler work with TDM-GCC libraries instead of MinGW.org libraries. Currently the only difference is that under MinGW.org, the compiler has to link in libgcc_eh to satisfy dependencies, while this is not needed under TDM-GCC, which does not even have this library. The difference is caused by the exception handling mechanisms the toolchains are configured to use: TDM-GCC with SJLJ, MinGW.org with DW2.
- ##-d ENABLE_SUFFIX=foo##
This makes the compiler append the given suffix to the lib/freebasic/ directory name when searching for its own lib/freebasic/ directory. For example, ##-d ENABLE_SUFFIX=-0.24## causes it to look for lib/freebasic-0.24/ instead of lib/freebasic/. This is only supported for the normal (non-standalone) build.
- ##-d ENABLE_PREFIX=/some/path##
This causes the given prefix path to be hard-coded into the compiler. It will no longer use exepath() and be relocatable. This may only be useful if its known that the compiler does not need to be relocatable, or if exepath() does not work.
{{anchor name="RtlibSourceConfig"}}{{fbdoc item="section" value="rtlib and gfxlib2 source code configuration (CFLAGS)"}}
- ##-DDISABLE_X11##
With this, the Unix rtlib/gfxlib2 will not use X11 headers, disabling gfxlib2's X11 graphics driver and some of the rtlib's Linux console functionality (affects multikey() and console mouse handling)
- ##-DDISABLE_GPM##
With this, the Linux rtlib will not use General Purpose Mouse headers (gpm.h), disabling the Linux GetMouse functionality.
- ##-DDISABLE_FFI##
With this, the rtlib will not use libffi headers (ffi.h), disabling the ThreadCall functionality.
- ##-DDISABLE_OPENGL##
With this, the gfxlib2 will not use OpenGL headers, disabling the OpenGL graphics drivers.
{{anchor name="KnownProblems"}}{{fbdoc item="section" value="Known problems and pitfalls"}}
{{fbdoc item="subsect" value="libbfd pitfall"}}
By default the compiler uses bfd-wrapper.c to access libbfd through the bfd.h found by gcc. You have to make sure to link against the proper corresponding libbfd.a/.so, not another one! (due to the unstable libbfd API)
If you know the specific libbfd version the compiler will be linked against, you can use ENABLE_FBBFD=version. Then the makefile will build the compiler with ##-d ENABLE_FBBFD=version##, causing it to use FB libbfd headers for that version, instead of compiling in the version agnostic bfd-wrapper.c.
Careful: the official FB standalone (linux/win32/dos) setups contain a libbfd.a 2.17, which will typically not match the bfd.h/libbfd.a/.so on the system. When boostrapping/building the compiler with such an FB setup you should use ENABLE_FBBFD=217. Here, using the default bfd-wrapper.c (compiling against bfd.h, but linking with an incompatible libbfd.a) is wrong. As an alternative it's possible to overwrite FB's libbfd.a with the one from the system, to make the libbfd.a against which the compiler will be linked match bfd.h.
Normally though, when building the compiler with an FB setup that does not come with its own libbfd.a, it's preferable to use the bfd-wrapper.c to use the system's libbfd. This is the case when bootstrapping/building the compiler using the normal non-standalone FB setup.
The way to avoid all the libbfd trouble is to use DISABLE_OBJINFO.
This is typically caused by libbfd header/library version mismatches, see above.
%%CC src/rtlib/obj/hinit.o
src/rtlib/win32/hinit.c: In function 'fb_hInit':
src/rtlib/win32/hinit.c:21:5: warning: implicit declaration of function '_controlfp' [-Wimplicit-function-declaration]
src/rtlib/win32/hinit.c:21:17: error: '_PC_64' undeclared (first use in this function)
- [[https://sourceforge.net/tracker/?func=detail&aid=3414086&group_id=2435&atid=102435 MinGW GCC 4.6.1 bug report]]
- [[https://sourceforge.net/tracker/?func=detail&aid=3011968&group_id=2435&atid=302435 MinGW patch tracker, 2010]]
%%CC src/compiler/obj/bfd-wrapper.o
LINK bin/fbc-new.exe
fbc triggers a bug (ld/12614) in the mentioned linker versions causing it to produce broken binaries. It's fixed in binutils 2.21.1 and up.
{{fbdoc item="subsect" value="-lXpm not found on Debian x86_64"}}
The ia32-libs-dev package (for example on Debian 6) for some reason does not contain a /usr/lib32/libXpm.so symlink, even though it does contain those for the other X11 development libraries. This apparently can be fixed by creating the symlink manually:
%%ln -s /usr/lib32/libXpm.so.4 /usr/lib32/libXpm.so
Deletions:
**{{anchor name="PREVIOUS|Previous guides (for compiling FB 0.23 and earlier)"}}**
**{{anchor name="SOURCE|Getting the current source code"}}**
**{{anchor name="SETUP|Setting up the environment"}}**
- **{{anchor name="SETUP_DOS|DOS"}}**
- **{{anchor name="SETUP_LINUX|Linux"}}**
- **{{anchor name="SETUP_WINDOWS|Windows"}}**
**{{anchor name="COMPILE|Compiling FreeBASIC"}}**
**{{anchor name="ALONEDOS|Making a self-contained DOS version (like the FB-dos release)"}}**
**{{anchor name="ALONEWIN32|Making a self-contained Win32 version (like the FB-win32 release)"}}**
**{{anchor name="RECOMPILE|Getting source code updates and recompiling"}}**
**{{anchor name="DEBUG|Recompiling fbc for debugging purposes"}}**
**{{anchor name="CONFIG|Compilation options"}}**
**{{anchor name="PROBLEMS|Known problems"}}**
{{anchor name="PREVIOUS"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 [versions on or before September 20, 2011] and earlier)"}}
{{anchor name="SOURCE"}}{{fbdoc item="section" value="Getting the current source code"}}
Web view of main fbc/fbc repository: http://fbc.git.sourceforge.net/git/gitweb.cgi?p=fbc/fbc;a=summary
Git clone URL: ##""git://fbc.git.sourceforge.net/gitroot/fbc/fbc""##
Github mirror: https://github.com/freebasic/fbc
Git clone URL: ##""https://github.com/freebasic/fbc.git""##
{{anchor name="SETUP"}}{{fbdoc item="section" value="Setting up the environment"}}
The ""FreeBASIC"" compiler is self-hosting, and a working ""FreeBASIC"" installation is needed to compile it, while ##gcc## is needed to compile the ""FreeBASIC"" runtime libraries. It should be possible to compile the current development version of ##fbc## using ""FreeBASIC"" 0.21 or up.
{{anchor name="SETUP_DOS"}}==DOS==
The DOS version of ""FreeBASIC"" is typically compiled on Windows, using a DOS ""FreeBASIC"" and DJGPP. The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/beta/v2/ beta/v2/]]##), but for the others it should be ok to use the ones from DJGPP 2.03 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/current/v2gnu/ current/v2gnu/]]##). Setup DJGPP by extracting everything into ##C:\DJGPP## and adding an environment variable named "DJGPP", set to ##C:\DJGPP\djgpp.env##.
- ##binutils## (##bnu*b.zip##, ##bnu*a.zip##)
- ##bash## (##bsh*.zip##)
- ##djdev## (##djdev*.zip##) - //pick up djdev204.zip or later from the ##beta/## directory//
- ##fileutils## (##fil*.zip##)
- ##gcc## (##gcc*b.zip##)
- ##gpp## (##gpp*b.zip##)
- ##gettext## (##gtxt*b.zip##) - //libintl, for libbfd//
- ##make## (##mak*b.zip##)
- ##shellutils## (##shl*b.zip##)
- ##textutils## (##txt*b.zip##)
- ##zlib## (##zlib*b.zip##) - //zlib, for libbfd, from the ##[[http://www.delorie.com/pub/djgpp/current/v2tk/ current/v2tk/]]## directory//
For example when working in parallel with ""MinGW"", it can be useful to use a batch script to launch a terminal with the DJGPP tools in its PATH environment variable, instead of modifying your system's global PATH environment variable:
%%set DJGPP=C:\DJGPP\djgpp.env
{{anchor name="SETUP_LINUX"}}==Linux==
This assumes a 32bit (x86) Linux system, however it should also be possible to crosscompile the (still only 32bit) ""FreeBASIC"" on a 64bit system, but the steps might be different. Roughly these Debian packages should be needed (with Fedora names in parentheses):
- ##gcc##
- ##""g++""## (##""gcc-c++""##)
- ##binutils##
- ##binutils-dev## (##binutils-devel## or ##binutils-static##) - //libbfd for fbc's objinfo feature//
- ##make##
- ##libncurses-dev## (##ncurses-devel##) - //curses headers for the rtlib//
- ##libx11-dev## (##libX11-devel##) - //X11 headers for gfxlib2//
- ##libxext-dev## (##libXext-devel##)
- ##libxpm-dev## (##libXpm-devel##)
- ##libxrandr-dev## (##libXrandr-devel##)
- ##libxrender-dev## (##libXrender-devel##)
- ##libgpm-dev## (##gpm-devel##) - //General purpose mouse library headers for the rtlib//
- ##freeglut3-dev## (##freeglut-devel##) - //""OpenGL"" headers for gfxlib2//
- ##libffi-dev## (##ffi-devel##) - //foreign function interface for ##[[KeyPgThreadcall ThreadCall]]##//
On 64bit Debian/Ubuntu, these packages should do the trick (To do: test and update):
- ##ia32-libs-dev##
- ##libc6-dev-i386##
- ##gcc-multilib##
- ##""g++-multilib""##
- ##lib32ncurses5-dev##
{{anchor name="SETUP_WINDOWS"}}==Windows==
To install [[http://www.mingw.org MinGW/MSYS]], download the latest version of the [[http://sourceforge.net/projects/mingw/files/Installer/mingw-get/ mingw-get program]] and extract it into ##""C:\MinGW""##. After that open a command prompt (cmd.exe) and run:
%%cd C:\MinGW\bin
mingw-get update
mingw-get upgrade
mingw-get install <package-name>
The following packages are needed:
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-g++]]## (only needed to get ""libsupc++.a"")
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/ binutils]]## (binutils, and binutils-dev for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/ w32api]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gettext/ gettext-dev]]## (libintl for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/ msys-findutils]]## (xargs for running the test suite)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/make/ msys-make]]##
After installing, you can open a ""MinGW"" shell (MSYS bash) by running ##""C:\MinGW\msys\1.0\msys.bat""## (you can create a shortcut to it too).
To use ""MinGW/MSYS"" programs from other shells (for example the cmd.exe command prompt), add both ##""C:\MinGW\bin""## and ##""C:\MinGW\msys\1.0\bin""## to the system's global PATH environment variable.
To update an existing ""MinGW/MSYS"" installation:
%%mingw-get update
mingw-get upgrade
mingw-get upgrade <package-name>
In order to compile ""FreeBASIC""'s gfxlib2, ""DirectX"" headers are needed in ##C:\""MinGW""\include##, specifically ##ddraw.h## and ##dinput.h##. You can get the headers from here: [[http://alleg.sourceforge.net/files/dx80_mgw.zip]]
Note: It is most likely also possible to use other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]], since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases, and is currently preferred because it's configured for setjump/longjump exception handling rather than dwarf2, making its libraries and thus FB programs smaller. To use FB with TDM-GCC, compile with the ENABLE_TDMGCC makefile option.
{{anchor name="COMPILE"}}{{fbdoc item="section" value="Compiling FreeBASIC"}}
By default the compilation process creates a compiler that is intended to be installed into a unix-like directory tree such as ##/usr## or ##/usr/local## on Linux, or ##""C:\MinGW""## for the Windows version, or ##C:\DJGPP## for the DOS version.
To compile ""FreeBASIC"", open a terminal (command prompt) and change to directory containing the ""FreeBASIC"" source code, then run:
%%make%%
The newly built compiler and run-time libraries will be placed in a build directory called ##new/##. This is a basically valid ""FreeBASIC"" installation, allowing it to be tested immediately, although on DOS and Windows there are additional steps necessary to get a fully working ""FreeBASIC"" tree.
To install into ##/usr/local## on Linux:
%%make install%%
To install into ##""C:\MinGW""## on Windows:
%%make install prefix=c:/mingw%%
To install the DOS version:
1) %%make install prefix=c:/djgpp%%
1) Copy the modified ##libc.a## from the latest ""FreeBASIC-dos"" release into ##C:\DJGPP\lib\freebas##
{{anchor name="ALONEDOS"}}{{fbdoc item="section" value="Making a self-contained DOS version (like the FB-dos release)"}}
The DOS version is typically compiled using DJGPP on Windows. Assuming the source code is in ##C:\fbc##:
%%cd c:/fbc
make clean
# (This is added to config.mk so you don't have to retype it for every 'make' or 'make clean' etc.)
echo "ENABLE_STANDALONE=1" > config.mk
make clean
make
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
1) Copy to ##""C:\fbc\new\bin""##:
- ##C:\DJGPP\bin\{ar,as,ld}.exe##
1) Copy to ##""C:\fbc\new\lib""##:
- ##C:\DJGPP\lib\{crt0,gcrt0}.o##
- ##C:\DJGPP\lib\lib{emu,m}.a##
- ##C:\DJGPP\lib\gcc\djgpp\version\lib{gcc,supcxx}.a##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
- ##C:\DJGPP\lib\lib{bfd,iberty,intl,z}.a## //(For recompiling ""FreeBASIC"" using this tree)//
- The modified ##libc.a## from the latest ""FreeBASIC"" release //(Note: To use the libc.a from DJGPP, the _main.o it contains needs to be replaced with the one compiled from ##contrib/djgpp/libc/crt0/_main.c## from the fbc source code, to fix a bug in the original version from DJGPP)//
- and any additional libraries you want to use
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{anchor name="ALONEWIN32"}}{{fbdoc item="section" value="Making a self-contained Win32 version (like the FB-win32 release)"}}
Assuming the source code is in ##C:\fbc##:
%%cd /c/fbc
make clean
# (This is added to config.mk so you don't have to retype it for every 'make' or 'make clean' etc.)
echo "ENABLE_STANDALONE=1" > config.mk
make clean
make
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
1) Copy to ##""C:\fbc\new\bin""##:
- ##""C:\MinGW\bin\{ar,as,dlltool,ld}.exe""##
- ##""GoRC.exe""## (from [[http://www.godevtool.com/]] or the previous ""FreeBASIC"" release)
1) Copy to ##""C:\fbc\new\lib""##:
- ##""C:\MinGW\lib\{crt2,dllcrt2,gcrt2}.o""##
- ##""C:\MinGW\lib\lib{gmon,mingw32,mingwex,moldname}.a""##
- ##""C:\MinGW\lib\gcc\mingw32\version\{crtbegin,crtend}.o""##
- ##""C:\MinGW\lib\gcc\mingw32\version\lib{gcc,supc++}.a""##
- ##""C:\MinGW\lib\lib{advapi32,gdi32,kernel32,msvcrt,user32,winmm,winspool}.a""## //(Rename to ##lib*.dll.a## if preferred)//
- ##""C:\MinGW\lib\lib{bfd,iberty,intl}.a""## //(For recompiling ""FreeBASIC"" using this tree)//
- and any additional libraries you want to use
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{anchor name="RECOMPILE"}}{{fbdoc item="section" value="Getting source code updates and recompiling"}}
%%git pull%%
%%
# Update remote branches
Rebuilding is as easy as:
%%make%%
Note: If compilation options (like ENABLE_STANDALONE) were used for the previous build, it's necessary to specify them again this time. If they are set in ##config.mk## then they will be automatically set again.
{{anchor name="DEBUG"}}{{fbdoc item="section" value="Recompiling fbc for debugging purposes"}}
%%make clean-compiler
make FBFLAGS=-exx%%
{{anchor name="CONFIG"}}{{fbdoc item="section" value="Compilation options"}}
There are several compilation options that can be specified to the FB makefile via command line or inside a config.mk file that the makefile #includes. See also ##make help## for a full list. Many of these are intended for developing.
- ##FBFLAGS='-g -exx'##
Sets extra options to be used when compiling fbc, for example to build a debug fbc.
- ##CFLAGS='-g -O0'##
Sets extra options that are used when compiling rtlib and gfxlib2.
- ##new=new-foo##
Change the build directory name. The default is ##new/##. This can be used to make multiple builds in one source tree.
- ##prefix=c:/mingw##
Changes the /usr/local prefix to something else. Note: MSYS maps ##/usr/local## to ##C:\msys\1.0\local##.
- ##TARGET=i686-pc-mingw32##
To cross-compile the compiler and/or the runtime libraries to run on the specified host system. The system name will be inserted into the lib/ or lib/freebasic/ directory name to allow installing multiple target-specific FB runtimes in parallel.

For example, on a Debian GNU/Linux system with the i586-mingw32msvc-gcc cross-compiler installed, it's possible to cross-compile a win32 FB like this:
%%# Build the win32 runtime (gfxlib2 is not needed for the compiler, but for other FB programs)
make rtlib TARGET=i586-mingw32msvc
make gfxlib2 TARGET=i586-mingw32msvc
# Install it
make install TARGET=i586-mingw32msvc
# Then the win32 fbc (linking against the just built win32 runtime)
make compiler TARGET=i586-mingw32msvc
- ##SUFFIX=foo##
Append a suffix to the fbc executable's and lib/ directories' names. This allows installing multiple versions of compiler and runtime in parallel. Note: The include/ directory name is not affected, and the FB headers are always shared by all installed FB versions (FB's headers and their directory layouts are designed to be able to do that).
- ##SUFFIX2=foo##
Similar to ##SUFFIX##, except that this is a second suffix that will only be added to fbc executable's name, allowing to install multiple fbcs in parallel, but have them all use the same set of runtime libraries. Useful to quickly test changes to the compiler, without overwriting the stable fbc or having to rebuilt the runtime libraries.
- ##ENABLE_STANDALONE=1##
Intended for building self-contained installations (like the win32/dos FB releases), where fbc.exe is located in the toplevel directory, instead of bin/. This also changes some behavior in the compiler, and affects the include/ and lib/ directory layout.
- ##ENABLE_PREFIX=1##
Allows hard-coding the ##prefix## into the compiler, instead of letting it use exepath() to be relocatable.
- ##ENABLE_FBBFD=217##
Makes fbc use FB ##bfd.bi## headers to use libbfd directly, instead of using a wrapper around the system's original ##bfd.h##. The specified version must match the version of the libbfd that this fbc will be linked with (because the libbfd ABI is very unstable).
- ##DISABLE_OBJINFO=1##
If specified fbc will not use libbfd at all, at the cost of the [[DevObjinfo objinfo feature]] being disabled. This is useful in environments (e.g. Debian unstable) where the shared libbfd is updated frequently, as fbc will no longer depend on a specific libbfd version/soname.
- ##ENABLE_TDMGCC=1## (win32 only)
This causes FB to be built for TDM-GCC rather than the mingw.org GCC. Currently the only difference this makes is that when built for TDM-GCC, fbc doesn't try to link in libgcc_eh into FB programs.
{{anchor name="PROBLEMS"}}{{fbdoc item="section" value="Known problems"}}
%%CC new/libfb/hinit_win32.o
rtlib/hinit_win32.c: In function 'fb_hInit':
rtlib/hinit_win32.c:21:5: warning: implicit declaration of function '_controlfp' [-Wimplicit-function-declaration]
rtlib/hinit_win32.c:21:17: error: '_PC_64' undeclared (first use in this function)
- ""MinGW GCC 4.6.1 bug report"": https://sourceforge.net/tracker/?func=detail&aid=3414086&group_id=2435&atid=102435
- ""MinGW patch tracker, 2010"": https://sourceforge.net/tracker/?func=detail&aid=3011968&group_id=2435&atid=302435
%%CC new/compiler/bfd-wrapper.o
LINK new/bin/fbc.exe
This is typically caused by libbfd header/library version mismatches. Note that FB 0.23 dos/win32/linux-standalone comes with libbfd.a 2.17, while the system's libbfd.a/bfd.h probably is a much later version (for example 2.21). There are three ways to handle this situation:
- Use ##ENABLE_FBBFD=217## to compile against libbfd 2.17 headers instead of the system's bfd.h (and make sure to link against libbfd.a 2.17)
- Replace FB's libbfd.a by the one from the system
- Use ##DISABLE_OBJINFO=1## to avoid libbfd completely
fbc triggers a bug in the mentioned linker versions causing it to produce broken binaries. It's fixed in binutils 2.21.1 and up.


Revision [16187]

Edited on 2012-05-26 19:41:59 by CountingPine [Add anchors for OS-specific setup instructions]
Additions:
- **{{anchor name="SETUP_WINDOWS|Windows"}}**
Deletions:
- **{{anchor name="SETUP_WIN32|Windows"}}**


Revision [16186]

Edited on 2012-05-26 19:41:39 by CountingPine [Add anchors for OS-specific setup instructions]
Additions:
- **{{anchor name="SETUP_DOS|DOS"}}**
- **{{anchor name="SETUP_LINUX|Linux"}}**
- **{{anchor name="SETUP_WIN32|Windows"}}**
{{anchor name="SETUP_DOS"}}==DOS==
{{anchor name="SETUP_LINUX"}}==Linux==
{{anchor name="SETUP_WINDOWS"}}==Windows==
Deletions:
==DOS==
==Linux==
==Windows==


Revision [15733]

Edited on 2012-01-18 07:56:18 by DkLwikki [Remove freebasic-headers links]
Deletions:
1) Copy to ##""C:\fbc\new\include""##:
- any headers you want to use, from [[http://code.google.com/p/freebasic-headers/ freebasic-headers]] or the previous ""FreeBASIC"" release, etc.
1) Copy to ##""C:\fbc\new\include""##:
- any headers you want to use, from [[http://code.google.com/p/freebasic-headers/ freebasic-headers]] or the previous ""FreeBASIC"" release, etc.


Revision [15684]

Edited on 2012-01-16 02:16:01 by SirMud [Remove freebasic-headers links]
Additions:
{{fbdoc item="back" value="DevToc|FreeBASIC Developer Information"}}


Revision [15659]

Edited on 2012-01-15 09:10:48 by DkLwikki [Update MinGW links]
Additions:
To install [[http://www.mingw.org MinGW/MSYS]], download the latest version of the [[http://sourceforge.net/projects/mingw/files/Installer/mingw-get/ mingw-get program]] and extract it into ##""C:\MinGW""##. After that open a command prompt (cmd.exe) and run:
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/ gcc-g++]]## (only needed to get ""libsupc++.a"")
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/ binutils]]## (binutils, and binutils-dev for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/ w32api]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/Base/gettext/ gettext-dev]]## (libintl for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/ msys-findutils]]## (xargs for running the test suite)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/Base/make/ msys-make]]##
Deletions:
To install [[http://www.mingw.org MinGW/MSYS]], download the latest version of the [[https://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/ mingw-get program]] and extract it into ##""C:\MinGW""##. After that open a command prompt (cmd.exe) and run:
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-g++]]## (only needed to get ""libsupc++.a"")
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GNU-Binutils/ binutils]]## (binutils, and binutils-dev for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/Win32-API/ w32api]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/gettext/ gettext-dev]]## (libintl for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/findutils/ msys-findutils]]## (xargs for running the test suite)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/make/ msys-make]]##


Revision [15642]

Edited on 2012-01-12 15:46:33 by DkLwikki [Update for TARGET and ENABLE_TDMGCC]
Additions:
Note: It is most likely also possible to use other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]], since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases, and is currently preferred because it's configured for setjump/longjump exception handling rather than dwarf2, making its libraries and thus FB programs smaller. To use FB with TDM-GCC, compile with the ENABLE_TDMGCC makefile option.
Deletions:
Note: It is most likely also possible to use other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]], since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases, and is currently preferred because it's configured for setjump/longjump exception handling rather than dwarf2, making its libraries and thus FB programs smaller.


Revision [15641]

Edited on 2012-01-12 15:42:22 by DkLwikki [Update for TARGET and ENABLE_TDMGCC]
Additions:
Note: It is most likely also possible to use other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]], since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases, and is currently preferred because it's configured for setjump/longjump exception handling rather than dwarf2, making its libraries and thus FB programs smaller.
To cross-compile the compiler and/or the runtime libraries to run on the specified host system. The system name will be inserted into the lib/ or lib/freebasic/ directory name to allow installing multiple target-specific FB runtimes in parallel.

For example, on a Debian GNU/Linux system with the i586-mingw32msvc-gcc cross-compiler installed, it's possible to cross-compile a win32 FB like this:
%%# Build the win32 runtime (gfxlib2 is not needed for the compiler, but for other FB programs)
make rtlib TARGET=i586-mingw32msvc
make gfxlib2 TARGET=i586-mingw32msvc
# Install it
make install TARGET=i586-mingw32msvc
# Then the win32 fbc (linking against the just built win32 runtime)
make compiler TARGET=i586-mingw32msvc
- ##ENABLE_TDMGCC=1## (win32 only)
This causes FB to be built for TDM-GCC rather than the mingw.org GCC. Currently the only difference this makes is that when built for TDM-GCC, fbc doesn't try to link in libgcc_eh into FB programs.
Deletions:
Note: It is most likely also possible to use other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]], since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases.
- ##HOST=i686-pc-mingw32##
To cross-compile an fbc that will run on the specified host. fbc will default to compiling for its HOST. The FB runtime will also be cross-compiled to run on this host, unless TARGET is used to override that.
To cross-compile the FB runtime libraries to run on the specified target. The target name will be inserted into the lib/ or lib/freebasic/ directory name to allow installing multiple target-specific FB runtimes in parallel. Note: TARGET does not affect the compiler, which always has all targets enabled, and always defaults to compiling for its HOST.


Revision [15605]

Edited on 2012-01-03 09:14:33 by AgAmemnus [Update for TARGET and ENABLE_TDMGCC]
Additions:
{{anchor name="PREVIOUS"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 [versions on or before September 20, 2011] and earlier)"}}
The current source (""FreeBASIC"" 0.24 [versions after September 20, 2011]) is available from these Git repositories:
Deletions:
{{anchor name="PREVIOUS"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 (not SVN!) and earlier)"}}
The current source (""FreeBASIC"" 0.24 [versions after August 6 2011]) is available from these Git repositories:


Revision [15604]

Edited on 2012-01-03 09:13:20 by AgAmemnus [Update for TARGET and ENABLE_TDMGCC]
Additions:
{{anchor name="PREVIOUS"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 (not SVN!) and earlier)"}}
The current source (""FreeBASIC"" 0.24 [versions after August 6 2011]) is available from these Git repositories:
Deletions:
{{anchor name="PREVIOUS"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 and earlier)"}}
The current source (""FreeBASIC"" 0.24) is available from these Git repositories:


Revision [15600]

Edited on 2012-01-02 22:11:39 by AgAmemnus [Update for TARGET and ENABLE_TDMGCC]
Additions:
(Typical usage after installation: "git clone git://...")


Revision [15566]

Edited on 2011-12-16 07:50:19 by DkLwikki [Update descriptions of several makefile variables]
Additions:
To cross-compile an fbc that will run on the specified host. fbc will default to compiling for its HOST. The FB runtime will also be cross-compiled to run on this host, unless TARGET is used to override that.
Append a suffix to the fbc executable's and lib/ directories' names. This allows installing multiple versions of compiler and runtime in parallel. Note: The include/ directory name is not affected, and the FB headers are always shared by all installed FB versions (FB's headers and their directory layouts are designed to be able to do that).
Similar to ##SUFFIX##, except that this is a second suffix that will only be added to fbc executable's name, allowing to install multiple fbcs in parallel, but have them all use the same set of runtime libraries. Useful to quickly test changes to the compiler, without overwriting the stable fbc or having to rebuilt the runtime libraries.
Makes fbc use FB ##bfd.bi## headers to use libbfd directly, instead of using a wrapper around the system's original ##bfd.h##. The specified version must match the version of the libbfd that this fbc will be linked with (because the libbfd ABI is very unstable).
Deletions:
To cross-compile an fbc that will run on the specified host.
Append a suffix to the fbc executable's and include/ and lib/ directories' names. This allows installing multiple versions of FB in parallel.
Similar to ##SUFFIX##, except that this is a second suffix that will only be added to fbc executable's name, allowing to install multiple fbcs in parallel, but have them all use the same set of runtime libraries.
Makes fbc use FB libbfd headers to use libbfd directly, instead of using a wrapper around the system's original ##bfd.h##. The specified version must match the version of the libbfd that this fbc will be linked with (because the libbfd ABI is very unstable).


Revision [15565]

Edited on 2011-12-16 07:37:16 by DkLwikki [Adjust TARGET description to 0.24 updates]
Additions:
To cross-compile the FB runtime libraries to run on the specified target. The target name will be inserted into the lib/ or lib/freebasic/ directory name to allow installing multiple target-specific FB runtimes in parallel. Note: TARGET does not affect the compiler, which always has all targets enabled, and always defaults to compiling for its HOST.
Deletions:
Allows building a cross-fbc that defaults to compiling for the specified target. rtlib and gfxlib2 will be compiled to run on this target. The target will be prefixed to the fbc executable name and include/lib directories.


Revision [15548]

Edited on 2011-12-12 14:19:40 by CountingPine [Add libffi-dev dependency (untested libffi-devel for fedora)]
Additions:
- ##libffi-dev## (##ffi-devel##) - //foreign function interface for ##[[KeyPgThreadcall ThreadCall]]##//


Revision [15508]

Edited on 2011-11-09 16:58:55 by DkLwikki [Mention libintl and zlib as requirement for libbfd on DJGPP]
Additions:
- ##gettext## (##gtxt*b.zip##) - //libintl, for libbfd//
- ##zlib## (##zlib*b.zip##) - //zlib, for libbfd, from the ##[[http://www.delorie.com/pub/djgpp/current/v2tk/ current/v2tk/]]## directory//


Revision [15500]

Edited on 2011-11-04 15:18:05 by DkLwikki [Use DocToc as parent]
Additions:
{{fbdoc item="back" value="DocToc|Table of Contents"}}
Deletions:
{{fbdoc item="back" value="DevToc|Table of Contents"}}


Revision [15485]

Edited on 2011-11-02 14:58:38 by DkLwikki [Update (c-objinfo module was renamed to bfd-wrapper)]
Additions:
%%CC new/compiler/bfd-wrapper.o
This happens when fbc's C libbfd wrapper module (##bfd-wrapper.c##) is used and compiled with a modern GCC (such as GCC 4.5.x, 2010), and the new fbc.exe is being linked by the old ld 2.15 (2005) from the current ""FreeBASIC-win32"" releases. The old ld complains about not knowing some sections that were added to later binutils.
Deletions:
%%CC new/compiler/c-objinfo.o
This happens when fbc's C libbfd wrapper module (##c-objinfo.c##) is used and compiled with a modern GCC (such as GCC 4.5.x, 2010), and the new fbc.exe is being linked by the old ld 2.15 (2005) from the current ""FreeBASIC-win32"" releases. The old ld complains about not knowing some sections that were added to later binutils.


Revision [15477]

Edited on 2011-10-31 07:22:37 by DkLwikki [Update libbfd known problem -- not just MinGW]
Additions:
This is typically caused by libbfd header/library version mismatches. Note that FB 0.23 dos/win32/linux-standalone comes with libbfd.a 2.17, while the system's libbfd.a/bfd.h probably is a much later version (for example 2.21). There are three ways to handle this situation:
- Use ##ENABLE_FBBFD=217## to compile against libbfd 2.17 headers instead of the system's bfd.h (and make sure to link against libbfd.a 2.17)
- Replace FB's libbfd.a by the one from the system
Deletions:
This is typically caused by libbfd header/library version mismatches. Note that FB 0.23 comes with libbfd.a 2.17, while ""MinGW's"" libbfd.a/bfd.h probably is version 2.21.1 or similar. There are three ways to handle this situation:
- Use ##ENABLE_FBBFD=217## to compile against libbfd 2.17 headers instead of ""MinGW's"" bfd.h
- Replace FB 0.23's libbfd.a by the one from ""MinGW""


Revision [15460]

Edited on 2011-10-20 13:58:23 by DkLwikki [Fix CamelCase links]
Additions:
This happens when fbc's C libbfd wrapper module (##c-objinfo.c##) is used and compiled with a modern GCC (such as GCC 4.5.x, 2010), and the new fbc.exe is being linked by the old ld 2.15 (2005) from the current ""FreeBASIC-win32"" releases. The old ld complains about not knowing some sections that were added to later binutils.
This is not known to cause any issue besides the warning, and can be solved by replacing the old ld.exe in the ""FreeBASIC-win32"" installation by a newer one from ""MinGW"".
Deletions:
This happens when fbc's C libbfd wrapper module (##c-objinfo.c##) is used and compiled with a modern GCC (such as GCC 4.5.x, 2010), and the new fbc.exe is being linked by the old ld 2.15 (2005) from the current FreeBASIC-win32 releases. The old ld complains about not knowing some sections that were added to later binutils.
This is not known to cause any issue besides the warning, and can be solved by replacing the old ld.exe in the FreeBASIC-win32 installation by a newer one from MinGW.


Revision [15459]

Edited on 2011-10-20 13:57:17 by DkLwikki [Fix formatting]
Additions:
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-g++]]## (only needed to get ""libsupc++.a"")
Deletions:
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-g++]]## (only needed to get libsupc++.a)


Revision [15458]

Edited on 2011-10-20 13:56:14 by DkLwikki [Test suite needs xargs from msys-findutils]
Additions:
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/findutils/ msys-findutils]]## (xargs for running the test suite)


Revision [15457]

Edited on 2011-10-20 11:23:51 by DkLwikki [MinGW's libbfd needs libintl from gettext-dev]
Additions:
The DOS version of ""FreeBASIC"" is typically compiled on Windows, using a DOS ""FreeBASIC"" and DJGPP. The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/beta/v2/ beta/v2/]]##), but for the others it should be ok to use the ones from DJGPP 2.03 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/current/v2gnu/ current/v2gnu/]]##). Setup DJGPP by extracting everything into ##C:\DJGPP## and adding an environment variable named "DJGPP", set to ##C:\DJGPP\djgpp.env##.
For example when working in parallel with ""MinGW"", it can be useful to use a batch script to launch a terminal with the DJGPP tools in its PATH environment variable, instead of modifying your system's global PATH environment variable:
mingw-get install <package-name>
The following packages are needed:
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-g++]]## (only needed to get libsupc++.a)
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GNU-Binutils/ binutils]]## (binutils, and binutils-dev for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/Win32-API/ w32api]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/gettext/ gettext-dev]]## (libintl for libbfd)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/bash/ bash]]## (terminal/shell)
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/coreutils/ msys-coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/make/ msys-make]]##
After installing, you can open a ""MinGW"" shell (MSYS bash) by running ##""C:\MinGW\msys\1.0\msys.bat""## (you can create a shortcut to it too).
Note: It is most likely also possible to use other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]], since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases.
Deletions:
The DOS version of ""FreeBASIC"" is typically compiled on Windows, using a DOS ""FreeBASIC"" and DJGPP. The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/beta/v2/ beta/v2/]]##), but for the others it should be ok to use the ones from DJGPP 2.03 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/current/v2gnu/ current/v2gnu/]]##).
Setup DJGPP by extracting everything into ##C:\DJGPP## and adding an environment variable named "DJGPP", set to ##C:\DJGPP\djgpp.env##. Assuming your DOS ""FreeBASIC"" is installed at ##C:\FBDOS##, you can use the following ##djgpp.bat## script to get a "DJGPP-terminal", from which you can work, instead of modifying your system's global PATH environment variable:
It adds ##C:\DJGPP\bin## to its PATH, so that ##gcc## maps to ##C:\DJGPP\bin\gcc.exe## (ditto for the binutils). As long as there is no conflict with other gccs/binutils in the global PATH (such as ""MinGW""), then of course you can make DJGPP global too, including the DOS ""FreeBASIC"".
mingw-get install gcc-core gcc-g++ binutils mingwrt w32api msys-core bash msys-coreutils msys-make
To open a ""MinGW"" shell (MSYS bash), run ##""C:\MinGW\msys\1.0\msys.bat""## (you can create a shortcut to it too).
__//Manually downloading the needed ""MinGW"" packages from [[http://sourceforge.net/projects/mingw/files]]//__
""FreeBASIC"" needs mostly the core packages only, see [[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/ MinGW BaseSystem]] and [[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/ MSYS BaseSystem]]. The archives to download are typically called ##*-*-*-mingw32-bin.tar.lzma## and ##lib*-*-*-mingw32-dll-*.tar.lzma## (similar for MSYS) and can be extracted using [[http://www.7-zip.org/ 7-zip]].

//""MinGW"" (binutils, GCC, ""Win32"" SDK)//
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-core, gcc-g++]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GNU-Binutils/ binutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/Win32-API/ w32api]]##
//MSYS (Unixy shell environment, make)//
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/bash/ bash]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/coreutils/ coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/make/ make]]##
__//Using other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]]//__
It should generally be possible to use non-mingw.org GCCs, since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases.


Revision [15395]

Edited on 2011-10-10 02:22:20 by DkLwikki [Add known problems section]

No Differences

Revision [15394]

Edited on 2011-10-10 02:20:40 by DkLwikki [Add known problems section]
Additions:
**{{anchor name="PROBLEMS|Known problems"}}**
{{anchor name="PROBLEMS"}}{{fbdoc item="section" value="Known problems"}}
{{fbdoc item="subsect" value="Win32 rtlib compilation error: _controlfp, _PC_64 undeclared"}}
%%CC new/libfb/hinit_win32.o
rtlib/hinit_win32.c: In function 'fb_hInit':
rtlib/hinit_win32.c:21:5: warning: implicit declaration of function '_controlfp' [-Wimplicit-function-declaration]
rtlib/hinit_win32.c:21:17: error: '_PC_64' undeclared (first use in this function)
Both the ""MinGW runtime"" and ""MinGW GCC"" have a ##float.h## header, and in some setups the GCC one is found before the ""MinGW"" one, causing the above errors. This issue shows up with some ""MinGW"" setups, for example gcc-core-4.6.1 + mingwrt-3.20, while for example gcc-core-4.5.2 + mingwrt-3.18 (a previous installation made with mingw-get) works fine. This problem also shows up with mingw32 cross compiler on Debian (gcc 4.4.4, mingwrt 3.13).
Easiest temporary fix: Append ###include_next <float.h>## to ##""C:\MinGW\lib\gcc\mingw32\version\include\float.h""##
See also:
- The comments at the top of ##""C:\MinGW\include\float.h""##
- ""MinGW GCC 4.6.1 bug report"": https://sourceforge.net/tracker/?func=detail&aid=3414086&group_id=2435&atid=102435
- ""MinGW patch tracker, 2010"": https://sourceforge.net/tracker/?func=detail&aid=3011968&group_id=2435&atid=302435
- http://lists.nongnu.org/archive/html/mingw-cross-env-list/2010-06/msg00038.html
- http://gcc.gnu.org/ml/gcc-patches/2010-01/msg01034.html
- https://sourceforge.net/mailarchive/message.php?msg_id=28122574
{{fbdoc item="subsect" value="Warning: .drectve ... unrecognized when linking fbc"}}
%%CC new/compiler/c-objinfo.o
LINK new/bin/fbc.exe
Warning: .drectve `-aligncomm:"_FB_bfd_format",2 '
Warning: .drectve `-aligncomm:"_FB_bfd_architecture",2' unrecognized
This happens when fbc's C libbfd wrapper module (##c-objinfo.c##) is used and compiled with a modern GCC (such as GCC 4.5.x, 2010), and the new fbc.exe is being linked by the old ld 2.15 (2005) from the current FreeBASIC-win32 releases. The old ld complains about not knowing some sections that were added to later binutils.
This is not known to cause any issue besides the warning, and can be solved by replacing the old ld.exe in the FreeBASIC-win32 installation by a newer one from MinGW.
{{fbdoc item="subsect" value="Newly built fbc crashes inside a bfd_*() function from libbfd"}}
This is typically caused by libbfd header/library version mismatches. Note that FB 0.23 comes with libbfd.a 2.17, while ""MinGW's"" libbfd.a/bfd.h probably is version 2.21.1 or similar. There are three ways to handle this situation:
- Use ##ENABLE_FBBFD=217## to compile against libbfd 2.17 headers instead of ""MinGW's"" bfd.h
- Replace FB 0.23's libbfd.a by the one from ""MinGW""
- Use ##DISABLE_OBJINFO=1## to avoid libbfd completely
{{fbdoc item="subsect" value="MinGW binutils ld versions 2.18 to 2.21"}}
fbc triggers a bug in the mentioned linker versions causing it to produce broken binaries. It's fixed in binutils 2.21.1 and up.


Revision [15393]

Edited on 2011-10-10 02:09:09 by DkLwikki [Fix typo]
Additions:
If you need help with installing or using Git, search the web or check out the few [[Git Git tips here]].
Deletions:
If you need help with installing or using Git, search the web and take at a few [[Git Git tips here]].


Revision [15392]

Edited on 2011-10-10 02:07:33 by DkLwikki [Split up the compilation section into multiple toplevel sections]
Additions:
**{{anchor name="ALONEDOS|Making a self-contained DOS version (like the FB-dos release)"}}**
**{{anchor name="ALONEWIN32|Making a self-contained Win32 version (like the FB-win32 release)"}}**
**{{anchor name="RECOMPILE|Getting source code updates and recompiling"}}**
**{{anchor name="DEBUG|Recompiling fbc for debugging purposes"}}**
{{anchor name="ALONEDOS"}}{{fbdoc item="section" value="Making a self-contained DOS version (like the FB-dos release)"}}
The DOS version is typically compiled using DJGPP on Windows. Assuming the source code is in ##C:\fbc##:
%%cd c:/fbc
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
- ##C:\DJGPP\lib\gcc\djgpp\version\lib{gcc,supcxx}.a##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{anchor name="ALONEWIN32"}}{{fbdoc item="section" value="Making a self-contained Win32 version (like the FB-win32 release)"}}
Assuming the source code is in ##C:\fbc##:
%%cd /c/fbc
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
- ##""C:\MinGW\lib\gcc\mingw32\version\{crtbegin,crtend}.o""##
- ##""C:\MinGW\lib\gcc\mingw32\version\lib{gcc,supc++}.a""##
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{anchor name="RECOMPILE"}}{{fbdoc item="section" value="Getting source code updates and recompiling"}}
To download updates made available in the fbc Git repository, you can do a pull, either using your preferred graphical Git tool, or in a terminal:
%%git pull%%
To take a look at incoming changes //before// applying them, do this:
%%
Rebuilding is as easy as:
Note: If compilation options (like ENABLE_STANDALONE) were used for the previous build, it's necessary to specify them again this time. If they are set in ##config.mk## then they will be automatically set again.
{{anchor name="DEBUG"}}{{fbdoc item="section" value="Recompiling fbc for debugging purposes"}}
%%make clean-compiler
Deletions:
{{fbdoc item="subsect" value="Building a standalone DOS version while on Windows, like the FreeBASIC-dos releases"}}
Assuming the source code is in ##C:\fbc##:
%%cd c:/fbc
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
- ##C:\DJGPP\lib\gcc\djgpp\<version>\lib{gcc,supcxx}.a##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{fbdoc item="subsect" value="Building a standalone Windows version, like the FreeBASIC-win32 releases"}}
Assuming the source code is in ##C:\fbc##:
%%cd /c/fbc
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
- ##""C:\MinGW\lib\gcc\mingw32\<version>\{crtbegin,crtend}.o""##
- ##""C:\MinGW\lib\gcc\mingw32\<version>\lib{gcc,supc++}.a""##
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{fbdoc item="subsect" value="Getting source code updates and recompiling"}}
To download updates made available in the fbc Git repository, you can do a pull, either using your preferred graphical Git tool, or in a terminal:
%%git pull%%
To take a look at incoming changes //before// applying them, do this:
%%
Rebuilding is as easy as:
%%make%%
Note: If compilation options (like ENABLE_STANDALONE) were used for the previous build, it's necessary to specify them again this time. If they are set in ##config.mk## then they will be automatically set again.
{{fbdoc item="subsect" value="Recompiling fbc for debugging purposes"}}
%%make clean-compiler


Revision [15391]

Edited on 2011-10-09 15:14:25 by DkLwikki [Add more to config section]
Additions:
- ##FBFLAGS='-g -exx'##
Sets extra options to be used when compiling fbc, for example to build a debug fbc.
- ##CFLAGS='-g -O0'##
Sets extra options that are used when compiling rtlib and gfxlib2.
- ##new=new-foo##
Change the build directory name. The default is ##new/##. This can be used to make multiple builds in one source tree.
- ##prefix=c:/mingw##
Changes the /usr/local prefix to something else. Note: MSYS maps ##/usr/local## to ##C:\msys\1.0\local##.
- ##HOST=i686-pc-mingw32##
To cross-compile an fbc that will run on the specified host.
- ##TARGET=i686-pc-mingw32##
Allows building a cross-fbc that defaults to compiling for the specified target. rtlib and gfxlib2 will be compiled to run on this target. The target will be prefixed to the fbc executable name and include/lib directories.
- ##SUFFIX=foo##
Append a suffix to the fbc executable's and include/ and lib/ directories' names. This allows installing multiple versions of FB in parallel.
- ##SUFFIX2=foo##
Similar to ##SUFFIX##, except that this is a second suffix that will only be added to fbc executable's name, allowing to install multiple fbcs in parallel, but have them all use the same set of runtime libraries.
- ##ENABLE_STANDALONE=1##
Intended for building self-contained installations (like the win32/dos FB releases), where fbc.exe is located in the toplevel directory, instead of bin/. This also changes some behavior in the compiler, and affects the include/ and lib/ directory layout.
- ##ENABLE_PREFIX=1##
Allows hard-coding the ##prefix## into the compiler, instead of letting it use exepath() to be relocatable.
- ##ENABLE_FBBFD=217##
Makes fbc use FB libbfd headers to use libbfd directly, instead of using a wrapper around the system's original ##bfd.h##. The specified version must match the version of the libbfd that this fbc will be linked with (because the libbfd ABI is very unstable).
- ##DISABLE_OBJINFO=1##
If specified fbc will not use libbfd at all, at the cost of the [[DevObjinfo objinfo feature]] being disabled. This is useful in environments (e.g. Debian unstable) where the shared libbfd is updated frequently, as fbc will no longer depend on a specific libbfd version/soname.
Deletions:
- ##FBFLAGS='-g -exx'##
Sets extra options to be used when compiling fbc, for example to build a debug fbc.
- ##CFLAGS='-g -O0'##
Sets extra options that are used when compiling rtlib and gfxlib2.
- ##new=new-foo##
Change the build directory name. The default is ##new/##. This can be used to make multiple builds in one source tree.
- ##prefix=c:/mingw##
Changes the /usr/local prefix to something else. Note: MSYS maps ##/usr/local## to ##C:\msys\1.0\local##.
- ##HOST=i686-pc-mingw32##
To cross-compile an fbc that will run on the specified host.
- ##TARGET=i686-pc-mingw32##
Allows building a cross-fbc that defaults to compiling for the specified target. rtlib and gfxlib2 will be compiled to run on this target. The target will be prefixed to the fbc executable name and include/lib directories.
- ##SUFFIX=foo##
Append a suffix to the fbc executable's and include/ and lib/ directories' names. This allows installing multiple versions of FB in parallel.
- ##SUFFIX2=foo##
Similar to ##SUFFIX##, except that this is a second suffix that will only be added to fbc executable's name, allowing to install multiple fbcs in parallel, but have them all use the same set of runtime libraries.
- ##ENABLE_STANDALONE=1##
Intended for building self-contained installations (like the win32/dos FB releases), where fbc.exe is located in the toplevel directory, instead of bin/. This also changes some behavior in the compiler, and affects the include/ and lib/ directory layout.
- ##ENABLE_PREFIX=1##
Allows hard-coding the ##prefix## into the compiler, instead of letting it use exepath() to be relocatable.
- ##ENABLE_FBBFD=217##
Makes fbc use FB libbfd headers to use libbfd directly, instead of using a wrapper around the system's original ##bfd.h##. The specified version must match the version of the libbfd that this fbc will be linked with (because the libbfd ABI is very unstable).
- ##DISABLE_OBJINFO=1##
If specified fbc will not use libbfd at all, at the cost of the [[DevObjinfo objinfo feature]] being disabled. This is useful in environments (e.g. Debian unstable) where the shared libbfd is updated frequently, as fbc will no longer depend on a specific libbfd version/soname.


Revision [15390]

Edited on 2011-10-09 15:12:12 by DkLwikki [Add more to config section]
Additions:
There are several compilation options that can be specified to the FB makefile via command line or inside a config.mk file that the makefile #includes. See also ##make help## for a full list. Many of these are intended for developing.
Sets extra options to be used when compiling fbc, for example to build a debug fbc.
- ##CFLAGS='-g -O0'##
Sets extra options that are used when compiling rtlib and gfxlib2.
- ##new=new-foo##
Change the build directory name. The default is ##new/##. This can be used to make multiple builds in one source tree.
- ##prefix=c:/mingw##
Changes the /usr/local prefix to something else. Note: MSYS maps ##/usr/local## to ##C:\msys\1.0\local##.
- ##HOST=i686-pc-mingw32##
To cross-compile an fbc that will run on the specified host.
- ##TARGET=i686-pc-mingw32##
Allows building a cross-fbc that defaults to compiling for the specified target. rtlib and gfxlib2 will be compiled to run on this target. The target will be prefixed to the fbc executable name and include/lib directories.
- ##SUFFIX=foo##
Append a suffix to the fbc executable's and include/ and lib/ directories' names. This allows installing multiple versions of FB in parallel.
- ##SUFFIX2=foo##
Similar to ##SUFFIX##, except that this is a second suffix that will only be added to fbc executable's name, allowing to install multiple fbcs in parallel, but have them all use the same set of runtime libraries.
Intended for building self-contained installations (like the win32/dos FB releases), where fbc.exe is located in the toplevel directory, instead of bin/. This also changes some behavior in the compiler, and affects the include/ and lib/ directory layout.
- ##ENABLE_PREFIX=1##
Allows hard-coding the ##prefix## into the compiler, instead of letting it use exepath() to be relocatable.
Makes fbc use FB libbfd headers to use libbfd directly, instead of using a wrapper around the system's original ##bfd.h##. The specified version must match the version of the libbfd that this fbc will be linked with (because the libbfd ABI is very unstable).
If specified fbc will not use libbfd at all, at the cost of the [[DevObjinfo objinfo feature]] being disabled. This is useful in environments (e.g. Debian unstable) where the shared libbfd is updated frequently, as fbc will no longer depend on a specific libbfd version/soname.
Deletions:
There are several compilation options that can be specified to the FB makefile via command line or inside a config.mk file that the makefile #includes. See also ##make help## for the full list.
If specified fbc will not use libbfd at all. This can save a lot of trouble, at the cost of the [[DevObjinfo objinfo feature]] being disabled. Problems that have been encountered with fbc + libbfd:
- Corruption and crashes due to libbfd ABI breaks
- fbc not starting due to depending on a shared libbfd with different soname than the one that's installed (different Linux distros have different libbfd versions, each with different soname)
This will result in fbc using FB libbfd headers to use libbfd directly, instead of using the system's C libbfd headers through fbc's default C libbfd wrapper. The FB libbfd header version must be specified, for example ##217##. The libbfd.a that this fbc will be linked with must match this version exactly.
This changes the directory layout expected by the compiler. By default this layout is used:
- ##prefix=path/to/somewhere##
Changes the /usr/local prefix to something else.
Note: MSYS maps ##/usr/local## to ##C:\msys\1.0\local##.
FBFLAGS can be used to specify extra options to be used when compiling fbc, for example to build a debug fbc.


Revision [15389]

Edited on 2011-10-09 14:39:24 by DkLwikki [Separate out Git info]
Additions:
If you need help with installing or using Git, search the web and take at a few [[Git Git tips here]].
Deletions:
==Git on Linux==
Install the ##git## and ##git-gui## packages (might be called different depending on the distro), then clone the repository, resulting in a new fbc/ directory containing the source code:
%%cd ~
ls
git clone git://fbc.git.sourceforge.net/gitroot/fbc/fbc
cd fbc/
git gui &
To get nice anti-aliased fonts in git-gui and gitk on Debian/Ubuntu, you might need to install [[http://www.tcl.tk/ Tcl/Tk]] version 8.5 and enable it explicitly:
%%apt-get install tcl8.5 tk8.5
update-alternatives --config wish
==Linux file explorer integration==
[[http://rabbitvcs.org/ RabbitVCS]] is a useful tool that acts as GUI frontend for several programs such as Git. It can integrate into the Nautilus file explorer much like ""TortoiseSVN"" on Windows. Install the ##rabbitvcs-nautilus## package on Debian/Ubuntu to get it.
==""MsysGit"" on Windows==
Download the latest ##Git-*-preview*.exe## installer from https://code.google.com/p/msysgit/, and install it. The recommended setting for ##core.autocrlf## is ##true##, so that the FB source code in the working tree will have CRLF line endings. By default ""MsysGit"" will add some useful context-menu (right-click menu) entries for directories in the Explorer (it's the git-cheetah shell extension actually).
After the installation, right click on your Desktop or somewhere in the Explorer and select "Git Gui" to bring up the Git Clone window. Here you can enter the Git clone URL of the fbc repository and the directory in which the clone should go. Note: Right-clicking and selecting //Git Gui// on directories that already //are// Git repositories will bring up the git-gui commit tool known from Linux.
Alternatively, you can use the //Git Bash// terminal that comes with ""MsysGit"" and provides a Unixy shell environment based on MSYS, allowing you to work with Git much like you would on Linux. For example, open Git Bash, then:
%%cd /c
ls
git clone git://fbc.git.sourceforge.net/gitroot/fbc/fbc
cd fbc/
git gui &
==""TortoiseGit"" on Windows==
Download the latest version from https://code.google.com/p/tortoisegit/ and install it. It works like ""TortoiseSVN"", i.e. all interaction is done through the Explorer right-click menu.


Revision [15387]

Edited on 2011-10-09 14:31:38 by DkLwikki [Remove mingw script part]
Additions:
%%cd c:/fbc
Deletions:
In the end ""MinGW"" should be installed in ##C:\""MinGW""##, and MSYS in ##C:\""MinGW""\msys\1.0##. You can use a ##mingw.bat## script like the following one to get a """MinGW-terminal"", from which you can work with ""MinGW"" without having to modify your system's global PATH environment variable (this assumes your Windows ""FreeBASIC"" is installed at ##""C:\FreeBASIC""##):
%%set PATH=C:\MinGW\bin;%PATH%
set PATH=C:\MinGW\msys\1.0\bin;%PATH%
set PATH=C:\FreeBASIC;%PATH%
bash --login
Alternatively you can also add both ""MinGW""/MSYS ##bin/## directories to the global PATH and use plain cmd.exe or MSYS' msys.bat. The result should be a terminal (MSYS' console, or cmd.exe command prompt) where ##make##, ##gcc##, ##fbc## and Unixy commands such as ##cp## and ##rm## are working.


Revision [15385]

Edited on 2011-10-07 07:21:09 by DkLwikki [Fix package names for mingw-get]
Additions:
mingw-get install gcc-core gcc-g++ binutils mingwrt w32api msys-core bash msys-coreutils msys-make
Deletions:
mingw-get install bash mingwrt w32api gcc-core gcc-g++ binutils coreutils make msys-core


Revision [15384]

Edited on 2011-10-07 06:23:37 by DkLwikki [Add mingw-get how-to]
Additions:
To open a ""MinGW"" shell (MSYS bash), run ##""C:\MinGW\msys\1.0\msys.bat""## (you can create a shortcut to it too).
To use ""MinGW/MSYS"" programs from other shells (for example the cmd.exe command prompt), add both ##""C:\MinGW\bin""## and ##""C:\MinGW\msys\1.0\bin""## to the system's global PATH environment variable.
Deletions:
To open a ""MinGW"" shell (MSYS bash), run ##C:\MinGW\msys\1.0\msys.bat## (you can create a shortcut to it too).
To use ""MinGW/MSYS"" programs from other shells (for example the cmd.exe command prompt), add both ##C:\MinGW\bin## and ##C:\MinGW\msys\1.0\bin## to the system's global PATH environment variable.


Revision [15383]

Edited on 2011-10-07 06:23:09 by DkLwikki [Add mingw-get how-to]
Additions:
To install [[http://www.mingw.org MinGW/MSYS]], download the latest version of the [[https://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/ mingw-get program]] and extract it into ##""C:\MinGW""##. After that open a command prompt (cmd.exe) and run:
%%cd C:\MinGW\bin
mingw-get update
To open a ""MinGW"" shell (MSYS bash), run ##C:\MinGW\msys\1.0\msys.bat## (you can create a shortcut to it too).
To use ""MinGW/MSYS"" programs from other shells (for example the cmd.exe command prompt), add both ##C:\MinGW\bin## and ##C:\MinGW\msys\1.0\bin## to the system's global PATH environment variable.
To update an existing ""MinGW/MSYS"" installation:
%%mingw-get update
mingw-get upgrade <package-name>
Deletions:
To install [[http://www.mingw.org MinGW/MSYS]], download the [[http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/ Automated (mingw-get based) Installer]] and install the //C compiler//, the //""C++"" compiler// (to get ""libsupc++.a""), and also the //MSYS Basic System//.
__//Updating (or installing) ""MinGW/MSYS"" using the mingw-get//__
If you don't already have it installed (e.g. ""C:\MinGW\bin\mingw-get.exe""), you can [[https://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/ download mingw-get here]]. In a command prompt, run:
%%mingw-get update
To update an existing ""MinGW/MSYS"" installation:
%%mingw-get update
mingw-get upgrade <package-name>%%


Revision [15382]

Edited on 2011-10-07 05:03:12 by DkLwikki [Add mingw-get how-to]

No Differences

Revision [15381]

Edited on 2011-10-07 05:02:47 by DkLwikki [Add mingw-get how-to]
Additions:
To install [[http://www.mingw.org MinGW/MSYS]], download the [[http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/ Automated (mingw-get based) Installer]] and install the //C compiler//, the //""C++"" compiler// (to get ""libsupc++.a""), and also the //MSYS Basic System//.
__//Updating (or installing) ""MinGW/MSYS"" using the mingw-get//__
If you don't already have it installed (e.g. ""C:\MinGW\bin\mingw-get.exe""), you can [[https://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/ download mingw-get here]]. In a command prompt, run:
%%mingw-get update
mingw-get upgrade
mingw-get install bash mingwrt w32api gcc-core gcc-g++ binutils coreutils make msys-core
To update an existing ""MinGW/MSYS"" installation:
%%mingw-get update
mingw-get upgrade
mingw-get upgrade <package-name>%%
Deletions:
To install [[http://www.mingw.org MinGW/MSYS]], download the [[http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/ Automated Installer]] and install the //C compiler//, the //""C++"" compiler// (to get ""libsupc++.a""), and also the //MSYS Basic System//.


Revision [15378]

Edited on 2011-10-06 17:21:58 by DkLwikki [Major update: Git setup, MinGW installation, compiling]
Additions:
**{{anchor name="PREVIOUS|Previous guides (for compiling FB 0.23 and earlier)"}}**
**{{anchor name="SOURCE|Getting the current source code"}}**
**{{anchor name="SETUP|Setting up the environment"}}**
**{{anchor name="COMPILE|Compiling FreeBASIC"}}**
**{{anchor name="CONFIG|Compilation options"}}**
{{anchor name="PREVIOUS"}}{{fbdoc item="section" value="Previous guides (for compiling FB 0.23 and earlier)"}}
{{anchor name="SOURCE"}}{{fbdoc item="section" value="Getting the current source code"}}
The current source (""FreeBASIC"" 0.24) is available from these Git repositories:
Web view of main fbc/fbc repository: http://fbc.git.sourceforge.net/git/gitweb.cgi?p=fbc/fbc;a=summary
Git clone URL: ##""git://fbc.git.sourceforge.net/gitroot/fbc/fbc""##
Github mirror: https://github.com/freebasic/fbc
Git clone URL: ##""https://github.com/freebasic/fbc.git""##
==Git on Linux==
Install the ##git## and ##git-gui## packages (might be called different depending on the distro), then clone the repository, resulting in a new fbc/ directory containing the source code:
%%cd ~
ls
git clone git://fbc.git.sourceforge.net/gitroot/fbc/fbc
cd fbc/
gitk --all
git gui &
%%
To get nice anti-aliased fonts in git-gui and gitk on Debian/Ubuntu, you might need to install [[http://www.tcl.tk/ Tcl/Tk]] version 8.5 and enable it explicitly:

%%apt-get install tcl8.5 tk8.5
update-alternatives --config wish
%%
==Linux file explorer integration==
[[http://rabbitvcs.org/ RabbitVCS]] is a useful tool that acts as GUI frontend for several programs such as Git. It can integrate into the Nautilus file explorer much like ""TortoiseSVN"" on Windows. Install the ##rabbitvcs-nautilus## package on Debian/Ubuntu to get it.
==""MsysGit"" on Windows==
Download the latest ##Git-*-preview*.exe## installer from https://code.google.com/p/msysgit/, and install it. The recommended setting for ##core.autocrlf## is ##true##, so that the FB source code in the working tree will have CRLF line endings. By default ""MsysGit"" will add some useful context-menu (right-click menu) entries for directories in the Explorer (it's the git-cheetah shell extension actually).

After the installation, right click on your Desktop or somewhere in the Explorer and select "Git Gui" to bring up the Git Clone window. Here you can enter the Git clone URL of the fbc repository and the directory in which the clone should go. Note: Right-clicking and selecting //Git Gui// on directories that already //are// Git repositories will bring up the git-gui commit tool known from Linux.

Alternatively, you can use the //Git Bash// terminal that comes with ""MsysGit"" and provides a Unixy shell environment based on MSYS, allowing you to work with Git much like you would on Linux. For example, open Git Bash, then:
%%cd /c
ls
git clone git://fbc.git.sourceforge.net/gitroot/fbc/fbc
cd fbc/
gitk --all
git gui &
%%
==""TortoiseGit"" on Windows==
Download the latest version from https://code.google.com/p/tortoisegit/ and install it. It works like ""TortoiseSVN"", i.e. all interaction is done through the Explorer right-click menu.
{{anchor name="SETUP"}}{{fbdoc item="section" value="Setting up the environment"}}
The DOS version of ""FreeBASIC"" is typically compiled on Windows, using a DOS ""FreeBASIC"" and DJGPP. The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/beta/v2/ beta/v2/]]##), but for the others it should be ok to use the ones from DJGPP 2.03 (DJGPP downloads directory: ##[[http://www.delorie.com/pub/djgpp/current/v2gnu/ current/v2gnu/]]##).
- ##binutils## (##bnu*b.zip##, ##bnu*a.zip##)
- ##bash## (##bsh*.zip##)
- ##djdev## (##djdev*.zip##) - //pick up djdev204.zip or later from the ##beta/## directory//
- ##fileutils## (##fil*.zip##)
- ##gcc## (##gcc*b.zip##)
- ##gpp## (##gpp*b.zip##)
- ##make## (##mak*b.zip##)
- ##shellutils## (##shl*b.zip##)
- ##textutils## (##txt*b.zip##)
Setup DJGPP by extracting everything into ##C:\DJGPP## and adding an environment variable named "DJGPP", set to ##C:\DJGPP\djgpp.env##. Assuming your DOS ""FreeBASIC"" is installed at ##C:\FBDOS##, you can use the following ##djgpp.bat## script to get a "DJGPP-terminal", from which you can work, instead of modifying your system's global PATH environment variable:
%%set DJGPP=C:\DJGPP\djgpp.env
set PATH=C:\FBDOS;%PATH%
This assumes a 32bit (x86) Linux system, however it should also be possible to crosscompile the (still only 32bit) ""FreeBASIC"" on a 64bit system, but the steps might be different. Roughly these Debian packages should be needed (with Fedora names in parentheses):
- ##gcc##
- ##""g++""## (##""gcc-c++""##)
- ##binutils##
- ##binutils-dev## (##binutils-devel## or ##binutils-static##) - //libbfd for fbc's objinfo feature//
- ##libncurses-dev## (##ncurses-devel##) - //curses headers for the rtlib//
- ##libx11-dev## (##libX11-devel##) - //X11 headers for gfxlib2//
- ##libxext-dev## (##libXext-devel##)
- ##libxpm-dev## (##libXpm-devel##)
- ##libxrandr-dev## (##libXrandr-devel##)
- ##libxrender-dev## (##libXrender-devel##)
- ##libgpm-dev## (##gpm-devel##) - //General purpose mouse library headers for the rtlib//
- ##freeglut3-dev## (##freeglut-devel##) - //""OpenGL"" headers for gfxlib2//
On 64bit Debian/Ubuntu, these packages should do the trick (To do: test and update):
- ##ia32-libs-dev##
- ##libc6-dev-i386##
- ##gcc-multilib##
- ##""g++-multilib""##
- ##lib32ncurses5-dev##
To install [[http://www.mingw.org MinGW/MSYS]], download the [[http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/ Automated Installer]] and install the //C compiler//, the //""C++"" compiler// (to get ""libsupc++.a""), and also the //MSYS Basic System//.
In order to compile ""FreeBASIC""'s gfxlib2, ""DirectX"" headers are needed in ##C:\""MinGW""\include##, specifically ##ddraw.h## and ##dinput.h##. You can get the headers from here: [[http://alleg.sourceforge.net/files/dx80_mgw.zip]]
__//Manually downloading the needed ""MinGW"" packages from [[http://sourceforge.net/projects/mingw/files]]//__
""FreeBASIC"" needs mostly the core packages only, see [[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/ MinGW BaseSystem]] and [[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/ MSYS BaseSystem]]. The archives to download are typically called ##*-*-*-mingw32-bin.tar.lzma## and ##lib*-*-*-mingw32-dll-*.tar.lzma## (similar for MSYS) and can be extracted using [[http://www.7-zip.org/ 7-zip]].

//""MinGW"" (binutils, GCC, ""Win32"" SDK)//
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GCC/Version4/ gcc-core, gcc-g++]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/GNU-Binutils/ binutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/ mingwrt]]##
- ##[[http://sourceforge.net/projects/mingw/files/MinGW/BaseSystem/RuntimeLibrary/Win32-API/ w32api]]##
//MSYS (Unixy shell environment, make)//
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/msys-core/ msys-core]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/bash/ bash]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/coreutils/ coreutils]]##
- ##[[http://sourceforge.net/projects/mingw/files/MSYS/make/ make]]##
__//Using other GCC-for-""Win32"" ports like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]]//__
It should generally be possible to use non-mingw.org GCCs, since they usually are almost identical. Things like different exception handling or 64bit support currently do not matter for ""FreeBASIC"". TDM-GCC was successfully used for the ""FreeBASIC"" 0.21 - 0.23 releases.
In the end ""MinGW"" should be installed in ##C:\""MinGW""##, and MSYS in ##C:\""MinGW""\msys\1.0##. You can use a ##mingw.bat## script like the following one to get a """MinGW-terminal"", from which you can work with ""MinGW"" without having to modify your system's global PATH environment variable (this assumes your Windows ""FreeBASIC"" is installed at ##""C:\FreeBASIC""##):
%%set PATH=C:\MinGW\bin;%PATH%
bash --login
%%
{{anchor name="COMPILE"}}{{fbdoc item="section" value="Compiling FreeBASIC"}}
By default the compilation process creates a compiler that is intended to be installed into a unix-like directory tree such as ##/usr## or ##/usr/local## on Linux, or ##""C:\MinGW""## for the Windows version, or ##C:\DJGPP## for the DOS version.
To compile ""FreeBASIC"", open a terminal (command prompt) and change to directory containing the ""FreeBASIC"" source code, then run:
The newly built compiler and run-time libraries will be placed in a build directory called ##new/##. This is a basically valid ""FreeBASIC"" installation, allowing it to be tested immediately, although on DOS and Windows there are additional steps necessary to get a fully working ""FreeBASIC"" tree.
To install into ##/usr/local## on Linux:
To install into ##""C:\MinGW""## on Windows:
%%make install prefix=c:/mingw%%
To install the DOS version:
1) %%make install prefix=c:/djgpp%%
1) Copy the modified ##libc.a## from the latest ""FreeBASIC-dos"" release into ##C:\DJGPP\lib\freebas##
{{fbdoc item="subsect" value="Building a standalone DOS version while on Windows, like the FreeBASIC-dos releases"}}
Assuming the source code is in ##C:\fbc##:
%%cd /c/fbc
make clean
# (This is added to config.mk so you don't have to retype it for every 'make' or 'make clean' etc.)
echo "ENABLE_STANDALONE=1" > config.mk
make clean
make
%%
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
1) Copy to ##""C:\fbc\new\bin""##:
- ##C:\DJGPP\bin\{ar,as,ld}.exe##
1) Copy to ##""C:\fbc\new\lib""##:
- ##C:\DJGPP\lib\{crt0,gcrt0}.o##
- ##C:\DJGPP\lib\lib{emu,m}.a##
- ##C:\DJGPP\lib\gcc\djgpp\<version>\lib{gcc,supcxx}.a##, and rename ##libsupcxx.a## to ##libsupcx.a## (8.3 file name)
- ##C:\DJGPP\lib\lib{bfd,iberty,intl,z}.a## //(For recompiling ""FreeBASIC"" using this tree)//
- The modified ##libc.a## from the latest ""FreeBASIC"" release //(Note: To use the libc.a from DJGPP, the _main.o it contains needs to be replaced with the one compiled from ##contrib/djgpp/libc/crt0/_main.c## from the fbc source code, to fix a bug in the original version from DJGPP)//
- and any additional libraries you want to use
1) Copy to ##""C:\fbc\new\include""##:
- any headers you want to use, from [[http://code.google.com/p/freebasic-headers/ freebasic-headers]] or the previous ""FreeBASIC"" release, etc.
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{fbdoc item="subsect" value="Building a standalone Windows version, like the FreeBASIC-win32 releases"}}
Assuming the source code is in ##C:\fbc##:
%%cd /c/fbc
make clean
# (This is added to config.mk so you don't have to retype it for every 'make' or 'make clean' etc.)
echo "ENABLE_STANDALONE=1" > config.mk
make clean
make
%%
After the compilation, the following files need to be copied into the ##C:\fbc\new## tree:
1) Copy to ##""C:\fbc\new\bin""##:
- ##""C:\MinGW\bin\{ar,as,dlltool,ld}.exe""##
- ##""GoRC.exe""## (from [[http://www.godevtool.com/]] or the previous ""FreeBASIC"" release)
1) Copy to ##""C:\fbc\new\lib""##:
- ##""C:\MinGW\lib\{crt2,dllcrt2,gcrt2}.o""##
- ##""C:\MinGW\lib\lib{gmon,mingw32,mingwex,moldname}.a""##
- ##""C:\MinGW\lib\gcc\mingw32\<version>\{crtbegin,crtend}.o""##
- ##""C:\MinGW\lib\gcc\mingw32\<version>\lib{gcc,supc++}.a""##
- ##""C:\MinGW\lib\lib{advapi32,gdi32,kernel32,msvcrt,user32,winmm,winspool}.a""## //(Rename to ##lib*.dll.a## if preferred)//
- ##""C:\MinGW\lib\lib{bfd,iberty,intl}.a""## //(For recompiling ""FreeBASIC"" using this tree)//
- and any additional libraries you want to use
1) Copy to ##""C:\fbc\new\include""##:
- any headers you want to use, from [[http://code.google.com/p/freebasic-headers/ freebasic-headers]] or the previous ""FreeBASIC"" release, etc.
After this, ##C:\fbc\new## should be ready to compile your programs, and you can also copy it to another directory or share it if you want.
{{fbdoc item="subsect" value="Getting source code updates and recompiling"}}
To download updates made available in the fbc Git repository, you can do a pull, either using your preferred graphical Git tool, or in a terminal:
%%git pull%%
To take a look at incoming changes //before// applying them, do this:
%%
# Update remote branches
git fetch
# Take a look
gitk --all
# Everything looks ok? Then merge the remote branch into the current branch to apply the update.
git merge origin/master
%%
Rebuilding is as easy as:
%%make%%
Note: If compilation options (like ENABLE_STANDALONE) were used for the previous build, it's necessary to specify them again this time. If they are set in ##config.mk## then they will be automatically set again.
{{fbdoc item="subsect" value="Recompiling fbc for debugging purposes"}}
%%make clean-compiler
make FBFLAGS=-exx%%
{{anchor name="CONFIG"}}{{fbdoc item="section" value="Compilation options"}}
Deletions:
Web browser access to fbc source code repositories: http://fbc.git.sourceforge.net/
Git clone URL for the main fbc/fbc repository: ##""git://fbc.git.sourceforge.net/gitroot/fbc/fbc""##
Old SVN guides:
{{fbdoc item="section" value="Setting up the environment"}}
This assumes a 32bit (x86) Linux system, however it should also be possible to crosscompile the (still only 32bit) ""FreeBASIC"" on a 64bit system, but the steps might be different (TODO). Roughly these Debian packages should be needed (with Fedora names in parentheses):
- ##gcc##, ##""g++""## (##""gcc-c++""##), ##binutils##
- ##binutils-dev## (##binutils-devel## or ##binutils-static##) - //libbfd//
- ##libncurses-dev## (##ncurses-devel##)
- ##libx11-dev##, ##libxext-dev##, ##libxpm-dev##, ##libxrandr-dev##, ##libxrender-dev## (##libX11-devel##, ##libXext-devel##, ##libXpm-devel##, ##libXrandr-devel##, ##libXrender-devel##) - //X11 headers//
- ##libgpm-dev## (##gpm-devel##) - //General purpose mouse library headers//
- ##freeglut3-dev## (##freeglut-devel##) - //""OpenGL"" headers//
The DOS version of ""FreeBASIC"" is typically compiled on Windows, using a DOS ""FreeBASIC"" and DJGPP. The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (beta/v2/), but for the others it should be ok to use the ones from DJGPP 2.03 (current/v2gnu/).
- binutils (bnu*b.zip, bnu*a.zip)
- bash (bsh*.zip)
- djdev (djdev*.zip) - //pick up djdev204.zip or later from the ##beta/## directory//
- fileutils (fil*.zip)
- gcc (gcc*b.zip)
- gpp (gpp*b.zip)
- make (mak*b.zip)
- shellutils (shl*b.zip)
- textutils (txt*b.zip)
Setup DJGPP by extracting everything ##C:\DJGPP## and adding an environment variable named "DJGPP", set to ##C:\DJGPP\djgpp.env##. You can use a ##djgpp.bat## script like the following one to get a "DJGPP-terminal":
%%set DJGPP=C:\DJGPP\djgpp.env
set PATH=C:\FreeBASIC-dos;%PATH%
""MinGW""/MSYS can be found at [[http://www.mingw.org]] and [[http://sourceforge.net/projects/mingw]]. It's split up into many packages, of which mostly only the core (""BaseSystem"") ones are needed for ""FreeBASIC"". It is possible to manually download and extract the packages, or to use ""MinGW""'s mingw-get tool to do that, or to even use another GCC Windows port like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]].
The required packages in general:
- ""MinGW"": ##gcc-core##, ##""gcc-g++""##, ##binutils##, ##mingwrt##, ##w32api##
- MSYS: ##msys-core##, ##bash##, ##coreutils##, ##cygutils-dos2unix##, ##make##
In the end ""MinGW"" should be installed in something like ##C:\""MinGW""##. You can use a ##mingw.bat## script like the following one to get a """MinGW-terminal"":
%%set PATH=C:\MinGW\bin;%PATH%
bash --login%%
In order to compile ""FreeBASIC""'s gfxlib, ""DirectX"" headers are needed in ##C:\""MinGW""\include##, specifically ##ddraw.h## and ##dinput.h##. You can get the headers from here: [[http://alleg.sourceforge.net/files/dx80_mgw.zip]]
{{fbdoc item="section" value="Compiling FreeBASIC"}}
""FreeBASIC""'s main makefile compiles the compiler and runtime libraries. Only this command needs to be run in the fbc source code directory:
It should compile everything. The result is a new sub-directory (the build directory) called ##new/##. It contains the newly built compiler and runtime libraries, and is a basically valid installation of ""FreeBASIC"", allowing it to be tested immediately.
The main makefile can do more, for example:
This will copy the built compiler from ##new/## into the ##prefix## path (which defaults to ##/usr/local## as this is a common place to install manually compiled tools to on Linux & co, however it can also be set to ##C:/""FreeBASIC""## or ##C:/""MinGW""## for example).
{{fbdoc item="section" value="Making the new FreeBASIC tree usable"}}
Several files need to be copied into the C:\""FreeBASIC""-dos tree to enable it to compile ""FreeBASIC"" programs (and FreeBASIC itself again; those cases are marked with "for rebuilding").
From ##C:\""FreeBASIC""-0.21.1-dos## into ##C:\""FreeBASIC""-dos\lib\dos##:
- ##libc.a## (Note: this is not the original one from DJGPP, we're using a modified version, see ""FreeBASIC""/src/contrib/djgpp/crt0)
- ##libintl.a## (for rebuilding)
- ##libz.a## (for rebuilding)
From ##C:\""FreeBASIC""-0.21.1-dos## into ##C:\""FreeBASIC""-dos\bin\dos##:
- ##ar.exe##
- ##as.exe##
- ##ld.exe##
These files need to be copied from DJGPP into the C:\""FreeBASIC""-dos tree:
From ##C:\DJGPP\lib\gcc\djgpp\<version>## into ##C:\""FreeBASIC""-dos\lib\dos##:
- ##libgcc.a##
- ##libsupcx.a## (Note: the original file is named ##libsupcxx.a##, but we're using the shorter version for FB to avoid long file name problems that occurred with this in the past)
Additionally you should copy
##C:\DJGPP\lib\gcc\djgpp\4.42\libsupcxx.a##
to
##C:\DJGPP\lib\gcc\djgpp\4.42\libsupcx.a##
because fbc expects that shorter name (probably a 8.3 file name issue).
From ##C:\DJGPP\lib## into ##C:\""FreeBASIC""-dos\lib\dos##:
- ##crt0.o##
- ##gcrt0.o##
- ##libbfd.a## (for rebuilding)
- ##libemu.a##
- ##libiberty.a## (for rebuilding)
- ##libm.a##
Now you can use C:\""FreeBASIC""-dos instead of C:\""FreeBASIC""-0.21.1-dos to compile FB programs.
Several files need to be copied into the C:\""FreeBASIC"" tree to enable it to compile ""FreeBASIC"" programs (and ""FreeBASIC"" itself again; those cases are marked with "for rebuilding").
From C:\""FreeBASIC""-0.21.1-win32 into C:\""FreeBASIC""\bin\win32:
- ##ar.exe##
- ##as.exe##
- ##dlltool.exe##
- ##ld.exe##
- ##""GoRC.exe""##
From ##C:\""MinGW""\lib\gcc\mingw32\4.4.1## into ##C:\""FreeBASIC""\lib\win32##:
- ##crtbegin.o##
- ##crtend.o##
- ##libgcc.a##
- ##""libsupc++.a""##
From ##C:\""MinGW""\lib## into ##C:\""FreeBASIC""\lib\win32##:
- ##crt2.o##
- ##dllcrt2.o##
- ##gcrt2.o##
- ##libadvapi32.a##
- ##libbfd.a## (for rebuilding)
- ##libgdi32.a##
- ##libgmon.a##
- ##libiberty.a## (for rebuilding)
- ##libintl.a## (for rebuilding)
- ##libkernel32.a##
- ##libmingw32.a##
- ##libmingwex.a##
- ##libmoldname.a##
- ##libmsvcrt.a##
- ##libuser32.a##
- ##libwinmm.a##
- ##libwinspool.a##
The advapi32, gdi32, kernel32, msvcrt, user32, winmm and winspool libraries may also be renamed to *.dll.a instead of just *.a if you prefer.
Now you can use C:\""FreeBASIC"" instead of C:\""FreeBASIC""-0.21.1-win32 to compile FB programs.
You can copy more Windows API libraries (or others), if/when you want/need them.
{{fbdoc item="section" value="Recompiling after SVN updates or changes to the source code"}}
For convenience you can rebuild the compiler and libraries (or just the changed component) in the same directory as before, using the same commands as before. However there may be chicken-egg problems after updates to the build system or the rtlib/gfxlib interface. Building fbc first avoids chicken-egg problems between fbc and the runtime libraries, but not all problems can be avoided while rebuilding in the same tree. It is safer (but more work) to use two separate FB directories (one being a working FB installation, the other being the tree you want to compile).
(Linux:) You can rebuild the compiler and libraries (or just the changed component) in the same directory as before, using the same commands as before. Since the FB installation in /usr/local is (normally) used for compilation, you don't have to worry about chicken-egg problems. However in case you're using a standalone fbc and rebuilding it in its own directory, you can run into the same problems as described on the Compiling For DOS/win32 pages.
{{fbdoc item="section" value="Compilation options"}}


Revision [15224]

Edited on 2011-09-25 16:40:34 by DkLwikki [New Compiling FB page WIP]
Additions:
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 this source code using anonymous read access and compile it using GNU development tools.
The ""FreeBASIC"" compiler is self-hosting, and a working ""FreeBASIC"" installation is needed to compile it, while ##gcc## is needed to compile the ""FreeBASIC"" runtime libraries. It should be possible to compile the current development version of ##fbc## using ""FreeBASIC"" 0.21 or up.
- ##binutils-dev## (##binutils-devel## or ##binutils-static##) - //libbfd//
- ##libx11-dev##, ##libxext-dev##, ##libxpm-dev##, ##libxrandr-dev##, ##libxrender-dev## (##libX11-devel##, ##libXext-devel##, ##libXpm-devel##, ##libXrandr-devel##, ##libXrender-devel##) - //X11 headers//
- ##libgpm-dev## (##gpm-devel##) - //General purpose mouse library headers//
- ##freeglut3-dev## (##freeglut-devel##) - //""OpenGL"" headers//
==DOS==
The DOS version of ""FreeBASIC"" is typically compiled on Windows, using a DOS ""FreeBASIC"" and DJGPP. The DJGPP packages can be found on the [[http://www.delorie.com/djgpp/getting.html DJGPP homepage]]. ""FreeBASIC"" needs djdev204.zip from DJGPP 2.04 (beta/v2/), but for the others it should be ok to use the ones from DJGPP 2.03 (current/v2gnu/).
- binutils (bnu*b.zip, bnu*a.zip)
- bash (bsh*.zip)
- djdev (djdev*.zip) - //pick up djdev204.zip or later from the ##beta/## directory//
- fileutils (fil*.zip)
- gcc (gcc*b.zip)
- gpp (gpp*b.zip)
- make (mak*b.zip)
- shellutils (shl*b.zip)
- textutils (txt*b.zip)
Setup DJGPP by extracting everything ##C:\DJGPP## and adding an environment variable named "DJGPP", set to ##C:\DJGPP\djgpp.env##. You can use a ##djgpp.bat## script like the following one to get a "DJGPP-terminal":
%%set DJGPP=C:\DJGPP\djgpp.env
set PATH=C:\DJGPP\bin;%PATH%
set PATH=C:\FreeBASIC-dos;%PATH%
cd C:\
cmd%%
It adds ##C:\DJGPP\bin## to its PATH, so that ##gcc## maps to ##C:\DJGPP\bin\gcc.exe## (ditto for the binutils). As long as there is no conflict with other gccs/binutils in the global PATH (such as ""MinGW""), then of course you can make DJGPP global too, including the DOS ""FreeBASIC"".
""MinGW""/MSYS can be found at [[http://www.mingw.org]] and [[http://sourceforge.net/projects/mingw]]. It's split up into many packages, of which mostly only the core (""BaseSystem"") ones are needed for ""FreeBASIC"". It is possible to manually download and extract the packages, or to use ""MinGW""'s mingw-get tool to do that, or to even use another GCC Windows port like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]].
- ""MinGW"": ##gcc-core##, ##""gcc-g++""##, ##binutils##, ##mingwrt##, ##w32api##
In the end ""MinGW"" should be installed in something like ##C:\""MinGW""##. You can use a ##mingw.bat## script like the following one to get a """MinGW-terminal"":
%%set PATH=C:\MinGW\bin;%PATH%
set PATH=C:\MinGW\msys\1.0\bin;%PATH%
set PATH=C:\FreeBASIC;%PATH%
bash --login%%
Alternatively you can also add both ""MinGW""/MSYS ##bin/## directories to the global PATH and use plain cmd.exe or MSYS' msys.bat. The result should be a terminal (MSYS' console, or cmd.exe command prompt) where ##make##, ##gcc##, ##fbc## and Unixy commands such as ##cp## and ##rm## are working.
This will copy the built compiler from ##new/## into the ##prefix## path (which defaults to ##/usr/local## as this is a common place to install manually compiled tools to on Linux & co, however it can also be set to ##C:/""FreeBASIC""## or ##C:/""MinGW""## for example).
==DOS==
Several files need to be copied into the C:\""FreeBASIC""-dos tree to enable it to compile ""FreeBASIC"" programs (and FreeBASIC itself again; those cases are marked with "for rebuilding").
From ##C:\""FreeBASIC""-0.21.1-dos## into ##C:\""FreeBASIC""-dos\lib\dos##:
- ##libc.a## (Note: this is not the original one from DJGPP, we're using a modified version, see ""FreeBASIC""/src/contrib/djgpp/crt0)
- ##libz.a## (for rebuilding)
From ##C:\""FreeBASIC""-0.21.1-dos## into ##C:\""FreeBASIC""-dos\bin\dos##:
These files need to be copied from DJGPP into the C:\""FreeBASIC""-dos tree:
From ##C:\DJGPP\lib\gcc\djgpp\<version>## into ##C:\""FreeBASIC""-dos\lib\dos##:
- ##libsupcx.a## (Note: the original file is named ##libsupcxx.a##, but we're using the shorter version for FB to avoid long file name problems that occurred with this in the past)
Additionally you should copy
##C:\DJGPP\lib\gcc\djgpp\4.42\libsupcxx.a##
to
##C:\DJGPP\lib\gcc\djgpp\4.42\libsupcx.a##
because fbc expects that shorter name (probably a 8.3 file name issue).
From ##C:\DJGPP\lib## into ##C:\""FreeBASIC""-dos\lib\dos##:
- ##crt0.o##
- ##gcrt0.o##
- ##libemu.a##
- ##libm.a##
Now you can use C:\""FreeBASIC""-dos instead of C:\""FreeBASIC""-0.21.1-dos to compile FB programs.
Deletions:
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. It is possible for users to download this source code using anonymous read access and compile it using GNU development tools.
The ""FreeBASIC"" compiler is self-hosting, and a working ""FreeBASIC"" installation is needed to compile it. It should be possible to compile the current development version using FreeBASIC 0.21 or up.
- ##binutils-dev## (##binutils-devel## or ##binutils-static##) [libbfd]
- ##libx11-dev##, ##libxext-dev##, ##libxpm-dev##, ##libxrandr-dev##, ##libxrender-dev## (##libX11-devel##, ##libXext-devel##, ##libXpm-devel##, ##libXrandr-devel##, ##libXrender-devel##) [X11 headers]
- ##libgpm-dev## (##gpm-devel##) [General purpose mouse library headers]
- ##freeglut3-dev## (##freeglut-devel##) [OpenGL headers]
""MinGW""/MSYS can be found at [[http://www.mingw.org]] and [[http://sourceforge.net/projects/mingw]]. It's split up into many packages, of which mostly only the core (BaseSystem) ones are needed for ""FreeBASIC"". It is possible to manually download and extract the packages, or to use MinGW's mingw-get tool to do that, or to even use another GCC Windows port like [[http://tdm-gcc.tdragon.net/ TDM-GCC]] or [[http://mingw-w64.sourceforge.net/ MinGW-w64]].
- MinGW: ##gcc-core##, ##""gcc-g++""##, ##binutils##, ##mingwrt##, ##w32api##
The result should be a terminal (MSYS' console, or cmd.exe command prompt) where ##gcc##, ##fbc## and Unixy commands such as ##cp## and ##rm## are working. To get there, the PATH environment variable might need to be adjusted to include the paths where ""FreeBASIC"" or MinGW binaries are installed.
This will copy the built compiler from ##new/## into the ##prefix## path (which defaults to ##/usr/local## as this is a common place to install manually compiled tools to on Linux & co, however it can also be set to ##C:/FreeBASIC## or ##C:/MinGW## for example).


Revision [15223]

The oldest known version of this page was created on 2011-09-25 12:50:31 by DkLwikki [New Compiling FB page WIP]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode