Posez votre question Signaler

[Linux][XLib] Erreur compilation

tito - Dernière réponse le 22 avril 2003 à 17:42
Bonjour,
Pourriez vous me dire ce qui cloche dans mon programme ????SVP
Lorsque je compile sur linux il me dit qu'il y un problème avec XCopyArea Mais je ne voit pas ...


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

GC gc;
Display *display;
int screen,dest_x,dest_y;
Window wina, winb, root;
unsigned long white_pixel, black_pixel;
XSetWindowAttributes attrib;
unsigned long mask_attrib;
int largf,hautf;
Drawable fenetre,src,dest;
int x,y;
unsigned int larg,haut;

int prof;
Pixmap pix;
int i;

main() {
if ((display = XOpenDisplay ("")) == NULL) {
fprintf (stderr, "Can't open Display\n");
exit (1);
}

x=10;y=10;
larg=40;
haut=40;
largf=300;
hautf=300;
gc = DefaultGC (display, screen);
screen = DefaultScreen (display);
root = RootWindow (display, screen);
white_pixel = WhitePixel (display, screen);
black_pixel = BlackPixel (display, screen);
wina = XCreateSimpleWindow (display, root,
0, 0, largf, hautf, 5, black_pixel, white_pixel);


XSelectInput (display, wina, ButtonPressMask);
XStoreName (display, wina, "gravity_S");


prof = XDefaultDepth (display, screen);
pix = XCreatePixmap (display, root, 100, 40, prof);

XMapWindow (display, wina);

XSync (display, 0);
XCopyArea (display, winb, pix, gc, 0, 0, 100, 40, 0, 0);
XFillArc(display,winb,gc,i,y,larg,haut,0,360*64);

winb = XCreateSimpleWindow (display, root,
0, 0, largf, hautf, 5, black_pixel, white_pixel);
XSelectInput (display, winb, ButtonPressMask);
XStoreName (display, winb, "gravity_NW");
XMapWindow (display, winb);
attrib.bit_gravity = SouthWestGravity;
mask_attrib = CWBitGravity;
XChangeWindowAttributes(display, wina, mask_attrib, &attrib);
attrib.bit_gravity = SouthWestGravity;
XChangeWindowAttributes(display, winb, mask_attrib, &attrib);



for (;;) {
XEvent ev;
XNextEvent (display, &ev);
switch (ev.type) {
case ButtonPress :
// if (ev.xbutton.window==wina)
// {
//XClearWindow (display, wina);

XFillArc(display,winb,gc,x,y,larg,haut,0,360*64);

//if (ev.xbutton.window==winb)
// {

for (i=0;i<largf;i++){
XClearWindow (display, winb);
XFillArc(display,winb,gc,i,y,larg,haut,0,360*64);
//sleep(2);
XCopyArea (display, pix, winb, gc, 0, 0, 100, 40, i,y);
}
break;
default :
break;
}
}
}
Lire la suite 

[Linux][XLib] Erreur compilation »

3 réponses
Réponse
+0
moins plus
Bonjour,
Est-ce que ton source compile?
Je peux comiler chez moi. C'est à l'exécution qu'il ya un problème.
Je regarderai en détail quand j'ai le temps...
[johand@zoot] ~/src/c/X11 $gcc -o test01
-I /usr/X11R6/include/X11/ -L /usr/X11R6/lib/ test01.c -lX11
[johand@zoot] ~/src/c/X11 $./test01
X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
Major opcode of failed request: 62 (X_CopyArea)
Resource id in failed request: 0x0
Serial number of failed request: 14
Current serial number in output stream: 21

Johan

The software said "Requires Windows98, Win2000, or better,
So I installed Unix.
pouet - 22 avril 2003 à 17:42
compiler sans -Wall c est mal.
Ajouter un commentaire
Réponse
+0
moins plus
ton code ne compile pas:
guillaume@fallen:~/XLIB$ gcc -Wall -Werror -I/usr/X11R6/include test2.c -L/usr/X11R6/lib/ -lX11 -o pouet
cc1: warnings being treated as errors
test2.c:21: warning: return type defaults to `int'
test2.c: In function `main':
test2.c:24: warning: implicit declaration of function `exit'
alors tu ajoutes
#include <stdlib.h>
pour exit()
tu mets main a la norme:
int main()
{
...
return 0;
}

et la magique ca compile:
guillaume@fallen:~/XLIB$ gcc -Wall -Werror -I/usr/X11R6/include test2.c -L/usr/X11R6/lib/ -lX11 -o pouet
guillaume@fallen:~/XLIB$
ca tu aurais du le faire avant de poster.

pour ton probleme lie a XCopyArea, le man te dit:
XCopyPlane can generate BadDrawable, BadGC, BadMatch, and BadValue errors.
BadDrawable
A value for a Drawable argument does not name a defined Window or Pixmap.
alors la tu te dis: "ho! j ai du oublier d initialiser un de mes Drawable - soit winb soit pix - avant d utiliser cette fonction.
tu verifies, tu corriges et ca marche.
Ajouter un commentaire
Ce document intitulé « [Linux][XLib] Erreur compilation » issu de CommentCaMarche (www.commentcamarche.net) est mis à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de cette page, dans les conditions fixées par la licence, tant que cette note apparaît clairement.
Dossier à la une
Passage au tout numérique : quel coût pour les particuliers ?