https://github.com/bensuperpc/c_plugin
An example for a C (C99) plugin system. It can load/unload plugins at runtime and call functions from them.
https://github.com/bensuperpc/c_plugin
c c99 dlopen linux plugin
Last synced: about 2 months ago
JSON representation
An example for a C (C99) plugin system. It can load/unload plugins at runtime and call functions from them.
- Host: GitHub
- URL: https://github.com/bensuperpc/c_plugin
- Owner: bensuperpc
- License: gpl-2.0
- Created: 2023-03-03T19:32:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T18:35:17.000Z (over 3 years ago)
- Last Synced: 2025-02-02T02:11:06.948Z (over 1 year ago)
- Topics: c, c99, dlopen, linux, plugin
- Language: C
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# c_plugin
## Getting started
An example for a C (C99) plugin system. It can load/unload plugins at runtime and call functions from them.
### Prerequisites
- [Make](https://www.gnu.org/software/make/)
- [GCC](https://gcc.gnu.org/)
- [Linux](https://www.linux.org/) (or [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10) on Windows).
## Building
To build the project:
```bash
make
```
To build and test the project:
```bash
make test
```
## Usage
To run the project and load the plugin1:
__Note:__ You can change the plugin name to load another plugin (*plugin2*).
```bash
./build/main build/plugin1
```
## Contributing
If you want to contribute to this project, you can do it by opening a pull request or an issue.
## Open source projects used
- [Make](https://www.gnu.org/software/make/)
- [gcc](https://github.com/gcc-mirror/gcc)
- [actions](https://github.com/actions/virtual-environments)
## Sources and references
- [linux-dlopen-system-call-c](https://linuxhint.com/linux-dlopen-system-call-c/)
- [dlopen_sample.c](https://gist.github.com/tailriver/30bf0c943325330b7b6a)
- [alternatives-to-dlsym-and-dlopen-in-c](https://stackoverflow.com/questions/1067346/alternatives-to-dlsym-and-dlopen-in-c)
- [sample-cpp-plugin](https://github.com/caiorss/sample-cpp-plugin/blob/master/main.cpp)
- [how-much-overhead-can-the-fpic-flag-add](https://stackoverflow.com/questions/15861759/how-much-overhead-can-the-fpic-flag-add)
## Licensing
See the [LICENSE](LICENSE) document.