From ee2eecf6a2f55e85106c72cfccef416fc8db35a3 Mon Sep 17 00:00:00 2001 From: Arthur-Coppey Date: Thu, 10 Mar 2022 16:51:55 +0100 Subject: [PATCH] pthreads test with the compiler options now --- CMakeLists.txt | 7 ++++++- main.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bb56d9..fd6c96f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,4 +3,9 @@ project(qotd C) set(CMAKE_C_STANDARD 99) -add_executable(qotd main.c quote.c quote.h server.c server.h config.h) \ No newline at end of file +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +set(THREADS_PREFER_PTHREAD_FLAG TRUE) +find_package(Threads REQUIRED) + +add_executable(qotd main.c quote.c quote.h server.c server.h config.h) +target_link_libraries(qotd Threads::Threads) \ No newline at end of file diff --git a/main.c b/main.c index cb7a0fa..809add9 100644 --- a/main.c +++ b/main.c @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) { pthread_create(&threadHandle, &attr, (void *(*)(void *)) threadTest, "a"); void * ret; pthread_join(threadHandle, &ret); - puts(ret); + printf("%d", ret); // server(1, 1); return 0;