External Library Bindings

FreeBASIC includes many .bi files that let BASIC programs call libraries written in C or other languages.  These pages describe the bindings and the examples that use them.

A binding is not the same thing as a complete package.  The include file can describe the API, but the target system still needs the matching library, import library, shared object, DLL, framework, package, or runtime asset.  This matters more now because the compiler is being used on a much wider set of targets than the old desktop-only cases.

{{fbdoc item="section" value="How to read this page"}}

* **Usually practical:** The binding is commonly usable when the normal operating system package is installed, or when this build already ships the needed pieces.
* **Optional external library:** The examples are valid, but the library is not part of every FreeBASIC install.  Install the development package for your operating system before expecting the example to link.
* **Legacy or special-case:** The binding exists, but the upstream library is old, commercial, uncommon, or not packaged cleanly on every target.
* **Platform API:** The binding is only meaningful on the platform that owns the API.  A Windows API example is not expected to work on JavaScript, Android, Xbox, DOS, or Unix targets.

{{fbdoc item="section" value="Platform reality from the example sweeps"}}

The examples directory contains notes from current example sweeps.  Those notes are a useful reality check for this table.

|| **Target family** || **What the sweeps show** ||
|| Windows win32 || The shipped example set links a large number of examples.  Some old or commercial libraries still need extra runtime DLLs or import libraries before the examples are truly runnable. ||
|| Windows win64 || Many restored examples are now practical, including several database, image, helper, and math examples.  The remaining rough edges are mostly older libraries such as Allegro 4, CGUI, GRX, wx-c, BASS/BASSMOD, FMOD 3, PDFlib, Newton, and old SpiderMonkey. ||
|| Cygwin || The core compiler, runtime, networking, procedure, and thread examples are healthy.  Most external-library failures are plain missing-library failures, not compiler failures. ||
|| JavaScript, Android, and Xbox || These targets are useful compile targets for portable BASIC code, but most desktop external libraries and OS APIs are not expected to exist there.  Treat those examples as target-specific unless the target package says otherwise. ||

{{fbdoc item="section" value="Sound and media"}}

* {{fbdoc item="keyword" value="sfxlib command set" link="CatPgSfx"}} - Built-in BASIC-oriented sound commands.  Start here for SOUND, PLAY, SFX, MUSIC, MIDI, waveform, envelope, channel, panning, and capture commands.
* {{fbdoc item="keyword" value="OpenAL" link="ExtLibal"}} - 3D audio API.  Optional on most systems.
* {{fbdoc item="keyword" value="BASS" link="ExtLibbass"}} and {{fbdoc item="keyword" value="BASSMOD" link="ExtLibbassmod"}} - Third-party audio libraries.  Useful when you provide the vendor runtime, but not something every FreeBASIC package can ship.
* {{fbdoc item="keyword" value="FMOD" link="ExtLibfmod"}} - Old FMOD binding.  Treat this as legacy unless you already have the matching SDK/runtime.
* {{fbdoc item="keyword" value="Flite" link="ExtLibFlite"}} - Speech synthesis library.
* {{fbdoc item="keyword" value="mpg123" link="ExtLibmpg123"}}, {{fbdoc item="keyword" value="Ogg" link="ExtLibogg"}}, {{fbdoc item="keyword" value="Vorbis" link="ExtLibvorbis"}}, and {{fbdoc item="keyword" value="sndfile" link="ExtLibsndfile"}} - Audio decoding and file-format libraries.
* {{fbdoc item="keyword" value="PortAudio" link="ExtLibPortAudio"}} - Cross-platform audio I/O library.
* {{fbdoc item="keyword" value="VLC" link="ExtLibVLC"}} - Media playback through libVLC.
* {{fbdoc item="keyword" value="old sfx binding page" link="ExtLibsfx"}} - Historical page kept for compatibility.  New code should normally read the sfxlib command pages instead.

{{fbdoc item="section" value="Graphics, image, and display libraries"}}

