Quantcast
Channel: Hacker News
Viewing all articles
Browse latest Browse all 25817

Single-file C/C++ public-domain/open source libraries with minimal dependencies

$
0
0

README.md

I am the author of a large number of single-file C/C++ public domain libraries. I am not the only person who writes libraries like this, so below are other, similar libraries.

Generally, the following is a list of small, easy-to-integrate, portable libraries which are usable from C and/or C++, and should be able to be compiled on both 32-bit and 64-bit platforms.

Rules

  • Libraries must be usable from C or C++, ideally both
  • Libraries should be usable from more than one platform (ideally, all major desktops and/or all major mobile)
  • Libraries should compile and work on both 32-bit and 64-bit platforms
  • Libraries should use at most two files

Exceptions will be allowed for good reasons.

New libraries and corrections

See discussion after the list.

JSON Parsing

There are a lot of JSON parsers listed here. For some analysis and performance results, check out https://github.com/miloyip/nativejson-benchmark

Other lists

Also you might be interested in other related, but different lists:

  • clib: list of (mostly) small single C functions (licenses not listed)

Library listing

Public domain single-file libraries usable from C and C++ are in bold. Other libraries are either non-public domain, or two files, or not usable from both C and C++, or all three. Libraries of more than two files are mostly forbidden.

For the API column, "C" means C only, "C++" means C++ only, and "C/C++" means C/C++ usable from either; some files may require building as C or C++ but still qualify as "C/C++" as long as the header file uses extern "C" to make it work. (In some cases, a header-file-only library may compile as both C or C++, but produce an implementation that can only be called from one or the other, because of a lack of use of extern "C"; in this case the table still qualifies it as C/C++, as this is not an obstacle to most users.)

Categories:

