Build with MinGW GCC, link to Cygwin libs, program doesn't work

Daniel Orzechowski
Mon Sep 12 21:21:00 GMT 2005

I've built a simple application by compiling the source with the MinGW 
version of GCC 3.3.1 , and linking to the regular Cygwin X11 libraries.


#include <stdio.h>
#include <stdlib.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>

int main(int argc, char *argv[])
     Display *display;

     printf("hello world\n");
     display = XOpenDisplay(":0.0");

     if (display == NULL)
         fprintf(stderr, "can't connect to X server\n");

     printf("connected ok\n");


My C_INCLUDE_PATH environment variable points to the 
c:\cygwin\usr\X11R6\include , and my LIBRARY_PATH variable points to 
c:\cygwin\usr\X11R6\lib .

After calling
 > gcc -o test test.c -lX11-6
the code compiles and links successfully.  I run XWin.exe (which works 
properly; I am able to use xeyes, xfontsel, etc.) and then launch my 
program.  It gets stuck on the call to XOpenDisplay(), and does nothing but 
run the CPU up to 99% load until I send it a Ctrl-C.

I'm not very familiar with Cygwin, and wouldn't know where to start looking 
to troubleshoot this.  Has anyone ever experienced anything similar to this 
problem, or know where I could look to get started?  I skimmed the FAQ but 
didn't seem to find anything relevant.

Thanks in advance for any help.

- Dan

(Switching compilers or Cygwin versions isn't really possible, since our 
customer is dictating what build environment we use.  I'm attempting to use 
the Cygwin X libraries since we're evaluating alternatives to the 
commercial off-the-shelf X server and client software we're currently using.)

Unsubscribe info:
Problem reports:

More information about the Cygwin-xfree mailing list