What does “Performing Test CMAKE_HAVE_LIBC_PTHREAD” failed actually mean?

The lines — Looking for pthread.h — Looking for pthread.h – found — Performing Test CMAKE_HAVE_LIBC_PTHREAD — Performing Test CMAKE_HAVE_LIBC_PTHREAD – Failed — Looking for pthread_create in pthreads — Looking for pthread_create in pthreads – not found — Looking for pthread_create in pthread — Looking for pthread_create in pthread – found are output of a …

Read more

Mutex lock threads

What you need to do is to call pthread_mutex_lock to secure a mutex, like this: pthread_mutex_lock(&mutex); Once you do this, any other calls to pthread_mutex_lock(mutex) will not return until you call pthread_mutex_unlock in this thread. So if you try to call pthread_create, you will be able to create a new thread, and that thread will …

Read more

when g++ static link pthread, cause Segmentation fault, why?

First, the solution. This here will work: Update: Since Ubuntu 18.04, you need to link also against librt (add -lrt): g++ -o one one.cpp -Wall -std=c++11 -O3 -static -lrt -pthread \ -Wl,–whole-archive -lpthread -Wl,–no-whole-archive (continue with original answer) g++ -o one one.cpp -Wall -std=c++11 -O3 -static -pthread \ -Wl,–whole-archive -lpthread -Wl,–no-whole-archive When you use -pthread, …

Read more

How to continue one thread at a time when debugging a multithreaded program in GDB?

By default, GDB stops all threads when any breakpoint is hit, and resumes all threads when you issue any command (such as continue, next, step, finish, etc.) which requires that the inferior process (the one you are debugging) start to execute. However, you can tell GDB not to do that: (gdb) help set scheduler-locking Set …

Read more

How to restrict gdb debugging to one thread at a time

As TazMainiac said, scheduler-locking is useful for single stepping, but the “mode” must be set to “step”. set scheduler-locking step You can refer the link provided by TazMainiac which mentions the same: http://ftp.gnu.org/old-gnu/Manuals/gdb-5.1.1/html_node/gdb_39.html The step mode optimizes for single-stepping. It stops other threads from “seizing the prompt” by preempting the current thread while you are …

Read more