• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.buzzy/H24-Jul-2019-

.travis/H24-Jul-2019-

cmake/H24-Jul-2019-

docs/H03-May-2022-

extras/H24-Jul-2019-

include/libcork/H03-May-2022-

share/valgrind/H03-May-2022-

src/H03-May-2022-

tests/H03-May-2022-

.gitignoreH A D24-Jul-2019120

.travis.ymlH A D24-Jul-2019395

COPYINGH A D24-Jul-20191.5 KiB

INSTALLH A D24-Jul-20191.7 KiB

Makefile.amH A D03-May-20221 KiB

README.markdownH A D24-Jul-20193.5 KiB

make-dist.shH A D24-Jul-2019238

run.shH A D24-Jul-2019976

version.shH A D24-Jul-20191.1 KiB

README.markdown

1# libcork
2
3[![Build Status](https://img.shields.io/travis/redjack/libcork/develop.svg)](https://travis-ci.org/redjack/libcork)
4
5So what is libcork, exactly?  It's a “simple, easily embeddable,
6cross-platform C library”.  It falls roughly into the same category as
7[glib](http://library.gnome.org/devel/glib/) or
8[APR](http://apr.apache.org/) in the C world; the STL,
9[POCO](http://pocoproject.org/), or [QtCore](http://qt.nokia.com/)
10in the C++ world; or the standard libraries of any decent dynamic
11language.
12
13So if libcork has all of these comparables, why a new library?  Well,
14none of the C++ options are really applicable here.  And none of the C
15options work, because one of the main goals is to have the library be
16highly modular, and useful in resource-constrained systems.  Once we
17describe some of the design decisions that we've made in libcork, you'll
18hopefully see how this fits into an interesting niche of its own.
19
20## Using libcork
21
22There are two primary ways to use libcork in your own software project:
23as a _shared library_, or _embedded_.
24
25When you use libcork as a shared library, you install it just like you
26would any other C library.  We happen to use CMake as our build system,
27so you follow the usual CMake recipe to install the library.  (See the
28[INSTALL](INSTALL) file for details.)  All of the libcork code is
29contained within a single shared library (called libcork.so,
30libcork.dylib, or cork.dll, depending on the system).  We also install a
31pkg-config file that makes it easy to add the appropriate compiler flags
32in your own build scripts.  So, you use pkg-config to find libcork's
33include and library files, link with libcork, and you're good to go.
34
35The alternative is to embed libcork into your own software project's
36directory structure.  In this case, your build scripts compile the
37libcork source along with the rest of your code.  This has some
38advantages for resource-constrained systems, since (assuming your
39compiler and linker are any good), you only include the libcork routines
40that you actually use.  And if your toolchain supports link-time
41optimization, the libcork routines can be optimized into the rest of
42your code.
43
44Which should you use?  That's really up to you.  Linking against the
45shared library adds a runtime dependency, but gives you the usual
46benefits of shared libraries: the library in memory is shared across
47each program that uses it; you can install a single bug-fix update and
48all libcork programs automatically take advantage of the new release;
49etc.  The embedding option is great if you really need to make your
50library as small as possible, or if you don't want to add that runtime
51dependency.
52
53## Design decisions
54
55Note that having libcork be **easily** embeddable has some ramifications
56on the library's design.  In particular, we don't want to make any
57assumptions about which build system you're embedding libcork into.  We
58happen to use CMake, but you might be using autotools, waf, scons, or
59any number of others.  Most cross-platform libraries follow the
60autotools model of performing some checks at compile time (maybe during
61a separate “configure” phase, maybe not) to choose the right API
62implementation for the current platform.  Since we can't assume a build
63system, we have to take a different approach, and do as many checks as
64we can using the C preprocessor.  Any check that we can't make in the
65preprocessor has to be driven by a C preprocessor macro definition,
66which you (the libcork user) are responsible for checking for and
67defining.  So we need to have as few of those as possible.
68