* {{fbdoc item="keyword" value="Allegro" link="ExtLiballegro"}}, {{fbdoc item="keyword" value="SDL" link="ExtLibSDL"}}, {{fbdoc item="keyword" value="TinyPTC" link="ExtLibtinyptc"}}, {{fbdoc item="keyword" value="DUGL" link="ExtLibDUGL"}}, and {{fbdoc item="keyword" value="GRX" link="ExtLibgrx"}} - Game, framebuffer, and graphics libraries.  Several are useful for old examples, but some are legacy on modern Windows packages.
* {{fbdoc item="keyword" value="OpenGL" link="ExtLibOpenGL"}}, {{fbdoc item="keyword" value="GLUT" link="ExtLibGLUT"}}, {{fbdoc item="keyword" value="freeglut" link="ExtLibfreeglut"}}, and {{fbdoc item="keyword" value="GLFW" link="ExtLibGLFW"}} - OpenGL-related bindings.  Good desktop targets, but not generally expected on JavaScript, Android, Xbox, or DOS package installs.
* {{fbdoc item="keyword" value="Cairo" link="ExtLibcairo"}}, {{fbdoc item="keyword" value="caca" link="ExtLibcaca"}}, {{fbdoc item="keyword" value="DISLIN" link="ExtLibdislin"}}, and {{fbdoc item="keyword" value="PDFLib" link="ExtLibpdflib"}} - Drawing, terminal graphics, plotting, and document-generation libraries.
* {{fbdoc item="keyword" value="DevIL" link="ExtLibIL"}}, {{fbdoc item="keyword" value="FreeImage" link="ExtLibfreeimage"}}, {{fbdoc item="keyword" value="FreeType2" link="ExtLibfreetype2"}}, {{fbdoc item="keyword" value="GD" link="ExtLibgd"}}, {{fbdoc item="keyword" value="GIFLIB" link="ExtLibgiflib"}}, {{fbdoc item="keyword" value="jpeglib" link="ExtLibjpeglib"}}, {{fbdoc item="keyword" value="jpgalleg" link="ExtLibjpgalleg"}}, and {{fbdoc item="keyword" value="libpng" link="ExtLiblibpng"}} - Image loading, image writing, font, and raster helpers.  These are often practical when the OS package manager provides matching development libraries.

{{fbdoc item="section" value="GUI and platform user-interface libraries"}}

* {{fbdoc item="keyword" value="CGUI" link="ExtLibcgui"}}, {{fbdoc item="keyword" value="GTK+" link="ExtLibgtk"}}, {{fbdoc item="keyword" value="IUP" link="ExtLibIUP"}}, {{fbdoc item="keyword" value="JAPI" link="ExtLibjapi"}}, and {{fbdoc item="keyword" value="wx-c" link="ExtLibwxc"}} - GUI bindings.  Some are useful, but they are among the bindings most likely to need extra runtime libraries.
* {{fbdoc item="keyword" value="Curses" link="ExtLibcurses"}} - Terminal UI support.
* {{fbdoc item="keyword" value="X11" link="ExtLibX11"}} and {{fbdoc item="keyword" value="Windows API" link="ExtLibwindows"}} - Platform APIs.  These are not portable abstractions.

{{fbdoc item="section" value="Data, database, and web libraries"}}

* {{fbdoc item="keyword" value="GDBM" link="ExtLibGDBM"}}, {{fbdoc item="keyword" value="MySQL" link="ExtLibmysql"}}, {{fbdoc item="keyword" value="PostgreSQL" link="ExtLibpostgresql"}}, and {{fbdoc item="keyword" value="SQLite" link="ExtLibsqlite"}} - Database bindings.  SQLite is usually the easiest dependency to satisfy; client/server databases need the matching client development package.
* {{fbdoc item="keyword" value="CGI utility" link="ExtLibcgiutil"}}, {{fbdoc item="keyword" value="FastCGI" link="ExtLibFastCGI"}}, {{fbdoc item="keyword" value="curl" link="ExtLibcurl"}}, and {{fbdoc item="keyword" value="ZeroMQ" link="ExtLibZeroMQ"}} - Web, HTTP, and messaging support.  These are practical where the OS provides the libraries, but they are not automatically available on every cross target.
* {{fbdoc item="keyword" value="Expat" link="ExtLibexpat"}}, {{fbdoc item="keyword" value="libxml" link="ExtLiblibxml"}}, {{fbdoc item="keyword" value="libxslt" link="ExtLiblibxslt"}}, and {{fbdoc item="keyword" value="mxml" link="ExtLibmxml"}} - XML parsers and transformation libraries.
* {{fbdoc item="keyword" value="json-c" link="ExtLibjsonc"}} - JSON support through json-c.

