Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
gcc-编译示例xscreensaver时出错_C_Gcc - Fatal编程技术网

gcc-编译示例xscreensaver时出错

gcc-编译示例xscreensaver时出错,c,gcc,C,Gcc,我正在尝试编译示例屏幕保护程序simplesquares.c(来自)。我有vroot.h,这是我正在使用的命令: gcc -lX11 -o simplesquares simplesquares.c 以下是返回的错误: /tmp/cc0FvxcU.o: In function `VirtualRootWindowOfScreen': simplesquares.c:(.text+0x55): undefined reference to `XInternAtom' simplesquares.

我正在尝试编译示例屏幕保护程序simplesquares.c(来自)。我有vroot.h,这是我正在使用的命令:

gcc -lX11 -o simplesquares simplesquares.c
以下是返回的错误:

/tmp/cc0FvxcU.o: In function `VirtualRootWindowOfScreen':
simplesquares.c:(.text+0x55): undefined reference to `XInternAtom'
simplesquares.c:(.text+0x82): undefined reference to `XQueryTree'
simplesquares.c:(.text+0x108): undefined reference to `XGetWindowProperty'
simplesquares.c:(.text+0x14c): undefined reference to `XFree'
/tmp/cc0FvxcU.o: In function `main':
simplesquares.c:(.text+0x17b): undefined reference to `XOpenDisplay'
simplesquares.c:(.text+0x1c8): undefined reference to `XCreateGC'
simplesquares.c:(.text+0x201): undefined reference to `XSetForeground'
simplesquares.c:(.text+0x295): undefined reference to `XFillRectangle'
simplesquares.c:(.text+0x2e3): undefined reference to `XClearWindow'
simplesquares.c:(.text+0x2ef): undefined reference to `XFlush'
collect2: error: ld returned 1 exit status

这里发生了什么,我如何修复它?

静态链接库应该位于命令行的末尾

gcc -o simplesquares simplesquares.c -lX11
发件人:

在命令中写入此选项的位置会有所不同;这个 链接器按顺序搜索和处理库和对象文件 它们是指定的。因此,'foo.o-lzbar.o'在后面搜索库'z' 文件foo.o但在bar.o之前。如果bar.o引用“z”中的函数, 这些函数可能无法加载


链接器错误。。。您需要使用-L/path/to/Lib-L包含一些库libname@GradyPlayer我只是试着在两个地方用
-lX11
编译,前面的错误是一样的,最后的错误是没有的。那么我就可以改正了。。。好。。。也许,我不会真正尝试自己;)@GradyPlayer找到了文档。如果您好奇,请查看我的最新答案。:)好吧,我相信,这比最后的结果更有意义。