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.

Share:
11,780

Related videos on Youtube

Dresel
Author by

Dresel

Updated on September 18, 2022

Comments

  • Dresel
    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
    Dresel over 12 years
    At 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 like Geany
  • David
    David about 3 years
    If 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 using cmake, not when using gcc with the -pthread flag. I just compiled cmake 3.16 from source and everything worked well