Browse Source

docs: add compile commands

master
Dnomd343 1 year ago
parent
commit
ae267a7d32
  1. 8
      CMakeLists.txt
  2. 41
      README.md

8
CMakeLists.txt

@ -4,7 +4,13 @@ set(CMAKE_C_STANDARD 99)
project(tiny_thread_pool LANGUAGES C)
add_library(tiny_pool STATIC tiny_pool.c)
option(BUILD_DYN "build shared library" OFF)
if (BUILD_DYN)
add_compile_options(-fPIC)
add_library(tiny_pool SHARED tiny_pool.c)
else()
add_library(tiny_pool STATIC tiny_pool.c)
endif()
target_link_libraries(tiny_pool pthread)
add_subdirectory(demo/c)

41
READMD.md → README.md

@ -30,4 +30,45 @@ In addition, there is a `tiny_pool_kill`, this command will directly clear all t
### Compile
This project uses `CMake` to build and compile, you can use it to get started quickly, or manually call the compiler.
**CMake**
> This will build `libtiny_pool.a` static library and demo executable.
```bash
cmake -B cmake-build
cmake --build cmake-build
```
> This will build `libtiny_pool.so` dynamic library and demo executable.
```bash
cmake -B cmake-build -DBUILD_DYN=ON
cmake --build cmake-build
```
**GCC**
> Manually build the static library.
```bash
gcc -std=gnu99 -c tiny_pool.c -o libtiny_pool.a
```
> Build the demo and link the static library.
```bash
gcc demo/c/demo.c -o demo_c -I. -L. -ltiny_pool -lpthread
g++ demo/cpp/demo.cc -o demo_cpp -I. -L. -ltiny_pool -lpthread
```
> Manually build the dynamic library.
```bash
gcc -std=gnu99 -shared -fPIC -c tiny_pool.c -o libtiny_pool.so
```
### License
MIT ©2023 [@dnomd343](https://github.com/dnomd343)
Loading…
Cancel
Save