tboox/tbox logo

tboox/tbox

Free

🎁 A glib-like multi-platform c library

FreeFree tier
Type
Open Source

About tboox/tbox

TBOX is a glib-like cross-platform C library designed to simplify C development and boost productivity. It offers a wide range of modules including stream I/O, coroutines, regular expressions, containers, algorithms, XML parsing, serialization/deserialization, network communication, and memory management. The library supports Windows, macOS, Linux, Android, iOS, and *BSD, and provides multiple build configurations (Release, Debug, Small, Micro) via the xmake build system. It includes advanced features such as coroutine-based asynchronous I/O, high-performance memory pools with debugging for common bugs (out-of-bounds, use-after-free, leaks), and support for SSL/TLS, DNS caching, and HTTP. TBOX is suitable for both desktop and embedded systems, with a micro build targeting around 64KB.

Key Features

Cross-platform support: Windows, macOS, Linux, Android, iOS, *BSD
Stream library with file, data, http, socket sources and gzip/charset filters
High-performance coroutine library with stackful and stackless modes, supporting epoll, kqueue, poll, select, IOCP
Database library supporting MySQL and SQLite3 with iterator-based data enumeration
XML parser supporting DOM, SAX, and XPath
Serialization and deserialization for XML, JSON, bplist, xplist, binary formats
Memory library with memory pools and fast error detection for debug mode
Container library: hash table, list, vector, stack, queue, min/max heap, with iterator support
Algorithm library: find, sort, count, walk, for_all using iterator mode
Network library: DNS caching, SSL (OpenSSL, PolarSSL, mbedTLS), HTTP, cookies, IPv4/IPv6

Pros & Cons

Pros
  • Comprehensive set of modules covering I/O, networking, data structures, and algorithms
  • Cross-platform with consistent API across Windows, Linux, macOS, mobile, and BSD
  • Coroutine support for efficient asynchronous programming without callback complexity
  • Memory debugging features help detect common C bugs in debug builds
  • Multiple build configurations allowing size optimization down to ~64KB for embedded use
  • Active open-source community with over 5,000 stars and frequent commits
  • Detailed documentation available (documents link referenced)
Cons
  • Requires xmake build system (not a standard build tool like CMake or Make)
  • Primarily a general-purpose C library; not specialized for AI or machine learning tasks
  • Steep learning curve for developers unfamiliar with glib-style abstractions
  • Some modules (e.g., database, SSL) have external dependencies
  • Limited to C programming language; no native support for C++ or other languages

Best For

Developing portable system tools and utilities in CEmbedded software development with size-constrained environmentsBuilding network servers with coroutine-based asynchronous I/OCross-platform application development requiring consistent APIsEducational projects for learning modern C library patternsReplacing glib with a lighter, more focused alternative

FAQ

What platforms does TBOX support?
TBOX supports Windows, macOS, Linux, Android, iOS, and *BSD.
Does TBOX support coroutines?
Yes, TBOX provides a high-performance coroutine library with stackful and stackless variants, supporting epoll, kqueue, poll, select, and IOCP.
How can I use TBOX in an embedded system?
TBOX offers a Micro build configuration that compiles the library to approximately 64KB, suitable for embedded systems.
What build system does TBOX use?
TBOX uses xmake as its build system, which provides various configurations like Release, Debug, Small, and Micro.
Does TBOX provide memory debugging?
Yes, in debug mode the memory library can detect out-of-bounds accesses, use-after-free, double-free, invalid free, and memory leaks.