Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


#include <gtk/gtk.h>

int main(int argc, char *argv[]) {

  GtkWidget *window;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 

  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`
share|improve this question
up vote 4 down vote accepted

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|improve this answer
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 – user24665 Nov 18 '11 at 13:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.