Skip to main content


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 18:04 Go to next message
Nick Krause is currently offline Nick KrauseFriend
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 09:17 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
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 06:34 Go to previous messageGo to next message
Nick Krause is currently offline Nick KrauseFriend
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 07:55 Go to previous messageGo to next message
Nick Krause is currently offline Nick KrauseFriend
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 15:48 Go to previous message
Nick Krause is currently offline Nick KrauseFriend
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: Thu Apr 18 01:52:01 GMT 2024

Powered by FUDForum. Page generated in 0.02407 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top