Compiling from SVN for Linux

Compiling from SVN for Linux

This guide shows how to compile a Linux FreeBASIC (compiler and libraries) on an x86 Linux system using a Linux version of FreeBASIC. Note: Compiling the 32bit FB on a 64bit Linux system requires extra steps and is a bit harder, though surely possible.

Setting up the environment

Choose a place for the SVN FreeBASIC, for example ~/FreeBASIC. Then checkout the current development base:

cd ~/FreeBASIC
svn checkout .

An existing FreeBASIC installation is needed.

You will need many development tools and libraries, including but not limited to:
  • subversion
  • gcc
  • g++ (or gcc-c++ on Fedora)
  • binutils-dev (or binutils-devel on Fedora, and binutils-static on Fedora 14 and later)
  • perl
  • autoconf
  • libncurses-dev (or ncurses-devel on Fedora)
  • libx11-dev (or libX11-devel on Fedora)
  • libxext-dev (or libXext-devel on Fedora)
  • libxpm-dev (or libXpm-devel on Fedora)
  • libxrandr-dev (or libXrandr-devel on Fedora)
  • libxrender-dev (or libXrender-devel on Fedora)
  • libgpm-dev (or gpm-devel on Fedora)
  • freeglut3-dev (or freeglut-devel on Fedora, or another one that pulls in OpenGL headers)

Compiling FreeBASIC

Open up a shell and enter the following commands.

cd ~/FreeBASIC

Compile the new fbc:

cd src/compiler/obj/linux
make install
cd ../../../..

Compile the new libfb.a and libfbmt.a:

cd src/rtlib/obj/linux
../../configure CFLAGS=-O2
make install
cd ../../../..

Compile the new libfbgfx.a:

cd src/gfxlib2/obj/linux
../../configure CFLAGS=-O2
make install
cd ../../../..

Now you can install the new fbc/libraries into /usr/local, overwriting the old installation (might require root privileges):

./ -i

Note: If the existing installation and the just-compiled FreeBASIC use different prefixes (or one is standalone, but not the other) then the or scripts won't replace the existing files. You will need to remove the previous installation first, either by running -u or install-standalone -u in the FreeBASIC directories you installed the existing FreeBASIC from, or by manually deleting the files.

Recompiling after SVN updates or changes to the source code

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.

Useful options for building rtlib and gfxlib


  • CC=<path/to/gcc>
    (Useful if not using the default from the system)

  • RANLIB=<path/to/ranlib>
  • CFLAGS=<gcc compile options>
    Useful to override the default "-O2 -g" and just use "-O2", unless you want debug symbols.

    You can pass these to the makefile too, but by passing them to configure they will be written to the makefile and you won't have to remember them the next time you're make'ing.


  • AR=<path/to/ar>
    (The AR variable is not forwarded by configure currently, so it has to be passed to the makefile)

Useful options for building the compiler


  • --disable-objinfo
    If specified fbc will not be linked against libbfd/libiberty/libintl. This can save a lot of trouble during compilation of fbc, at the cost of the objinfo feature being disabled.

  • --enable-standalone
    Build a standalone fbc that can run from the FreeBASIC tree and doesn't need to be installed. It will seek binutils and libraries in the FreeBASIC tree, thus they need to be copied in. You can look at the FreeBASIC-linux-standalone release to see what files are expected. The script can be used to install/uninstall this fbc to/from /usr/share/freebasic.

  • --prefix=/a/path/to/somewhere
    Changes the /usr/local prefix to something else. Only useful for the non-standalone build.
    For example:
    ../../configure --prefix=/usr
    Then -i will install into /usr instead of /usr/local (and fbc will use /usr instead of /usr/local to find binutils, libraries and headers).

  • --enable-crosscomp-<target>
    fbc will be compiled supporting cross-compilation for the specified target. To actually cross-compile something though additional binutils and libraries will be needed in the FreeBASIC/bin/<target> and FreeBASIC/lib/<target> directories. Besides, this may only work with the standalone build of fbc.
    For example:
    ../../configure --enable-crosscomp-dos

  • FBC=<path/to/fbc>


  • DEBUG=1
    fbc will be compiled with -g. Useful for debugging fbc.
    For example:
    make DEBUG=1

    fbc will be compiled with -exx. Useful for debugging fbc. The resulting fbc will be notably slower.

    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 BFD_VER=217. The libbfd.a that this fbc will be linked against must match this version exactly.

    Note: The linking process to build fbc will prefer the system's libbfd (from /usr/lib) over libbfd's found in library search paths (such as /usr/share/freebasic/lib/linux), and it will prefer shared libraries ( over static libraries (libbfd.a).
    Because of that it's easier to use the default C libbfd wrapper, unless you exactly know your system's libbfd version and it won't change (unlikely).
    If you don't want to link against a shared libbfd (which is likely to be present on your system because of the binutils), you can place (a specific) libbfd.a into /usr/local/lib, and it will be preferred over anything from /usr/lib.

There are no comments on this page. [Add comment] phatcode

lynplexc/building_linux.txt · Last modified: 2011/09/08 16:07 (external edit)