{{fbdoc item="section" value="Development, language, and helper libraries"}}

* {{fbdoc item="keyword" value="ASpell" link="ExtLibaspell"}}, {{fbdoc item="keyword" value="BFD" link="ExtLibbfd"}}, {{fbdoc item="keyword" value="CUnit" link="ExtLibCUnit"}}, {{fbdoc item="keyword" value="GDSL" link="ExtLibgdsl"}}, {{fbdoc item="keyword" value="gettext" link="ExtLibgettext"}}, {{fbdoc item="keyword" value="MediaInfo" link="ExtLibMediaInfo"}}, and {{fbdoc item="keyword" value="UUID" link="ExtLibUUID"}} - Helper and developer libraries.  These are useful, but mostly depend on optional OS packages.
* {{fbdoc item="keyword" value="libffi" link="ExtLibFfi"}}, {{fbdoc item="keyword" value="libjit" link="ExtLibJit"}}, {{fbdoc item="keyword" value="JNI" link="ExtLibjni"}}, {{fbdoc item="keyword" value="Lua" link="ExtLibLua"}}, and {{fbdoc item="keyword" value="SpiderMonkey" link="ExtLibspidermonkey"}} - Language runtimes and foreign-function interfaces.  libjit and old SpiderMonkey are special-case bindings on current Windows package builds.

{{fbdoc item="section" value="Math, physics, compression, regex, and system APIs"}}

* {{fbdoc item="keyword" value="big_int" link="ExtLibbigint"}}, {{fbdoc item="keyword" value="GMP" link="ExtLibgmp"}}, and {{fbdoc item="keyword" value="GSL" link="ExtLibgsl"}} - Big-number and scientific/math libraries.
* {{fbdoc item="keyword" value="Chipmunk" link="ExtLibChipmunk"}}, {{fbdoc item="keyword" value="Newton" link="ExtLibnewton"}}, and {{fbdoc item="keyword" value="ODE" link="ExtLibode"}} - Physics libraries.  Expect package availability to vary by platform.
* {{fbdoc item="keyword" value="cryptlib" link="ExtLibcryptlib"}} - Cryptography library binding.  Treat licensing and redistributability as part of the dependency decision.
* {{fbdoc item="keyword" value="bzip2" link="ExtLibbzip2"}}, {{fbdoc item="keyword" value="LZMA" link="ExtLibLzma"}}, {{fbdoc item="keyword" value="LZO" link="ExtLibLzo"}}, {{fbdoc item="keyword" value="QuickLZ" link="ExtLibquicklz"}}, {{fbdoc item="keyword" value="Zip" link="ExtLibZip"}}, and {{fbdoc item="keyword" value="zlib" link="ExtLibzlib"}} - Compression libraries.
* {{fbdoc item="keyword" value="PCRE" link="ExtLibpcre"}} and {{fbdoc item="keyword" value="TRE" link="ExtLibtre"}} - Regular-expression libraries.
* {{fbdoc item="keyword" value="C runtime" link="ExtLibCRT"}}, {{fbdoc item="keyword" value="DOS API" link="ExtLibdos"}}, {{fbdoc item="keyword" value="DispHelper" link="ExtLibdisphelper"}}, and {{fbdoc item="keyword" value="GLib" link="ExtLibGLib"}} - System/runtime bindings.  These should be read with the target platform in mind.

{{fbdoc item="section" value="Practical advice"}}

If an external-library example fails to build, first check whether the target system has the library development package installed.  Missing -l errors usually mean the compiler is fine and the library is absent.  Runtime DLL errors on Windows usually mean the program linked, but the needed DLL was not next to the executable or on PATH.

For new portable programs, prefer the built-in FreeBASIC runtime, gfxlib, sfxlib, sockets, and standard file/string functionality before reaching for a third-party binding.  Use external libraries when they give you a real feature you need, and document that dependency in your own project.
