Problems when linking X programs

patrickl@bredband.net patrickl@bredband.net
Thu Feb 16 10:19:00 GMT 2006


I have a pretty recent installation of Cygwin + X on my laptop. I have installed the X11 libraries and latest gcc in order to build some X11 software that I've downloaded. So far I've failed...

I made this really short program to demonstrate my problems:

#include <X11/Xutil.h>
int main()
{
  Display* d = XOpenDisplay(NULL);
  return 0;
}

When I try to build this with the followin line:

gcc -o Xtest -L/usr/X11R6/lib -lX11 Xtest.cpp

This gives the following error:

Xtest.cpp: undefined reference to `_XOpenDisplay´

I've checked the following:
* libX11.dll.a is a link to libX11-6.dll.a
* libX11-6.dll.a contains the symbol _XOpenDisplay
* when I change the -L path to something bogus I get a 'File not found' error, so I'm pretty sure that gcc does find the libX11.dll.a file. (I've also used -Wl,-verbose and -Wl,-trace to verify this)

Finally, my solution so far... :
I've changed the link libX11.dll.a to point to /usr/X11R6/bin/cygX11-6.dll instead. This solves the problem, but not in a way that I'm happy with.

I've seen this problem reported on this list way back in 2001 (I think) but it never got any attention at all.

If anyone has some ideas on why this happens and how to solve it (more properly) then I'm all ears...

-- Patrick



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/



More information about the Cygwin-xfree mailing list