slibc  0.1.3
Educational C Standard Library Project
slibc Documentation

License: MPL 2.0 Tests

Shatter Libc

Shatter Libc (slibc) is C89 compliant Standard Library written for educational purposes.

Table of Contents

Building

To build, simply run cmake in a build directory, then run make

$ mkdir build
$ cd build
$ cmake -S .. -B .
$ make

Installing

To install slibc, you can run the install target.

$ make install

This will install the library and header files onto your system (/usr/local/lib/slibc and /usr/local/include/slibc by default). It will also install a slibc.conf into /etc/ld.so.conf.d and run ldconfig.

To uninstall slibc, you can either run

$ make uninstall

or manually uninstall the files described in install_manifest.txt, which is what make uninstall does by default.

Note:

make install and make uninstall may require elevated permissions to run correctly.

You may also need to set $PKG_CONFIG_PATH to the install directory of libslibc.pc and libslibc_start_main.pc (by default /usr/local/share/pkgconfig).

Running

There is an example program that can also be compiled and ran.

$ cd example
$ mkdir build
$ cd build
$ cmake -S .. -B .
$ make
$ ./example

This creates a program that is linked against slibc, which can be verified with

$ ldd example
linux-vdso.so.1 (...)
libslibc.so.1 => <install_dir>/libslibc.so.1 (...)

If you wish to use slibc to build your own projects, be sure to not link against stdlib and to not use stdinc.

Also ensure you include the header files for slibc and to dynamically link with libslibc.so and statically link with libslibc_start_main.a.

An example command would be

$ $CC -std=c89 -nostdlib -nostdinc -I<include_dir> -L<lib_dir> -lslibc -lslibc_start_main foo.c -o foo

Alternatively, the provided CMakeLists.txt in the example directory provides a good starting point to build your own projects.

Note

The execute_process is there to grab the LDFLAGS from pkg-config. Alternatively, you can instead have the following line

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib")

to not link with stdlib. The execute_process is there in the event additional linker flags are added.

Tests

In the tests directory there is a series of tests for each off the standard library functions. Testing these yourself is done similary to building and executing the example program.

$ cd tests
$ mkdir build
$ cd build
$ cmake -S .. -B .
$ make
$ ./tests

Note

Testing is incomplete/

Documentation

slibc also allows for the creation of documenation using doxygen and doxygen-awesome-css. To do so, simply run doxygen in the build directory of slibc after running cmake.

$ mkdir build
$ cd build
$ cmake -S .. -B .
$ doxygen

Documentation is also hosted at slibc.amberlagrange.com.

Note

Documentation is not complete.

Supported Platforms

Currently slibc only supports Linux x86_64, but plans to supports x86, and potentially Aarch64 in the future.

Other OSes will most likely not be supported.