Single-file public-domain/open source libraries with minimal dependencies
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:
- 2D graphics
- 3D graphics
- 3D geometry file processing
- AI
- argument processing
- audio
- compression
- cryptography
- data structures
- files and filenames
- hardware interfacing
- image loading, saving, & processing
- mathematics for geometry
- mathematics
- miscellaneous
- multithreading
- networking
- parsing
- profiling
- scripting
- string processing
- tests
- user interface
- video
AI
library | license | API | files | description | micropatherzlibC++2pathfinding with A*GenannzlibC/C++2simple neural networks (ANN)argv
library | license | API | files | description | pargpublic domainC1command-line argument parsingaudio
library | license | API | files | description | aw_ima.hMITC/C++1IMA-ADPCM audio decoderdr_flacpublic domainC/C++1FLAC audio decoderdr_wavpublic domainC/C++1WAV audio loadersts_mixerpublic domainC/C++1simple stereo audio mixercompression
library | license | API | files | description | miniz.cpublic domainC/C++1compression,decompression, zip file, png writinglz4BSDC/C++2fast but larger LZ compressionfastlzMITC/C++2fast but larger LZ compressionpithyBSDC/C++2fast but larger LZ compressionmicrotarMITC/C++2lightweight tar librarycrypto
library | license | API | files | description | TweetNaClpublic domainC2high-quality tiny cryptography librarydata structures
library | license | API | files | description | klibMITC/C++2many 2-file libs: hash, sort, b-tree, etcuthashBSDC/C++2several 1-header, 1-license-file libs: generic hash, list, etcPackedArrayWTFPLv2C2memory-efficient array of elements with non-pow2 bitcountminilibspublic domainC2two-file binary tress (also regex, etc)DG_dynarr.hpublic domainC/C++1typesafe dynamic arrays (like std::vector) for plain Cchobo-shlMITC++1several C++11 standard contaner like libraries and helpersfiles & filenames
library | license | API | files | description | DG_misc.hpublic domainC/C++1Daniel Gibson's stb.h-esque cross-platform helpers: path/file, stringswhereamiWTFPLv2C/C++2get path/filename of executable or moduledirentMITC/C++1dirent for windows: retrieve file & dir infoTinyDirBSDC1cross-platform directory readergeometry file
library | license | API | files | description | tk_objfileMITC/C++1OBJ file loadertinyplypublic domainC++2PLY mesh file loadertinyobjloaderMITC++1wavefront OBJ file loadertinyobjloader-cMITC1wavefront OBJ file loaderyocto_obj.hMITC/C++1wavefront OBJ file loadergeometry math
library | license | API | files | description | nv_voronoi.hpublic domainC/C++1find voronoi regions on lattice w/ integer inputssobol.hpublic domainC/C++1sobol & stratified sampling sequencessdf.hMITC/C++1compute signed-distance field from antialiased imagenanoflannBSDC++1build KD trees for point cloudsjc_voronoiMITC/C++1find voronoi regions on float/double datapar_msquaresMITC/C++1convert (binarized) image to trianglespar_shapesMITC/C++1generate various 3d geometric shapesTomas Akenine-Moller snippetspublic domainC/C++2various 3D intersection calculations, not lib-ifiedClipperBoostC++2line & polygon clipping & offsettingPolyPartitionMITC++2polygon triangulation, partitioningVoxelizerMITC/C++1convert triangle mesh to voxel triangle meshyocto_bvh.hMITC/C++1ray-casting and closest-element queries of bounding-volume hierarchyyocto_shape.hMITC/C++1shape generation, tesselation, normals, etc.rjmpublic domainC/C++1marching cubes triangulatorgraphics (2d)
library | license | API | files | description | blendishMITC/C++1blender-style widget rendering using NanoVGtigrpublic domainC/C++2quick-n-dirty window text/graphics for Windows and OSXnoc_turtleMITC/C++2procedural graphics generatorgraphics (3d)
library | license | API | files | description | yocto_trace.hMITC/C++1physically-based unidirectional path tracer w/ MIS for direct lightsyocto_symrigid.hMITC/C++1rigid body simulator (sequential impulse/PGS) with support for concave objectsmikktspacezlibC/C++2compute tangent space for normal mappingdebug-drawpublic domainC++1API-agnostic immediate-mode debug renderinglightmapperpublic domainC/C++1use your OpenGL renderer to offline bake lightmapshardware
library | license | API | files | description | EasyTabpublic domainC/C++1multi-platform tablet inputimages
library | license | API | files | description | 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 encodergif_loadpublic domainC/C++1(animated) GIF readerminiexrpublic domainC++2OpenEXR writer, needs header filetinyexrBSDC/C++1EXR image read/write, uses miniz internallylodepngzlibC/C++2PNG encoder/decodernanoSVGzlibC/C++11-file SVG parser; 1-file SVG rasterizerpicopng.cppzlibC++2tiny PNG loaderjpeg-compressorpublic domainC++22-file jpeg compress, 2-file jpeg decompresseasyexifMITC++2EXIF metadata extractor for JPEG imagescro_mipmap.hpublic domainC/C++1average, min, max mipmap generatorsPDFgenpublic domainC2PDF writermath
library | license | API | files | description | mm_vec.hBSDC/C++1SIMD vector mathHandmade Mathpublic domainC/C++1vector mathgb_mathpublic domainC/C++1Vector, quaternion and matrix math w/o math.hccVector.hpublic domainC/C++1Vector, quaternion and matrix mathShaderFastLibsMITC++1(also HLSL) approximate transcendental functions optimized for shaders (esp. GCN)TinyExprzlibC2evaluation of math expressions from stringslinalg.hunlicenseC++1vector/matrix/quaternion mathPoissonGenerator.hMITC++1Poisson disk points generator (disk or rect)prns.hpublic domainC/C++1seekable pseudo-random number sequencesaomebaMITC/C++1constraint solver (Cassowary) w/Lua bindingmultithreading
library | license | API | files | description | mm_sched.hzlibC/C++1cross-platform multithreaded task scheduler based on enkiTSnetwork
library | license | API | files | description | zed_netpublic domainC/C++1cross-platform socket wrappersts_netpublic domainC/C++1cross-platform socket wrapper (socket sets and packet API)mm_web.hBSDC/C++1lightweight webserver, fork of webbypar_easycurl.hMITC/C++1curl wrapperyoctopublic domainC/C++2non-production-use http serverhappyhttpzlibC++2http client requestsmongooseGPLv2C/C++2http serverLUrlParserMITC++2lightweight URL & URI parser RFC 1738, RFC 3986znetMITC/C++1cross-platform networking w/ lua bindingparsing
library | license | API | files | description | SLREGPLv2C/C++1regular expression matcherPicoJSONBSDC++1JSON parse/serializermm_lexer.hzlibC/C++1C-esque language lexerjson.hpublic domainC/C++2JSON parserjzon.hMITC++2JSON parserparsonMITC/C++2JSON parser and serializerminilibspublic domainC2two-file regex (also binary tree, etc)profiling
library | license | API | files | description | RemoteryApache 2.0C/C++2CPU/GPU profiler Win/Mac/Linux, using web browser for viewerMicroProfileunlicenseC++2-4CPU (and GPU?) profiler, 1-3 header files, uses miniz internallyscripting
library | license | API | files | description | LILzlibC/C++2interpreter for a Tcl-like scripting languagelualiteMITC++1generate lua bindings in C++PicolBSDC/C++1interpreter for a Tcl-like scripting languagestrings
library | license | API | files | description | DG_misc.hpublic domainC/C++1Daniel Gibson's stb.h-esque cross-platform helpers: path/file, stringsutf8public domainC/C++1utf8 string librarystrpool.hpublic domainC/C++1string interningdfaMITC/C++2fast utf8 decoder (need a header file)gb_string.hpublic domainC/C++1dynamic stringstests
library | license | API | files | description | utestMITC/C++1unit testingcatchBoostC++1unit testingdoctestMITC++1unit testingSPUTBSDC/C++1unit testingpempek_assert.cppWTFPLv2C++2flexible assertionsminctestzlibC1unit testinggreatestiSCC1unit testingµnitMITC1unit testinglabratpublic domainC/C++1unit testinguser interface
library | license | API | files | description | dear imguiMITC++9an immediate-mode GUI formerly named "ImGui"; 3rd-party C wrappernuklearpublic domainC/C++1minimal GUI toolkitnoc_file_dialog.hMITC/C++1file open/save dialogs (Linux/OSX/Windows)tinyfiledialogsZLIBC/C++2modal dialogs inc. file open/save (Linux/OSX/Windows)video
library | license | API | files | description | jo_mpegpublic domainC++1mpeg file writermiscellaneous
library | license | API | files | description | MakeID.hpublic domainC++1allocate/deallocate small integer IDs efficientlylogurupublic domainC++1flexible loggingtinyformatBoostC++1typesafe printfdebug-assertzlibC++1modular assertion macrodbgtoolszlibC/C++2cross-platform debug util librariesstmrMITC2extract English word stemslevenshteinMITC2compute edit distance between two stringsThere are also these XML libraries, but if you're using XML, shame on you:
- parsing: tinyxml2: XML
- parsing: pugixml: XML (MIT license)
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.
0 0