librarylicenseAPIfilesdescription
micropatherzlibC++2pathfinding with A*
GenannzlibC/C++2simple neural networks (ANN)
librarylicenseAPIfilesdescription
pargpublic domainC2command-line argument parsing
flagspublic domainC++1command-line argument parsing
librarylicenseAPIfilesdescription
aw_ima.hMITC/C++1IMA-ADPCM audio decoder
dr_flacpublic domainC/C++1FLAC audio decoder
dr_wavpublic domainC/C++1WAV audio loader
sts_mixerpublic domainC/C++1simple stereo audio mixer
tinysoundzlibC/C++1direct sound audio mixer & WAV loader
librarylicenseAPIfilesdescription
miniz.cpublic domainC/C++1compression,decompression, zip file, png writing
lz4BSDC/C++2fast but larger LZ compression
fastlzMITC/C++2fast but larger LZ compression
pithyBSDC/C++2fast but larger LZ compression
microtarMITC/C++2lightweight tar library
librarylicenseAPIfilesdescription
TweetNaClpublic domainC2high-quality tiny cryptography library
librarylicenseAPIfilesdescription
klibMITC/C++2many 2-file libs: hash, sort, b-tree, etc
uthashBSDC/C++2several 1-header, 1-license-file libs: generic hash, list, etc
PackedArrayWTFPLv2C2memory-efficient array of elements with non-pow2 bitcount
minilibspublic domainC2two-file binary tress (also regex, etc)
DG_dynarr.hpublic domainC/C++1typesafe dynamic arrays (like std::vector) for plain C
chobo-shlMITC++1several C++11 standard contaner like libraries and helpers
libpqueueBSDC/C++2priority queue (heap)
librarylicenseAPIfilesdescription
DG_misc.hpublic domainC/C++1Daniel Gibson's stb.h-esque cross-platform helpers: path/file, strings
whereamiWTFPLv2C/C++2get path/filename of executable or module
direntMITC/C++1dirent for windows: retrieve file & dir info
TinyDirBSDC1cross-platform directory reading (win/posix/mingw)
tinyfileszlibC/C++1cross-platform directory reading (win/mac/unix)
librarylicenseAPIfilesdescription
nv_voronoi.hpublic domainC/C++1find voronoi regions on lattice w/ integer inputs
dfpublic domainC/C++1find voronoi region in linear time of size of lattice
sobol.hpublic domainC/C++1sobol & stratified sampling sequences
sdf.hMITC/C++1compute signed-distance field from antialiased image
nanoflannBSDC++1build KD trees for point clouds
jc_voronoiMITC/C++1find voronoi regions on float/double data
par_msquaresMITC/C++1convert (binarized) image to triangles
par_shapesMITC/C++1generate various 3d geometric shapes
Tomas Akenine-Moller snippetspublic domainC/C++2various 3D intersection calculations, not lib-ified
ClipperBoostC++2line & polygon clipping & offsetting
PolyPartitionMITC++2polygon triangulation, partitioning
VoxelizerMITC/C++1convert triangle mesh to voxel triangle mesh
yocto_bvh.hMITC/C++1ray-casting and closest-element queries of bounding-volume hierarchy
yocto_shape.hMITC/C++1shape generation, tesselation, normals, etc.
rjmpublic domainC/C++1marching cubes triangulator
librarylicenseAPIfilesdescription
blendishMITC/C++1blender-style widget rendering using NanoVG
tigrpublic domainC/C++2quick-n-dirty window text/graphics for Windows and OSX
noc_turtleMITC/C++2procedural graphics generator
librarylicenseAPIfilesdescription
yocto_trace.hMITC/C++1physically-based unidirectional path tracer w/ MIS for direct lights
yocto_symrigid.hMITC/C++1rigid body simulator (sequential impulse/PGS) with support for concave objects
mikktspacezlibC/C++2compute tangent space for normal mapping
debug-drawpublic domainC++1API-agnostic immediate-mode debug rendering
lightmapperpublic domainC/C++1use your OpenGL renderer to offline bake lightmaps
librarylicenseAPIfilesdescription
EasyTabpublic domainC/C++1multi-platform tablet input
librarylicenseAPIfilesdescription
jo_gif.cpppublic domainC++1animated GIF writer (CPP file can also be used as H file)
gif.hpublic domainC++1animated GIF writer (can only include once)
tiny_jpeg.hpublic domainC/C++1JPEG encoder
gif_loadpublic domainC/C++1(animated) GIF reader
miniexrpublic domainC++2OpenEXR writer, needs header file
tinyexrBSDC/C++1EXR image read/write, uses miniz internally
lodepngzlibC/C++2PNG encoder/decoder
nanoSVGzlibC/C++11-file SVG parser; 1-file SVG rasterizer
picopng.cppzlibC++2tiny PNG loader
jpeg-compressorpublic domainC++22-file jpeg compress, 2-file jpeg decompress
easyexifMITC++2EXIF metadata extractor for JPEG images
cro_mipmap.hpublic domainC/C++1average, min, max mipmap generators
PDFgenpublic domainC2PDF writer
librarylicenseAPIfilesdescription
mm_vec.hBSDC/C++1SIMD vector math
Handmade Mathpublic domainC/C++1vector math
gb_mathpublic domainC/C++1Vector, quaternion and matrix math w/o math.h
ccVector.hpublic domainC/C++1Vector, quaternion and matrix math
ShaderFastLibsMITC++1(also HLSL) approximate transcendental functions optimized for shaders (esp. GCN)
TinyExprzlibC2evaluation of math expressions from strings
linalg.hunlicenseC++1vector/matrix/quaternion math
PoissonGenerator.hMITC++1Poisson disk points generator (disk or rect)
prns.hpublic domainC/C++1seekable pseudo-random number sequences
aomebaMITC/C++1constraint solver (Cassowary) w/Lua binding
librarylicenseAPIfilesdescription
mm_sched.hzlibC/C++1cross-platform multithreaded task scheduler based on enkiTS
librarylicenseAPIfilesdescription
zed_netpublic domainC/C++1cross-platform socket wrapper
sts_netpublic domainC/C++1cross-platform socket wrapper (socket sets and packet API)
mm_web.hBSDC/C++1lightweight webserver, fork of webby
par_easycurl.hMITC/C++1curl wrapper
yoctopublic domainC/C++2non-production-use http server
happyhttpzlibC++2http client requests
mongooseGPLv2C/C++2http server
LUrlParserMITC++2lightweight URL & URI parser RFC 1738, RFC 3986
znetMITC/C++1cross-platform networking w/ lua binding
librarylicenseAPIfilesdescription
SLREGPLv2C/C++1regular expression matcher
PicoJSONBSDC++1JSON parse/serializer
mm_lexer.hzlibC/C++1C-esque language lexer
json.hpublic domainC/C++2JSON parser
jzon.hMITC++2JSON parser
parsonMITC/C++2JSON parser and serializer
minilibspublic domainC2two-file regex (also binary tree, etc)
tinymemfilezlibC++1fscanf on in-memory files
librarylicenseAPIfilesdescription
RemoteryApache 2.0C/C++2CPU/GPU profiler Win/Mac/Linux, using web browser for viewer
MicroProfileunlicenseC++2-4CPU (and GPU?) profiler, 1-3 header files, uses miniz internally
librarylicenseAPIfilesdescription
LILzlibC/C++2interpreter for a Tcl-like scripting language
lualiteMITC++1generate lua bindings in C++
PicolBSDC/C++1interpreter for a Tcl-like scripting language
s7BSDC/C++2interpreter for a subset of Scheme (R5RS/R7RS)
librarylicenseAPIfilesdescription
DG_misc.hpublic domainC/C++1Daniel Gibson's stb.h-esque cross-platform helpers: path/file, strings
utf8public domainC/C++1utf8 string library
strpool.hpublic domainC/C++1string interning
dfaMITC/C++2fast utf8 decoder (need a header file)
gb_string.hpublic domainC/C++1dynamic strings
librarylicenseAPIfilesdescription
utestMITC/C++1unit testing
catchBoostC++1unit testing
doctestMITC++1unit testing
SPUTBSDC/C++1unit testing
pempek_assert.cppWTFPLv2C++2flexible assertions
minctestzlibC1unit testing
greatestiSCC1unit testing
µnitMITC1unit testing
labratpublic domainC/C++1unit testing
hippomocksLGPLC++1unit testing
librarylicenseAPIfilesdescription
jo_mpegpublic domainC++1mpeg file writer
librarylicenseAPIfilesdescription
MakeID.hpublic domainC++1allocate/deallocate small integer IDs efficiently
logurupublic domainC++1flexible logging
tinyformatBoostC++1typesafe printf
visit_structBoostC++2struct-field reflection
debug-assertzlibC++1modular assertion macro
dbgtoolszlibC/C++2cross-platform debug util libraries
stmrMITC2extract English word stems
levenshteinMITC2compute edit distance between two strings
tinytimezlibC/C++1quick-and-dirty time elapsed time

