问下这个makefile的问题

superwavelet 2011-02-15 07:36:34
作业提示是:
makefile 里面需要写入这些:

-I/usr/openwin/include -L/usr/openwin / lib -L/usr/X11R6/ lib -lX11

但是我不makefile,所以如果不用makefile 直接写编译命令,根据上面的该如何写?

谢谢
...全文
143 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
superwavelet 2011-02-17
  • 打赏
  • 举报
回复
为什么呢?还是不明白
superwavelet 2011-02-16
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 wzzww 的回复:]

-I/usr/openwin/include -L/usr/openwin / lib -L/usr/X11R6/ lib -lX11
这啥东西呀?
-I是指定include路径,编译的时候用的,-L是指定lib路径,链接的时候用的,-l是指定链接库
[/Quote]

这是对的吧?
superwavelet 2011-02-16
  • 打赏
  • 举报
回复
为什么我重新编译了一遍,然后运行 ./Cprogram 就出现 cannot connect to localhost: 13.0

无知者无谓 2011-02-16
  • 打赏
  • 举报
回复
-I/usr/openwin/include -L/usr/openwin / lib -L/usr/X11R6/ lib -lX11
这啥东西呀?
-I是指定include路径,编译的时候用的,-L是指定lib路径,链接的时候用的,-l是指定链接库
superwavelet 2011-02-16
  • 打赏
  • 举报
回复
为什么我重新编译了一遍,然后运行 ./Cprogram 就出现 cannot connect to localhost: 13.0

为什么呢?新手求助
superwavelet 2011-02-16
  • 打赏
  • 举报
回复
太感谢你们了,我按照你们的指导这样写的:gcc -I/usr/openwin/include Cprogram.c -o Cprogram -L/usr/openwin/lib -L/usr/X11R6/lib -lX11

好像运行时闪现了一下,看不清。程序如下:
#include <X11/Xlib.h> // X11 library headers
#include <X11/Xutil.h>
#include <X11/Xos.h>
#define X_RESN 800 /* x resolution */
#define Y_RESN 800 /* y resolution */

#include <stdio.h>

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 %s\n",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);


}


不知为何
louyong0571 2011-02-16
  • 打赏
  • 举报
回复
都编译出可执行文件了?那调试下呗
lzj1980 2011-02-16
  • 打赏
  • 举报
回复
这样也不行吗?[Quote=引用 4 楼 yong_f 的回复:]
引用 1 楼 yevv 的回复:
假设你要编译source.c这个文件
gcc -I/usr/openwin/include -c source.c -o source.o -L/usr/openwin/lib -L/usr/X11R6/lib -lX11


这个好像有点问题。
-o 后应该是一个经连接后的可执行文件,不应该是源文件的目标文件
[/Quote]
superwavelet 2011-02-16
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 yong_f 的回复:]

引用 1 楼 yevv 的回复:
假设你要编译source.c这个文件
gcc -I/usr/openwin/include -c source.c -o source.o -L/usr/openwin/lib -L/usr/X11R6/lib -lX11


这个好像有点问题。
-o 后应该是一个经连接后的可执行文件,不应该是源文件的目标文件
[/Quote]

总之,我还是没弄出来
justkk 2011-02-16
  • 打赏
  • 举报
回复
gcc -I/usr/openwin/include source.c -o tt -L/usr/openwin/lib -L/usr/X11R6/lib -lX11
yong_f 2011-02-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yevv 的回复:]
假设你要编译source.c这个文件
gcc -I/usr/openwin/include -c source.c -o source.o -L/usr/openwin/lib -L/usr/X11R6/lib -lX11
[/Quote]

这个好像有点问题。
-o 后应该是一个经连接后的可执行文件,不应该是源文件的目标文件
wangtingguang 2011-02-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 superwavelet 的回复:]
引用 1 楼 yevv 的回复:

假设你要编译source.c这个文件
gcc -I/usr/openwin/include -c source.c -o source.o -L/usr/openwin/lib -L/usr/X11R6/lib -lX11

谢谢,但是./yourapp 运行后什么反应都没有?
[/Quote]

那跟你的程序有关关系了,都编译成了可执行文件了。
superwavelet 2011-02-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yevv 的回复:]

假设你要编译source.c这个文件
gcc -I/usr/openwin/include -c source.c -o source.o -L/usr/openwin/lib -L/usr/X11R6/lib -lX11
[/Quote]
谢谢,但是./yourapp 运行后什么反应都没有?
yevv 2011-02-15
  • 打赏
  • 举报
回复
假设你要编译source.c这个文件
gcc -I/usr/openwin/include -c source.c -o source.o -L/usr/openwin/lib -L/usr/X11R6/lib -lX11

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