{"id":15107106,"url":"https://github.com/shadowsocks/libcork","last_synced_at":"2025-09-27T05:31:33.769Z","repository":{"id":65979111,"uuid":"79292465","full_name":"shadowsocks/libcork","owner":"shadowsocks","description":"A simple, easily embeddable cross-platform C library","archived":false,"fork":true,"pushed_at":"2020-04-03T00:46:22.000Z","size":1482,"stargazers_count":21,"open_issues_count":0,"forks_count":54,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2024-12-08T01:01:25.257Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://libcork.readthedocs.org/","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"dcreager/libcork","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shadowsocks.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-18T01:52:43.000Z","updated_at":"2024-10-10T22:01:34.000Z","dependencies_parsed_at":"2023-02-19T19:00:56.190Z","dependency_job_id":null,"html_url":"https://github.com/shadowsocks/libcork","commit_stats":null,"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowsocks%2Flibcork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowsocks%2Flibcork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowsocks%2Flibcork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shadowsocks%2Flibcork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shadowsocks","download_url":"https://codeload.github.com/shadowsocks/libcork/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234391381,"owners_count":18824810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-25T21:04:31.843Z","updated_at":"2025-09-27T05:31:33.376Z","avatar_url":"https://github.com/shadowsocks.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libcork\n\n[![Build Status](https://img.shields.io/travis/redjack/libcork/develop.svg)](https://travis-ci.org/redjack/libcork)\n\nSo what is libcork, exactly?  It's a “simple, easily embeddable,\ncross-platform C library”.  It falls roughly into the same category as\n[glib](http://library.gnome.org/devel/glib/) or\n[APR](http://apr.apache.org/) in the C world; the STL,\n[POCO](http://pocoproject.org/), or [QtCore](http://qt.nokia.com/)\nin the C++ world; or the standard libraries of any decent dynamic\nlanguage.\n\nSo if libcork has all of these comparables, why a new library?  Well,\nnone of the C++ options are really applicable here.  And none of the C\noptions work, because one of the main goals is to have the library be\nhighly modular, and useful in resource-constrained systems.  Once we\ndescribe some of the design decisions that we've made in libcork, you'll\nhopefully see how this fits into an interesting niche of its own.\n\n## Using libcork\n\nThere are two primary ways to use libcork in your own software project:\nas a _shared library_, or _embedded_.\n\nWhen you use libcork as a shared library, you install it just like you\nwould any other C library.  We happen to use CMake as our build system,\nso you follow the usual CMake recipe to install the library.  (See the\n[INSTALL](INSTALL) file for details.)  All of the libcork code is\ncontained within a single shared library (called libcork.so,\nlibcork.dylib, or cork.dll, depending on the system).  We also install a\npkg-config file that makes it easy to add the appropriate compiler flags\nin your own build scripts.  So, you use pkg-config to find libcork's\ninclude and library files, link with libcork, and you're good to go.\n\nThe alternative is to embed libcork into your own software project's\ndirectory structure.  In this case, your build scripts compile the\nlibcork source along with the rest of your code.  This has some\nadvantages for resource-constrained systems, since (assuming your\ncompiler and linker are any good), you only include the libcork routines\nthat you actually use.  And if your toolchain supports link-time\noptimization, the libcork routines can be optimized into the rest of\nyour code.\n\nWhich should you use?  That's really up to you.  Linking against the\nshared library adds a runtime dependency, but gives you the usual\nbenefits of shared libraries: the library in memory is shared across\neach program that uses it; you can install a single bug-fix update and\nall libcork programs automatically take advantage of the new release;\netc.  The embedding option is great if you really need to make your\nlibrary as small as possible, or if you don't want to add that runtime\ndependency.\n\n## Design decisions\n\nNote that having libcork be **easily** embeddable has some ramifications\non the library's design.  In particular, we don't want to make any\nassumptions about which build system you're embedding libcork into.  We\nhappen to use CMake, but you might be using autotools, waf, scons, or\nany number of others.  Most cross-platform libraries follow the\nautotools model of performing some checks at compile time (maybe during\na separate “configure” phase, maybe not) to choose the right API\nimplementation for the current platform.  Since we can't assume a build\nsystem, we have to take a different approach, and do as many checks as\nwe can using the C preprocessor.  Any check that we can't make in the\npreprocessor has to be driven by a C preprocessor macro definition,\nwhich you (the libcork user) are responsible for checking for and\ndefining.  So we need to have as few of those as possible.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowsocks%2Flibcork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshadowsocks%2Flibcork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshadowsocks%2Flibcork/lists"}