Skip to content

caprese-project/libc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Standard C/C++ Library Template

This library implements only the OS-independent parts of the C and C++ standard libraries. By adding OS-dependent functions, it can be made to run on any system. This allows for the use of functions and classes that are only supported in the host environment, even on custom OSes that do not conform to common APIs such as POSIX or WASI.

How to Use

Installing Locally

To use the library, you can install it locally on your system. Here's how you can do that:

Prerequisites

Before installing, make sure you have installed all of the following:

  • CMake version 3.20 or higher
  • Ninja

Download the Source Code

You can download the source code from GitHub at https://github.com/caprese-project/libc

git clone https://github.com/caprese-project/libc

Build and Install

Once you have the source code, you can build and install the library with the following commands:

cmake -B build -G Ninja -DCMAKE_C_COMPILER:FILEPATH=/path/to/your/c-compiler
cmake --build build
sudo cmake --install build

This will install the library to the default system location (e.g. /usr/local/). If you want to install it to a different location, you can use the --prefix option:

sudo cmake --install build --prefix /path/to/install/prefix

Using with FetchContent

Alternatively, you can use CMake's FetchContent module to incorporate the library into your project without a local installation. Here's an example of how to do that:

  1. Add the following to your project's CMakeLists.txt file:
include(FetchContent)

FetchContent_Declare(
  caprese_libc
  GIT_REPOSITORY https://github.com/caprese-project/libc
  GIT_TAG        master # or any other tag or commit hash
)
FetchContent_MakeAvailable(caprese_libc)
  1. Then, you can link against the library as you normally would with target_link_libraries:
target_link_libraries(your_target PRIVATE caprese_libc)

Note

  • This library is provided as a template, and developers can customize it as needed.
  • Implementations such as string.h are OS-independent and are provided as a template, but OS-dependent parts need to be implemented by the developer.

Releases

No releases published

Packages

No packages published