There are also these XML libraries, but if you're using XML, shame on you:

New libraries and corrections

Submissions of new libraries: I accept submissions (as issues or as pull requests). Please note that every file that must be included in a user's project counts; a header and a source file is 2 files, but a header file, source file, and LICENSE (if the license isn't in the source file) is 3 files, and won't be accepted, because it's not 2 files. But actually 'LICENSE' is a problem for just dropping the library in a source tree anyway, since it's not scoped to just the library, so library authors are encouraged to include the license in the source file and not require a separate LICENSE.

Corrections: if information for a library above is wrong, please send a correction as an issue, pull request, or email. Note that if the list indicates a library works from both C/C++, but it doesn't, this could be an error in the list or it could be a bug in the library. If you find a library doesn't work in 32-bit or 64-bit, the library should be removed from this list, unless it's a bug in the library.

List FAQ

Can I link directly to this list?

Yes. This is the preferred link.

Why isn't library XXX which is made of 3 or more files on this list?

I draw the line arbitrarily at 2 files at most. (Note that some libraries that appear to be two files require a separate LICENSE file, which made me leave them out). Some of these libraries are still easy to drop into your project and build, so you might still be ok with them. But since people come to stb for single-file public domain libraries, I feel that starts to get too far from what we do here.

Why isn't library XXX which is at most two files and has minimal other dependencies on this list?

Probably because I don't know about it, feel free to submit a pull request, issue, email, or tweet it at me (it can be your own library or somebody else's). But I might not include it for various other reasons, including subtleties of what is 'minimal other dependencies' and subtleties about what is 'lightweight'.

Why isn't SQLite's amalgamated build on this list?

Come on.


Viewing all articles
Browse latest Browse all 25817

Trending Articles