当前位置: 技术问答>linux和unix
麻烦大家看看这个cygwin的编译的c程序怎么有这些错误?
来源: 互联网 发布时间:2016-11-08
本文导语: cygwin里面写下如下程序: 程序如下 #include // X11 library headers #include #include #define X_RESN 800 /* x resolution */ #define Y_RESN 800 /* y resolution */ #include int main (int argc, char **argv ) { /* -------------------------...
cygwin里面写下如下程序:
程序如下
程序如下
#include // X11 library headers
#include
#include
#define X_RESN 800 /* x resolution */
#define Y_RESN 800 /* y resolution */
#include
int main (int argc, char **argv ) {
/* --------------------------- X11 graphics setup ------------------------------ */
Window win; /* initialization for a window */
unsigned int width, height, /* window size */
win_x,win_y, /* window position */
border_width, /* border width in pixels */
display_width, display_height, /* size of screen */
screen; /* which screen */
char *window_name = "My graphics program", *display_name = NULL;
GC gc;
unsigned long valuemask = 0;
XGCValues values;
Display *display;
XSizeHints size_hints;
Pixmap bitmap;
XPoint points[800];
FILE *fp, *fopen ();
char str[100];
XSetWindowAttributes attr[1];
if ( (display = XOpenDisplay (display_name)) == NULL ) { /* connect to Xserver */
fprintf (stderr, "drawon: cannot connect to X server %sn",XDisplayName (display_name) );
exit (-1);
}
screen = DefaultScreen (display); /* get screen size */
display_width = DisplayWidth (display, screen);
display_height = DisplayHeight (display, screen);
width = X_RESN; /* set window size */
height = Y_RESN;
win_x = 0; win_y = 0; /* set window position */
border_width = 4; /* create opaque window */
win = XCreateSimpleWindow (display, RootWindow (display, screen),
win_x, win_y, width, height, border_width,
BlackPixel (display, screen), WhitePixel (display, screen));
size_hints.flags = USPosition|USSize;
size_hints.x = win_x;
size_hints.y = win_y;
size_hints.width = width;
size_hints.height = height;
size_hints.min_width = 300;
size_hints.min_height = 300;
XSetNormalHints (display, win, &size_hints);
XStoreName(display, win, window_name);
gc = XCreateGC (display, win, valuemask, &values); /* create graphics context */
XSetBackground (display, gc, WhitePixel (display, screen));
XSetForeground (display, gc, BlackPixel (display, screen));
XSetLineAttributes (display, gc, 1, LineSolid, CapRound, JoinRound);
attr[0].backing_store = Always;
attr[0].backing_planes = 1;
attr[0].backing_pixel = BlackPixel(display, screen);
XChangeWindowAttributes(display, win, CWBackingStore | CWBackingPlanes | CWBackingPixel, attr);
XMapWindow (display, win);
XSync(display, 0);
}
|
gcc your.c -lx11
|
晕 我随便说了个名字,竟然蒙对了
编译是通过了
运行问题我就不懂了,没玩过
编译是通过了
运行问题我就不懂了,没玩过
|
编译
gcc -I/usr/openwin/include -c source.c -o source.o
编译 & 连接
gcc -I/usr/openwin/include source.c -o yourapp -L/usr/openwin / lib -L/usr/X11R6/ lib -lX11
gcc -I/usr/openwin/include -c source.c -o source.o
编译 & 连接
gcc -I/usr/openwin/include source.c -o yourapp -L/usr/openwin / lib -L/usr/X11R6/ lib -lX11
|
编译的时候应该连接X11库吧
没用过,不确定具体的库文件的名称
没用过,不确定具体的库文件的名称