gcc: -pthread: No such file or directory
11,780
It most likely means that your system doesn't have the development portion of the threading library installed. You can find out what thread -pthread
flag does on your platform with the following command:
gcc -dumpspecs | grep "%{pthread"
I get this:
%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
%{pthread:-lpthread} %{shared:-lc} %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}
Which means that -pthread
on my system adds -D_REENTRANT
and -lpthread
. So the missing file would be libpthread.sometihing
.
Related videos on Youtube
Author by
Dresel
Updated on September 18, 2022Comments
-
Dresel over 1 year
Trying to compile following code in terminal i got
gcc: -pthread: No such file or directory
,what does this error means and how to eliminate it?
file name: window.c
code:
#include <gtk/gtk.h> int main(int argc, char *argv[]) { GtkWidget *window; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); gtk_main(); return 0; }
I tried to compile it with following parameters:-
gcc -Wall -g window.c -o window `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
-
Dresel over 12 yearsAt this point, the terminal compiles fine. But the error message still shows up when i try to compile the source through
Shell Script
or IDEs likeGeany
-
David about 3 yearsIf somebody gets here many years later as it happened to me, I describe my solution. I was getting the same error as the OP when compiling from CLion using a docker container based on ubuntu 18.04 (which comes with
cmake 3.10
in the repositories). The problem really only appeared when usingcmake
, not when usinggcc
with the-pthread
flag. I just compiledcmake 3.16
from source and everything worked well