Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » X windows Sytem code not working
X windows Sytem code not working [message #870018] Sat, 05 May 2012 14:04 Go to next message
Nick Krause is currently offline Nick Krause
Messages: 5
Registered: May 2012
Junior Member
#include<X11/Xlib.h>
#include<stdio.h>
#include<stdlib.h> // prevents error for exit on line 18 when compiling with gcc
void XOpenDisplay(Display *& d)
{
/* open connection with the server */
d=XOpenDisplay(NULL);
}

int main() {
Display *d;
int s;
Window w;
XEvent e;

/* open connection with the server */
XOpenDisplay(d);
if(d==NULL) {
printf("Cannot open display\n");
exit(1);
}
s=DefaultScreen(d);

/* create window */
w=XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1,
BlackPixel(d, s), WhitePixel(d, s));

Atom delWindow = XInternAtom( d, "WM_DELETE_WINDOW", 0 );
XSetWMProtocols(d , w, &delWindow, 1);

/* select kind of events we are interested in */
XSelectInput(d, w, ExposureMask | KeyPressMask);

/* map (show) the window */
XMapWindow(d, w);

/* event loop */
while(1) {
XNextEvent(d, &e);
/* draw or redraw the window */
if(e.type==Expose) {
XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
}
/* exit on key press */
if(e.type==KeyPress)
break;

// Handle Windows Close Event
if(e.type==ClientMessage)
break;
}

/* destroy our window */
XDestroyWindow(d, w);

/* close connection to server */
XCloseDisplay(d);

return 0;
}
Here is the code above it states that the functions have no references and is a bit of a pain. Can something please help me fix this as it would be greatly appreciated.
Re: X windows Sytem code not working [message #870205 is a reply to message #870018] Mon, 07 May 2012 05:17 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1949
Registered: July 2009
Senior Member
You have to link your application against the X libraries.
http://wiki.eclipse.org/CDT/User/FAQ#Adding_C.2FC.2B.2B_External_Libraries


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: X windows Sytem code not working [message #871334 is a reply to message #870205] Sat, 12 May 2012 02:34 Go to previous messageGo to next message
Nick Krause is currently offline Nick Krause
Messages: 5
Registered: May 2012
Junior Member
Tryed everything from google and what you told me to do it STILL isn't working for some reason.
Re: X windows Sytem code not working [message #871336 is a reply to message #871334] Sat, 12 May 2012 03:55 Go to previous messageGo to next message
Nick Krause is currently offline Nick Krause
Messages: 5
Registered: May 2012
Junior Member
Got it to work was really overthinking it ,all I ahdd to do was open the header file to get the other file read it and gain connection with it.
Re: X windows Sytem code not working [message #871371 is a reply to message #871336] Sat, 12 May 2012 11:48 Go to previous message
Nick Krause is currently offline Nick Krause
Messages: 5
Registered: May 2012
Junior Member
Still working even after adding it to the path just won't find it.
Previous Topic:Kernel Header Issues
Next Topic:Trying to be a Committer
Goto Forum:
  


Current Time: Fri Aug 01 04:05:36 EDT 2014

Powered by FUDForum. Page generated in 0.02189 seconds