mirror of
https://github.com/theoludwig/libcproject.git
synced 2024-11-08 22:31:31 +01:00
C static library for learning purposes. Implement useful functions/data structures while being easier to use than
libc
(C standard library).
https://libcproject.vercel.app/
lib | ||
test | ||
.clang-format | ||
.gitignore | ||
libcproject.h | ||
LICENSE | ||
main.c | ||
Makefile | ||
README.md |
libcproject
About
libcproject
is a C static library for learning purposes. It tries to implement useful functions/data structures while being easier to use than libc
(C standard library) as much as possible.
Prerequisites
For example on GNU/Linux Ubuntu:
sudo apt-get install build-essential gcc make clang-format
Usage
Steps to create a new C project that uses libcproject
:
Step 1: Compile libcproject
make
Step 2: Create a new project
mkdir my-project
cd my-project
Step 3: Install libcproject
in the project
mkdir libcproject
cp --recursive <path-to-libcproject> ./ # copy
# or
ln -s <path-to-libcproject> ./ # symbolic link
Step 4: Create a new C file
touch main.c
#include <stdio.h>
#include <stdlib.h>
#include "libcproject/libcproject.h"
int main() {
char* string = "Hello, world!";
printf("%s\n", string);
printf("string_length = %ld\n", string_get_length(string)); // `string_get_length` is a function from `libcproject`
return EXIT_SUCCESS;
}
Step 5: Compile your project and link it with the library
gcc -o ./main.exe ./main.c -L. -l:./libcproject/build/libcproject.a
Contributing
make # to compile
make run # to run main
make test # to run unit tests
make lint # to lint the code
make clean # to clean up
nm ./build/libcproject.a # to see the symbols