Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds docs for watcher-c #53

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions watcher-c/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Using the watcher library from C

The watcher can also be used from C by including the `watcher-c.h` file on compilation and in your project.

You can cross compile the library via the `watcher-c/cross-compile.sh` script or download the precompiled library from
the releases.

### Compiling the library from source

If you want to compile the library yourself you can follow the following example:

First check out a branch or release, here we'll use the 'next' branch.
You can then compile the library with meson or a tool of your choice,
we will use `c++`.

```bash
AlliBalliBaba marked this conversation as resolved.
Show resolved Hide resolved
curl -L https://github.com/e-dant/watcher/archive/refs/heads/next.tar.gz | tar xz
cd watcher-next/watcher-c
c++ -o libwatcher-c.so ./src/watcher-c.cpp -I ./include -I ../include -std=c++17 -fPIC -shared
```

This gives us a `libwatcher-c.so` library that you can now install on your system.
In most container based environments you can just copy the library like this:

```bash
cp libwatcher-c.so /usr/local/lib/libwatcher-c.so
ldconfig
```

### Using the library in your C code

After installing the library, copy the `watcher-c.h` file to your project and include it in your C code:

```c
#include "watcher-c.h"
```

You will then be able to use the functions
[provided by the library](https://github.com/e-dant/watcher?tab=readme-ov-file#the-library).
Loading