Maratyszcza / pthreadpool

Portable (POSIX/Windows/Emscripten) thread pool for C/C++
BSD 2-Clause "Simplified" License
342 stars 132 forks source link

How to use this library? #18

Closed lucky9-cyou closed 2 years ago

lucky9-cyou commented 2 years ago

I am very sorry to bother you. I would like to ask what files I need to add to my include and src folders if I want to use your thread pool, and what changes I need to make to my cmakelists.txt. I am not very familiar with cmake, just that I need to use the thread pool for my my parallel computing homework and I will indicate the source of this thread pool in my homework. Thank you very much!

ur4t commented 2 years ago

PTHREADPOOL_LIBRARY_TYPE controls how this library is built, shared or static (default to static). For Debian users, since Debian 11 (bullseye), libpthreadpool-dev is available in the main repo. Here is a sample CMakeLists.txt for the example addition.c:

cmake_minimum_required(VERSION 3.10)
project(addition)
# --- the following two lines are required when the library is manually built but not installed.
include_directories(+++PATH_TO_LIBRARY_INCLUDE_DIRECTORY+++)
link_directories(+++PATH_TO_LIBRARY_BUILD_DIRECTORY+++)
# ---
add_executable(addition addition.c)
target_link_libraries(addition pthreadpool pthread) # pthread is required for a statically built library
lucky9-cyou commented 2 years ago

Ok, thank you very much for your answer